'Notify me for a specific location or straight road google maps

I'm getting my current Lat Long from fused I want to notify my user when he/ she comes on a specific route

In the below i have share you a location which is Yamuna express way I want to show notification to user when user comes on this highway from any side or any where

please answer properly, I'm really in the need of answer

Click to see image



Solution 1:[1]

You should know "specific route" coordinates and periodically check does the current user position lays on route. If you use Directions API you can get route coordinates from Directions API response, if you need specific street you can add its coordinates manually (or download them from e.g. OpenStreetMap).

For checking whether the current user position lies on or near a "specific route" polyline, you can use isLocationOnPath method from PolyUtil library:

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

where point - current user coordinates, polyline - list of "specific route" coordinates, geodesic - map modes (set it to true) and tolerance - maximal distance (in meters) between "specific road" and user coordinates when user still considered "on the specific route"

For reducing power (and traffic) consumption you can add some geofences along the route (or better only on crossroads where user can enter the route) and track user location precisely only if user within one of geofences:

Geofences along the target road

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Andrii Omelchenko