I am trying to use google maps directions API with continuous hitting to the API and updating the directions by getting a current location on location changed listener and it works perfectly.
But Instead of hitting multiple times I need to get directions API for the single instance and write an algorithm by getting the directions using segments start point and update on google map, Find a way to know the user is traveling in the wrong distance and re-route map by calling API.I tried these ways and working but there are a lot of cases to be handled for these scenarios.
I don't understand what to follow and why this is required is, we have a display cycle and the user starts the navigation and directions should be shown on cycle hardware display via BLE.
Please help me solving this issue.
You can try using the Google Maps Util Library. The PolyUtils
class has methods to check if a LatLng
lies on a polygon/polyline.
Maybe try using the method isLocationOnPath
. And if it's outside the polyline, make the request to directions API and re-plot the route.
Docs: http://googlemaps.github.io/android-maps-utils/javadoc/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With