Is it possible to get suggested routes from google maps in android2.2 application?
Asked Answered
H

3

8

I am using the following url to get driving directions from google maps.

http://maps.google.com/maps?f=d&hl=en&saddr=location1&daddr=location2&ie=UTF8&0&om=0&output=kml

I am getting only one route in my KML file. But when we searched same locations in web-browser it will show suggested routes.

In order to get all routes available as output, is there any other parameter to add in URL.

I found some answers as use google directions API for JavaScript with &alternatives=true Is it suitable for android ?? or any other solutions ??

Don't comment if URL have any mistakes, i used correct one in my application.

Thanks

Heritage answered 14/12, 2011 at 14:36 Comment(0)
C
3

The answer does not address the question directly, but here it is:

I'd suggest using The Google Directions API and JSON output as far as

1) this API is better documented,

2) the parsing of JSON is much easier and

3) JSON consumes less network traffic because it stores data more effectively than XML (KML).

To solve your problem with Google Directions API you will just need to add alternatives=true request parameter.

However, look through this document. Perhaps, start=n parameter is what you're looking for.

Chisolm answered 26/3, 2012 at 7:19 Comment(0)
S
1

You can combine these 2 urls: URL1 URL2 to get your best result

  1. Request URL1 to get all paths you need
  2. Request URL2 for each of your start_locations and end_locations from the URL1 above

But, this would make your program slow.:).

Striking answered 31/3, 2012 at 19:0 Comment(1)
You can only use URL1 (Google Map WebService), and decode the polyline_data then get your path, I've just figured it out =DStriking
I
0

Im assuming it is looking for the shortest distance from point A to B along the roads. How about writing an algorithm based off of that?

Lets say from point A to B is 15 miles. There may be an alternate route that's will take you 5 miles more driving distance in the end. How about setting an adjustable range for the map to search for more than 15 miles based on the map? Maybe something that increments the distance until it matches up geographically, because usually, alternate routes will be longer.

To make it bit more complex, how about making a call to multiple routes?

Imbalance answered 2/4, 2012 at 4:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.