Reputation: 1024
i'm using the MKMapView first time.
I need to show some address in one MKMapView: the address (take parsing an xml file) are google maps links.
Is possible to set the coordinates of the MKMapView using the URL? Or i need to take the longitude and latidude?
thanks
Upvotes: 1
Views: 1183
Reputation: 8254
To plot a point on a MKMapView, I'm pretty sure you need the longitude & latitude of the point.
As far as I'm aware using the iPhone MKMapView & associated classes, you can do reverse geocoding (ie - convert a longitide & latitude into an address), but I think going the other way - forward geocoding (address into a longitude / latitude) is not supported.
There are plenty of services you can use though that aren't google that do forward geocoding - one of which is Geonames. The free service has no support contract, so it's liable to stop working without notice - but it seems to do the trick OK for small or offline operations.
Upvotes: 0
Reputation: 5835
You have to take the longitude and latitude position of the point otherwise you can provide address to google map service, it will provide a lat and long position in JSON or XML format(for reference see google Reverse geo coding).
http://googlemapsapi.blogspot.com/2006/06/geocoding-at-last.html
use NSMutableRequest class to find-out the lat and long, for reference urlString-
NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@&output=csv", theAddress]; NSString *locationString = [[[NSString alloc] initWithContentsOfURL:[NSURL URLWithString:urlString]] autorelease];
for MKMapView you can refer this blog- link
Upvotes: 0