3

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.

Tejzeratul
  • 343
  • 6
  • 15

3 Answers3

1

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.

Dobbo
  • 1,188
  • 3
  • 16
  • 27
1

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.

code_guru
  • 210
  • 2
  • 11
0

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.

Community
  • 1
  • 1
Emil Adz
  • 40,709
  • 36
  • 140
  • 187