Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open iOS maps with pin using latitude and longitude

Tags:

ios

mapkit

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?

like image 823
Matrosov Oleksandr Avatar asked Nov 12 '13 00:11

Matrosov Oleksandr


People also ask

Can you use latitude and longitude on Apple Maps?

GPS coordinates are often used by hobbyists, surveyors, outdoor enthusiasts, and for many other purposes, which gives this approach a more technical lean than simply sharing a location through the Maps apps on iPhone directly, since raw GPS coordinates can be used by not only iPhone as well as Android but also the vast ...

How do I get coordinates from an Apple map pin?

Get the coordinates of a placeTouch and hold an area of the map that isn't labeled to drop a red pin. At the bottom, tap Dropped pin to find the coordinates.


1 Answers

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];
like image 95
Kalpit Gajera Avatar answered Nov 05 '22 10:11

Kalpit Gajera