Inaccurate locations in turn-by-turn GPS navigation

90 views Asked by At

I am developing an Android application which has a turn-by-turn navigation between two locations. However, I've been struggling to make the navigation smooth.

I call Directions Api from Google API to retrieve the route and I've already displayed it on the map. When switching to turn-by-turn navigaton I just set the marker to the new location (also animating the marker) using location manager (using both course and fine location). Everything works fine although the gps and network provider have some innacurate locations as shown in the image in the link below.

Although does errors sometimes aren't too big ( for example the location is set at the sidewalk next to the street), I need the marker to be always following the polyline as long as the user is following the route, otherwise it will have to recalculate the route. Furthermore, as I calculate the bearing of the icon through the previous location and the new one, sometimes the icon does weird things.

I don't want to use any external library as the majority aren't free and the application won't be for personal use in a future. My first idea was to check if the distance of my updated location to the polyline was bigger than x (say 5) in order to detect those errors. However, my application has to recalculate the route so this isn't a valid option. I've read about Kalman algorithm to detect errors, but people say that gps internally already filters location using that algorithm.

So I need advice in order to fix those innacurate locations and make a smooth navigation as Mapbox or Google Maps or Uber does.

Link to image: https://ibb.co/n511We

Yellow line indicates the route I made and the purple circles are the inaccurate locations.

0

There are 0 answers