質問

Is there a way to open OS X (Maverick's) Maps.app from a NSMenuItem? I'd like to plot a lat/lng pair on Apple Maps.

This will open OpenStreetMaps in a browser:

-(IBAction) plot: (id) sender {

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

}

A related topic:

Programmatically open Maps app in iOS 6

役に立ちましたか?

解決

See 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]);

他のヒント

open -a Maps.app will open it from a Terminal.

You could do this in NSAppleScript or probably from Launch Services

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top