Finding particular cities along your Path

后端 未结 1 701
旧时难觅i
旧时难觅i 2021-01-25 22:42

I need your suggestion. I am creating a web application where I need to find if particular city\'s exist along my path. I am using google API to get direction along path,but it

相关标签:
1条回答
  • 2021-01-25 23:14

    The name of a city isn't very accurate, you'll need a LatLng for the city.

    Based on a LatLng the method isLocationOnEdge() of the geometry-library allows you to determine if the LatLng(city) lies on (or is near) the polyline defined for a route:

    google.maps.geometry.poly
      .isLocationOnEdge(LatLngOfCity,
                        new google.maps.Polyline({path:google.maps.geometry.encoding.decodePath(response.routes[0].overview_polyline.points)}),
                        0000000001));
    

    response has to be a directionsResult, the last parameter is a tolerance

    http://jsfiddle.net/doktormolle/DXCH8/

    0 讨论(0)
提交回复
热议问题