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 :-)
Related
I have two Addresses let say Location A and Location B. And I have series of location between those Location A and Location B. I get those series of locations via Fused location API. and saved them on the server. Now following are my requirements :
What I want:
I want to calculate the distance between the Location A and Location B. Right Now I am using a code (link of post here) but it is giving me displacement.
Problems and Confusions:
I know about Google Distance matrix API and Google Directions api, but I really do not want to work on these apis as these are costly to me. But if I use them, I really did not understand that how API will know the route user selected. I mean it is possible that User has adopted the long way towards his destination. And I think google Direction and Distance API are returning the distance between Location A and Loation B using shortest route.
I really do not want to use the API, but if there is non other
possible way to do that then How could I get that ? and what is best
for me. Please suggest me the solution.
I think you have just idea of your logic but you do not know what it is called. Though it is too late but I am posting for your information or in case of if someone later on visit here.
To draw lines between two points on Map,Use Polylines and polygons. To read further I will refer you to this google page, It has a breif introduction and also a source code. And it is even really easy to implement. Here you go.
I am developing an app which given a postal code will return map of the area with all the roads in the 100m radius highlighted either green red or yellow based on our machine learning algorithm. My task is 2-folded
Gather all the roads in 100m radius given Postal code
Highlight those roads using different colours
Our solution to the very first problem is quite inefficient atm, we are trying to convert the postal code to LatLng and then calculate boundary boxes with LatLng +/- 100m and extract street names. This sadly uses so much bandwidth AND API calls that we must look for a new solution. Is there anything we could use instead?
As of highlighting those roads that are another problem, as I have encountered problems where the application needs to highlight specific route, which was solved using polylines based off points google maps API returned. In this case, though, no points are returned as of now.
I know that those are 2 question but they are so closely related to each other (as the output of 1st problem will be used in the drawing lines) that I've decided to ask them together.
Really appreciate your help!
In case people are wondering how to solve similar question here's how we solved it:
Our current solution is sending the initial Postal Code and radius to OpenStreetMap API called overpass (http://wiki.openstreetmap.org/wiki/Overpass_API) which returns streets within given bounding box (which is calculated using postal code longitude and latitude) as a WAY (set of points in JSON format). The returned WAY can be easily visualised using polylines included in the google maps API.
Hope that helps!
My Android app scenario is the following:
The user is a bus driver and he has some people to deliver to their locations(places). Is there is a way to do the following:
Get the best route passes from their locations.
Sort this list according to driving distance on that route.
Get each location's driving distance according to that route.
Can any of the Google APIs help me accomplish the above? Or perhaps a combination of two APIs?
Update:
I see that google-matrix-API give me the driving distance from an origin location to some destinations but I am not sure that it will calculate them as on the one driving trip.
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
I am a student working on an android application related to navigation trying to learn android programming. The application needs to search the geo-locations (latitude,longitude) among the ones available and find out which ones fall along the route the user is travelling.
For example, if the user is travelling from 37.422,-122.084058 to 37.422,-122.084058, then I should be able to search the points that fall along this route from the set of points that I have. How do I do that?
I am getting the route direction of the user from the google api
https://maps.googleapis.com/maps/api/directions/json?origin=Googleplex&destination=infinityloop=&key=your_api_key
I get the route in the form of legs and I have a set of geo-locations. I would like to find which geo-locations fall along the route of the user. Is there any way I can find it or any API that I can use ?
Any help is greatly appreciated. Thanks in advance :)
There's already a lib for this: use isLocationOnPath with the polyline you are getting from directions api response.
Build a LatLngBound using the two points and pass in the geolocation point you want to check into LatLngBounds.contain().