Search code examples
androidgoogle-mapscoordinatesgoogle-polylinegoogle-directory-api

Google Map Checking if cooridinate is between 2 points


ANDROID APP

I've use google direction API to get a route from 2 points.

All the routes returned is saved if there is a need to reference to any of that data

Then I decoded the overview_polyline into a list of LatLng and drew the polyline on the google map.

How do I find out if a given coordinate (traffic accident for example) is on/nearby the polyline route , plus minus a constant distance (maybe 100m?)


Solution

  • You can use Google Maps Utility Library.

    Especially isLocationOnPath(LatLng point, java.util.List<LatLng> polyline, boolean geodesic, double tolerance).

    Here's the full documentation.