Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Directions API Live tracking in android app

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.

like image 763
Nithin Avatar asked Oct 18 '22 02:10

Nithin


1 Answers

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/

like image 128
Basant Singh Avatar answered Oct 30 '22 18:10

Basant Singh