Google Map V2 Lib Android, draw active path from GPS update - android

I don't want to show the route as there is no destination point in our app, so what we want is to show the active path of the user over the map from the starting point to the current point.
Problem: As some time or most of the time the location shown outside the road on which user is traveling, which draws the path outside the roads.
Help me to draw the path on the road as user is driving on the road.
How Google do the same? or is there a way to do so which i am missing or
any algo to correct the path.

That is a very common problem that all GPS devices need to solve.
See http://econym.org.uk/gmap/snap.htm for some examples to snap your location coordinates to a street.

Related

Alert when current location is near marker android map

I am building an app for android that uses google map. its like a navigation app that updates the location on screen while in motion. I have placed multiple markers on the map and for each marker there is a radius of 125. When the current location intersects with the marker radius I get a warning message. This is done by looping through all markers and check if the current location intersect with the radius of any of the markers at the OnLocationChangedMethod() . it works well if you have couple of markers but I have more than 30 markers. By the time it takes to loop through all markers and report if there is an intersection , current location would have passed the marker. so it takes longer time and its not very efficient.
I hope someone can help for a better approach on how to do that. I have read couple of solutions that suggest taking the map bounds and find the visible marker. but this also iterate through all marker and it would take the same time as my solution.
I would appreciate if anyone could help.
Thanks,
Abdullah
This sounds like you would be better suited for Geofencing because it is basically what you are trying to do. No need for all these different services and such when there is something already built in
Use two services. One to get the current location and another to calculate the distances.

Point misplaced at street. Android application with maps.

I am developing an application that marks the path taken in real time (on android). Sometimes the gps fails and a point located in a building. Is there any way to fix this? Could I ask google if the marked point corresponds to a building, not the street, sending the location?
Thank you.
You can only partially avoid that, by using the accuracy fields from location. you cannot rotally remove that effect, which is typical for GPS.
It is possible to snap the position to the next road, when you have the vector data of the street (or map). But this is often not a good idea, when you travel by train then the losition will be false corrected to a near road. further if the street you are travelling dors nor exist on the map.

Google Directions Service: consider each corner as a step

I'm working in an Android application that will use Google directions service.
The source location is determined by the GPS and the destination is set by the user, the user can also set some waypoints by touching in the MapView (this is optional). Finally the app draws the route between these points.
When invoking the Google directions service I get a list of "steps", as far as I'm concerned each step corresponds to a point where the driver has to turn (right?). Is it posible to get more steps? For example consider each corner of the path as a step?
Thanks in advance.
Finally I could draw a precise route by decoding the "polyline" of each step returned by the service. A polyline contains an object holding an array of encoded points that represents an approximate path.
So I decoded that into a List of GeoPoints and then drew the lines between those GeoPoints.
In case someone needs to do something similar, this was really useful to me:
Google Maps API Version difference

Android:Draw path on mapv2 as device moves

i am making an app in which i have to draw path on map as my devices moves. I searched my tutorials but all show to draw path b/w two points but i want to draw path as my device moves.
Any help regarding this will be appreciated.
what do you mean as your device move? either way you have to get location updates using location listener and on every new update create a Polyline between the coordinates of the new update and the previous one.
UPDATE: Here are some post that show you how to draw a polyline with direction:
Is there a way to show road directions in Google Map API v2?
Get driving directions using Google Maps API v2
I could use the concepts there to draw you the line you want.

Google Maps Android API v2 routes json parsing

Hi With the help of LocationManager I managed to find current location in android.
For showing routes between two geo- co-ordinates what should I use so that I wont plot air distance instead will show ground routes or is it with help of json can I plot routes.
I have tried polyLine() but it gives straight line.
To work out the line between two points you need to know what map projection type you are using. Some map projections preserve shape (and therefore angles) others do not. Take a look at http://www.progonos.com/furuti/MapProj/Dither/CartProp/ShapePres/shapePres.html it might help.
If you're using a Mercator projection then I found this page that claims an algorithm in C# that should point you on your way: http://conceptdev.blogspot.co.uk/2009/01/great-circles.html
As for the line segments, ployline will give stright lines between the points. You'll need to use Path and use the Bézier curve methods Path.cubicTo() and Path.rCubicTo() from memory.
Do you have all permission set in the Manifest? Also, you have to enable the location service (is the gps icon in the status bar showing?). It'll take some time for the device to get the location, so see if onLocationChanged is called.
Here you can find the answer for your qustion:
Is there a way to show road directions in Google Map API v2?
and here:
Get driving directions using Google Maps API v2
basically what you should do is make a call to Google Directions API receive the road direction coordinates (many Latlng points), and then draw a polyline between each one of them.

Categories

Resources