Reputation: 109
i call the url of googlemaps to show a position to a given lat and long. How can i mark this position on the map with a pin ?
NSString *latlong = [NSString stringWithFormat:@"%@,%@", einBetrieb.lat, einBetrieb.lng];
NSString *url = [NSString stringWithFormat: @"http://maps.google.com/maps?ll=%@",
[latlong stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
Regard Caglar
Upvotes: 3
Views: 1189
Reputation: 3827
Try this url:
NSString *url = [NSString stringWithFormat: @"http://maps.google.com/maps?q=%@", [latlong stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
That should get you what you want. Replace the "ll" with a "q"
Upvotes: 1
Reputation: 9113
You should use MapKit to display map on iPhone, you will have greater flexibility and faster integration.
mapView being a MKMapView instance, you will have to manipulate your string to extract long and lat then
CLLocationCoordinate2D loc;
loc.latitude = extractedLatFromString;
loc.longitude = extractedLongFromString;
AddressAnnotation *pin = [[AddressAnnotation alloc] initWithCoordinate:loc];
[mapView addAnnotation:pin];
should do the job
Upvotes: 0
Reputation: 33335
I think you really need to use the mapkit api to solve your problems. Launching the Maps App externally will not give you the access you desire
you can do a quick search of StackOverFlow to find solutions, here is the first one I found
iPhone MapKit - update annotations coordinates and map
Upvotes: 1