4

I am new to android and developing a navigation based application for android.My question is I want to show a route with multiple way-points between source and destination node in Google maps and I don't know how to do it. I have search for this but most of the results are for two points.

Please help me to solve my problem

e.g:- when app user submits the destination with some way-points the map should display the route from the source to destination with those way-points on the phone.

Thanks !

Cham
  • 787
  • 3
  • 11
  • 25

3 Answers3

0

"I have search for this but most of the results are for two points." You already found everything you need to do this.

For this, you're not "drawing through the waypoints along the way," you're actually going to have to draw a route between 2 points for each waypoint you have:

IE. You want to get from point A to point D, and on the way there are points B and C. The solution is to draw a route from A to B, B to C, and finally C to D.

Cruceo
  • 6,763
  • 2
  • 31
  • 52
  • Take a look at the source for this; it contains what you're looking for: http://stackoverflow.com/a/2339975/1426565 – Cruceo Jun 14 '12 at 20:05
  • Thankz for the effort Cruceo..But it shows a straight line from one point to the other...What I am trying to do is show the route(road) between the two points... This is how I show a route between two points. Uri uri = Uri.parse("http://maps.google.com/maps?&saddr=latitude,longtitude&daddr=latitude,longtitude"); Intent ShowMapWithDirect = new Intent(Intent.ACTION_VIEW, uri); startActivity(ShowMapWithDirect); Using this I can only show the two points. I can not give any waypoints to show on the map.. – Cham Jun 15 '12 at 06:25
  • You'll have to implement your own MapView then, as opposed to using intents. Look for Custom MapView – Cruceo Jun 18 '12 at 14:28
0

I don't think the Maps intent offers those capabilities, but you do have some other options

Better but more work 1)Create your own map activity that displays routes for multi-location(using a mapview and overlays). Here is an example of how to convert the kml file to a route

Quicker and Easier 2)Create a simple webview (or you can just intent a new one with a given url) and dynamically build the url for a google maps api request with waypoints. See Google's website for documentation on getting a map with routes via waypoints.

Community
  • 1
  • 1
MikeIsrael
  • 2,871
  • 2
  • 22
  • 34
  • Thankz MikeIsrael....At last I have drawn the route. I used the direction API, in the response they give the points values under the overview_polyline tag, I decode it and draw the route. Like that I have drawn the route from source to destination with multiple waypoints. – Cham Jul 09 '12 at 05:19
  • @user1457039 glad to hear, also I think I noticed that you might need to add a line from your src point to the first point in the route and from the last point in the route to your dest in some cases. That is more style than functionality, but glad you got it working. – MikeIsrael Jul 09 '12 at 06:52
  • @user1457039 hi if u got the solution pls provide me i am also stuck on same problem – siva Apr 01 '15 at 12:18
0

You can use the map intent like this:

    String address = "http://maps.google.com/maps?daddr=" + "Latitude" + "," + "Longitude" + "+to:" +"Latitude" + "," + "Longitude";
    Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(address));                                                         
    startActivity(intent);

in this case the start point will be your current location and you can add as many intermediate points as you want using "+to:"

Roman Marius
  • 456
  • 3
  • 9
  • 21