有没有办法从NSMenuItem打开OS X(Maverick的)Maps.app?我想在Apple Maps上绘制纬度/经度对。

这将在浏览器中打开OpenStreetMaps:

-(IBAction) plot: (id) sender {

    NSURL *url = [NSURL URLWithString:@"https://www.openstreetmap.org/"];
    if( ![[NSWorkspace sharedWorkspace] openURL:url] )
        NSLog(@"Failed to open url: %@",[url description]);

}


相关主题:

Programmatically open Maps app in iOS 6

最佳答案

参见Apple's spec here

 NSURL *url = [NSURL URLWithString:@"http://maps.apple.com/?ll=45.5200,-122.6819"];
 if( ![[NSWorkspace sharedWorkspace] openURL:url] )
      NSLog(@"Failed to open url: %@",[url description]);

关于objective-c - 在OS X中以编程方式打开Maps应用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22952067/

10-14 18:52