Oleksandr Matrosov
Oleksandr Matrosov

Reputation: 27133

Open iOS maps with pin using latitude and longitude

I use this code for opening maps app

NSString* versionNum = [[UIDevice currentDevice] systemVersion];
    NSString *nativeMapScheme = @"maps.apple.com";
    if ([versionNum compare:@"6.0" options:NSNumericSearch] == NSOrderedAscending){
        nativeMapScheme = @"maps.google.com";
    }
    NSString* url = [NSString stringWithFormat:@"http://%@/maps?ll=%f,%f", nativeMapScheme, 40.739490, -73.991154];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];

Seems it works good, but there is no pin on this location I use. How to add pin, I suppose there is additional parameters in request?

Upvotes: 9

Views: 2913

Answers (1)

Kalpit Gajera
Kalpit Gajera

Reputation: 2525

If you want the pin to be placed on Apple's Maps app, use a 'q' instead of 'll' in the URL.

You can Use like this

 NSString* url = [NSString stringWithFormat:@"http://%@/maps?q=%f,%f", nativeMapScheme, 40.739490, -73.991154];

Upvotes: 12

Related Questions