Quote:
Originally Posted by Frankie
How do I find the distance between two places that I type in (like LA to NY or Boston to Tallahassee). Not using points but with text kinda how the directions in the google maps application is set up. Is there a tutorial on this or sample code I can follow?
I've seen a few tutorials but they're mainly dealing with dropping pins or knowing longitude and latitude coordinates.
|
The short answer is that with just the map-kit, you don't.
You need the ability to Geocode, or convert an address to a lat/long. The map kit includes a very limited API for REVERSE geocoding, which is taking a lat/long and converting it to an address.
What you want is forward geocoding.
The Google Maps server API includes this feature. You would need to go read up on the Google Maps server API as well as Google's license for using it. If I remember correctly, they limit you to looking up around 1 address a minute, only at the request of the user, and only if the results are displayed on a Google-branded map (Apple's map kit meets that last requirement because the maps have a google logo on them.) Bear in mind, though, that I'm quoting the license restrictions from memory, and I'm not a lawyer. Do a <google> search on "Google Maps JavaScript API V3" for more information.
Once you have your addresses converted to lat/longs' there IS a makit call that will calculate the distance between 2 points. It's a method of CLLocation called getDistanceFrom:.