When I draw a route in google map between two coordinates, I am using below Google API URL it works I can get all data, but now I can draw route between many coordinates how can I do this?
http://maps.googleapis.com/maps/api/directions/xml?origin=41.020381,28.936672&destination=41.023722,28.939016&sensor=false&units=metric&mode=driving
You can use waypoints https://developers.google.com/maps/documentation/directions/intro#Waypoints but take into account that the maximum allowed number of waypoints is 23
You can use waypoints, the documentation can be found here:
Google Maps APIs Waypoints
However, since waypoints only support a maximum of 23 waypoints, you'll need to divide the total number of points by 23 to get the interval you need to leave between points to end up with 23. This will not give you an incredibly accurate route, since you'll be missing many of the recorded points.
We found that an alternate solution was to not use the Google Maps Directions API, instead we just record a location as often as possible and then draw these points as a polyline directly onto the map, avoiding the need for any direction requests.
Related
I am using google direction api to find route between two points. It is currently returning me shortest available route between two points. Is there is anyway to find the longest route between two point using google direction apis.
What do you mean by longest route?! you can pass all the streets in the continent you are in and still don't reach the destination!
For example you want to go from Norway to Sweden and you go to Denmark and keep moving in streets forever :D
I believe, you need to use Direction API instead of Distance Matrix API.
Please note that you need to add alternatives=true to your query parametrs, then you will have all possible routes suggest by google maps, in addition to their distances/durations :-)
I have for example more than two points on streets in my app, how to draw route between them depending on streets?overview_polyline from Google Directions API working only with 2 points at the time?Is it possible to make Google Directions API one request with many points and get overview_polyline route?
Hope it help Google Maps Directions API
On our website we we plot two points on a map, and the google direction api neatly gives us the traveling time. If we change the from or to address some new calculation are performed, and the new traveling time is displayed on the site.
We are trying to create the same kind of setup in Android, but I see that there is no support for the directions API. I have looked at some old examples like this one Drawing a line/path on Google Maps but here there is just a simple line between two points. I do not see anything about the traveling times.
Another question I stumbled uppon was the following Directions API on Android but I do not see how the connection is made between the Android Maps API and the Google maps direction API.
To draw path you can use this library
Through this library you can get travel duration between two point. now when you move to your destination location you have to calculate your speed and remaining destination distance. from your speed you can assume you destination reach time.
To calculate your moving speed this link will help you
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.
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)