iphone application distance [duplicate] - google-maps

I want to calculate the driving distance between two locations [the user's specified locations], before user starts the driving. I used many formulas and getDistanceFrom in CLLocation also, but I am not able to get the perfect the driving distance between those locations.
There is much difference in actual and calculated distance.
Please help me to calculate the driving distance between two locations.
How can I use Google Maps API to calculate the driving distance ?
I have already use the regexkitlite to show the road path on Google Maps between the two place. However I can't calculated the path distance.
If you have any code/link, please send it to me.
Thanks in advance....

See directions API of Google Maps
You have just to make a HTTP request:
http://maps.googleapis.com/maps/api/directions/output?parameters
Answer could be json or xml. You will find the distance in the answer

If you have two LatLongs you can calculate the direct distance between them; however, since you want driving directions (not as the crow flies) you'll need access to street-center-lines, so you can calculate the distance for each "leg" of the trip.
Google Maps may provide driving directions along with route distance, you'll need to check the documentation for that specific functionality.
edit
On a second look, it appears this may not be available on the API (as of 2006), but a work-around is posted here: http://groups.google.com/group/Google-Maps-API/msg/4dc2fad4f74e3314

Using Core Location API it will only give you the distance between two point in a straight line - most roads aren't, and hence the distance will be wrong.

Related

Google Maps API - Getting Street Coordinates

Google Maps API has any way to get the street coordinates of an location?
Is simple: I just want to get the nearest street coordinate. To got this i need, for example, all coordinates that compose a street.
Are there something like this?
You may use the directionService.
Pass the given address(or location) as origin and destination to directionsService.route() and use the travelMode DRIVING . The response should contain the nearest street.
Demo: http://jsfiddle.net/doktormolle/W3VGN/
I found this (ReverseGeocoding in v3): https://developers.google.com/maps/documentation/javascript/geocoding#ReverseGeocoding
Since this thread is old I suppose this could be useful.
These answers are all old, and Google has rearranged the maps API significantly since the answers.
In 2018, the best way to turn a location (long, lat) into a "point on road," is to use the snap-to-road or nearest-road service:
https://developers.google.com/maps/documentation/roads/snap
Note that this API charges a cent per API call, and can take up to 100 distinct points per call. If latency and complexity aren't problems, if you need to answer this question on a client, you could build a server that collects up to 100 requests from different clients, makes one request to Google, and then returns the request data back to the appropriate clients. (For this use, make sure to use nearest-road, not snap-to-road.)
Also, currently, Google Maps has a $200 per-month statement credit available, which may make smaller uses of this API not actually end up costing much (or anything at all.)

How to compare Google Maps coordinates on an accurate way?

I have the coordinates(lat, lng) and the information associated to this point in an excel sheet.
I want to compare the coordinates that I have stored on a database(lat, lng) with the excel ones.
My main idea is to show the correct info about the road point on the info window associated to the marker.
My doubt is about how to choose the coordinates on the most accurate way?.
Any suggestion?
So I think I understand what you are doing - capturing the coordinates of a user's location and then you want to find information about what is nearby to that location. If I have that correct, I suggest you take a look at the Places Library.
Google provides a library/service that allows you to send a requestthat includes a location and radius or coordinates that define a rectangular bounds and the service will return information about nearby places of interest. There are many ways to refine the searches to focus on different types of features.
I think this is what you are looking for - if not, provide a little more detail and I will try to help you.

get all possible directions from A to B

I want to find all possible routes from point A to point B (not only shortest ones). So my question is, is there any web service api (because I use Java) for such request in Google Maps, Yahoo Maps etc. it doesn't matter which one..
I've found something about this topic in Google Maps Directions Api: "alternatives (optional), if set to true, specifies that the Directions service may provide more than one route alternative in the response. Note that providing route alternatives may increase the response time from the server." But unfortunately, I couldn't use this option, when I include alternatives=true inside request query I get the same result. That would be nice to have such an alternative - it's more flexible, but I found something guarantied one with waypoints (but its much like "hardcoding" - we specify streets that we will pass from). Anyone tried alternatives=true?!
Here's another approach and solution for this problem: convert meters to latitude longitude from any point
Thanks for your responses..
I'm using the fact that google maps' paths uses rounding boxes to get a circle, to do so i just choose the point that i want and create a route to another that is not the same but very very close to it, just like:
http://maps.googleapis.com/maps/api/staticmap?size=400x400&path=color:0x5600FF80|weight:100|51.5285582,0|51.5285583,0&sensor=false&zoom=15
We can choose the weight as the diameter of the circle, note that it is a fixed value, not related to the screen size and the zoom.

Google Map Distance Calculation

Does anyone know if Google Maps consider elevations and the actual path on earth to calculate distance between two points or it only considers geographical locations for distance measurement?
If you are referring to using google.maps.DistanceMatrixRequest then yes, it considers the actual route when calculating distance, based on the option provided in travelMode
code.google.com reference
When there is no established route (at least known to google) i'm sure (from experience) the response is the distance 'as the crow flies' between 2 lat/long locations. [experience based off making the request for a path that bisected a large lake]

How can I get the subway/bus distance between two locations in the NYC area?

I was able to query Google directions api for the driving distance between two points but they don't expose a way to get the distance or directions for the subway. Is there a good api out there that does this?
HopStop has a free API: http://www.hopstop.com/freeapi/
Haven't tried it myself yet thought.