Google Maps Android API v2 routes json parsing - android

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.

Related

Google maps api v2 how to find the nearest location

I am using Google maps api v2 in android. I have created xml parser for the bus stop. Bus stops are displayed using markers. I need to find the user's current location and find the nearest location (bus stop), best automatically (for example in a radius of 0.5 kilometer).
I tried to find a tutorial, but unfortunately I failed it.
Thank you for your help.
There is the distanceTo() method of Location class that gets the distance between 2 locations, in a straight line. You can find an example on how to use this here: How to get straight distance between two location in android?
But, if you don't want the straight line distance, rather the Travel distance, I'd recommend you take a look at this question and answer: Get the distance between two locations in android?

Google Maps Android API v2 - DirectionsRenderer

I already searched on StackOverflow and Google. But i didn't find a real answer. I think there is just no DirectionsRenderer in the Android API. But can you acknowledge this?
If there is not DirectionsRenderer, how could i use the Android API to show a GoogleMaps and draw a Route on the Map?
I want to draw a nice route. Not just lines between the coordinates of each route-section which are also delivered from the Directions-Request.
I think there is just no DirectionsRenderer in the Android API. But can you acknowledge this?
There is no DirectionsRenderer in Maps V2. You can tell this by reading the documentation.
how could i use the Android API to show a GoogleMaps and draw a Route on the Map?
There is nothing in Maps V2 to support this.
I want to draw a nice route. Not just lines between the coordinates of each route-section which are also delivered from the Directions-Request.
You will need to find some Web service that will serve up coordinate information for the route with sufficient granularity (e.g., every 10m) to give you your "nice route", then use a Polyline or something like that for actually rendering the route.
SO i found out that it is possible to just take the legs, then the steps and within the steps you will find the "points".. when you decode the points string its a very detailed list of all coordinates.
with this coordinates, you can easily draw a nice route on the map.
so it's possible without the need of a additional Web-API.

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.

Is it possible to get the route network from Android Google Map?

I am trying to find a way to get the map of the road network currently visible on the the screen, while using the Google Maps API v2 for Android. I want to place some markers along roads, but I don't know if that is even possible? I can get the addresses, or the path between two addresses(using the route manager), but I need to know if I can paths of...all the roads visible?
That want you want, is to get the route as vectors (as poly line of latitude, longitude) coordinates.
But, No you can't. (although there is an inofficial Google API that gest the route as coded and compressed vector, but the usage is not legal.)
The vectors are "owned" by TeleAtlas/TomTom and they are not public availble, nor has Google the right to give them out.
If you need vectors, then you have to use OpenStreetMap routing Service, which potentzally provides vectors of a route (via an OpenStreetmap API)

Get Directions Google maps Android

There is a Google map and on it marked objects. With GPS defining man's place on the map.
The aim is to set the phone automatically detects and plot a route to the nearest object. How can it be obtained?
I find this tutorial very helpful:
http://www.anddev.org/google_driving_directions_-_mapview_overlayed-t826.html

Categories

Resources