Reputation: 26272
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
Upvotes: 2
Views: 723
Reputation: 5953
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]);
Upvotes: 6
Reputation: 1275
open -a Maps.app
will open it from a Terminal.
You could do this in NSAppleScript
or probably from Launch Services
Upvotes: 0