Call up Google Maps with a URL from Objective-C

I call googlemaps url to show position for 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]];

Give up on Caglar

+3
source share
3 answers

Try this URL:

NSString *url = [NSString stringWithFormat: @"http://maps.google.com/maps?q=%@", [latlong stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

This should get what you want. Replace "ll" with "q"

+1
source

I think you really need to use mapkit api to solve your problems. Launching the Maps app from the outside will not give you the access you want

you can quickly find StackOverFlow to find solutions, here is the first one I found

iPhone MapKit -

+1

You must use MapKit to display the map on the iPhone, you will have great flexibility and quick integration.

mapView, which is an instance of MKMapView, you will have to manipulate your line to extract long and lat, then

CLLocationCoordinate2D loc;
loc.latitude = extractedLatFromString;
loc.longitude = extractedLongFromString;
AddressAnnotation *pin = [[AddressAnnotation alloc] initWithCoordinate:loc];
[mapView addAnnotation:pin];

must do the job

0
source

Source: https://habr.com/ru/post/1765135/


All Articles