The Apple Developer Documentation (link is dead now) explains that if you place a link in a web page and then click it whilst using Mobile Safari on the iPhone, the Google Maps application that is provided as standard with the iPhone will launch.
How can I launch the same Google Maps application with a specific address from within my own native iPhone application (i.e. not a web page through Mobile Safari) in the same way that tapping an address in Contacts launches the map?
NOTE: THIS ONLY WORKS ON THE DEVICE ITSELF. NOT IN THE SIMULATOR.
You can use the Google Maps Platform within your applications as long as your site meets the Google Maps Platform Terms of Service.
Tap the menu icon in the top left of the search bar. Scroll down to the bottom of the menu and tap Settings. Tap Default apps. Under Navigate from your location, tap Google Maps, then under Navigate between locations, tap Google Maps again.
Tap the top-left menu icon. Scroll down and find “Settings.” Select “Default Apps.” Under “Navigate from Your Location,” select “Google Maps.”
Using Swift 5 and XCode 13, I was able to use Google's Universal cross-platform syntax to open Google Maps app in directions mode. The link will open the google maps app if it is installed on the phone. If maps is not installed it will open the url in the browser.
For iOS 5.1.1 and lower, use the openURL
method of UIApplication
. It will perform the normal iPhone magical URL reinterpretation. so
[someUIApplication openURL:[NSURL URLWithString:@"http://maps.google.com/maps?q=London"]]
should invoke the Google maps app.
From iOS 6, you'll be invoking Apple's own Maps app. For this, configure an MKMapItem
object with the location you want to display, and then send it the openInMapsWithLaunchOptions
message. To start at the current location, try:
[[MKMapItem mapItemForCurrentLocation] openInMapsWithLaunchOptions:nil];
You'll need to be linked against MapKit for this (and it will prompt for location access, I believe).
Exactly. The code that you need to achieve this is something like that:
UIApplication *app = [UIApplication sharedApplication]; [app openURL:[NSURL URLWithString: @"http://maps.google.com/maps?q=London"]];
since as per the documentation, UIApplication is only available in the Application Delegate unless you call sharedApplication.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With