문제

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