Search code examples
androidgoogle-mapsgoogle-maps-api-3coordinatesgoogle-directions-api

How to lookup coordinates on google maps directions api response?


Is there any api or way of checking if a coordinate or location exist in the returned Direction Api response?

https://developers.google.com/maps/documentation/directions/#DirectionsResponses

I want to check if the returned Direction Api response contains my hardcoded coordinate/location?

enter image description here


Solution

  • If you use the API:

    The DirectionsRoute returns the overview_path (array of the lat/lng). With this, you can create a Polyline. And you can use this Polyline to call google.maps.geometry.poly.isLocationOnEdge function

    If you use the WebService:

    The returned JSON have a overview_polyline key. You can use it to create the Polyline and call google.maps.geometry.poly.isLocationOnEdge function

    Regards