I am building a site that will have address links as well as image of a map - both of which have a link to Google Maps.
The problem is that when I click on these links using my iPhone - or any address link that shows up in an email, the result is that either the native Apple Maps app opens or the Google Maps in the browser. I want for the native Google Maps app to open every time, and ideally for every user (whose iPhone I have no control of).
If I use the Chrome app for iPhone, then there's a little trick to do this:
http://www.redmondpie.com/how-to-set-google-maps-for-iphone-default-app-for-opening-map-links/
But the reality is that the trick above will not open the Google Maps app. It will open the web version of Google Maps inside the Chrome app. Then an icon shows up at the bottom asking if you want to open the native app instead. This is better than nothing, but far from ideal. I appreciate any help. Thank you. BTW, I'd like to do this without jailbreaking the iPhone - I'm looking for a solution that will work with other people's iPhones.
You can use apple's interface which is a bit more intelligent when using different browsers and devices:
http://maps.apple.com/?q=51.507269,-0.127695
Clicking the above url on the following devices:
iPhone|iPad:
Opens Apple maps app
Android:
Gives you a choice to open in either Google Maps App or Google maps website
Windows Phone:
Opens Google maps mobile website
Windows 8 Desktop:
Opens Google maps website
Apple OS Desktop:
Opens the new maps app (Mavericks)!!
For more info see:
Apple URL Scheme Reference
To open Google native app you need to write:
[[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:#"comgooglemaps://"]];
Example :
comgooglemaps://?q=Pizza¢er=37.759748,-122.427135
I just tested this and it worked in pulling up Google Maps instead of the default Apple Maps application.
Testing Maps
However, after deleting the Google Maps app for iOS, the link fails to open anything because that schema is no longer available and doesn't fallback to a generic maps link... almost seems like you would need to provide two links for Google Maps for iPhone and another generic Apple Map link...
Take a look at this.
It works on every device (for ios / android, it will launch google maps app else browser).
For other devices, it will launch browser.
Simple use case would be:
Construct universal map URI (with encoded params)
Use this URL like -
window.open(mapUrl, '_system');
More info for window.open here
My use case required to open existing in app map navigation into some another dedicated maps app (preferably google maps app) for ios and android devices.
I use ionic v1 + cordova for building native apps. Not sure if this is perfect for your use case but hope this helps.
Related
I used to just be able to have a link to a coordinate on Google Maps, like https://maps.google.com/maps?q=35.7491455078125,139.382995605469
but now that Apple kicked out the original Maps app, and Google has re-launched another one, links like that no longer drop a pin on the maps of iOS users.
Is there a way to drop a pin on a visitor's Google Maps app with the click of a link?
Sounds like the official Maps URLs would work for you. In your example, this should work (and across platforms, too!):
https://www.google.com/maps/search/?api=1&query=35.7491455078125,139.382995605469
You can read the full documentation at https://developers.google.com/maps/documentation/urls/guide
Replace http://maps.google.com with http://maps.apple.com, hopefully that works!
I am having a problem in safari, that it stopped opening native map application in iPhone device from url like http://maps.google.com/maps?saddr=&daddr=, it is always opening google map inside the browser, in new iOS safari browser, where as the same url works fine in older devices.
Any help would be very appreciated..
Thanks.
Contrary to what you find on the internet, you should not use "http://" but should use "maps://". So "http://maps.google.com/?q=paris" will open the Google Maps website but "maps://maps.google.com/?q=paris" will open the native Maps application.
I've seen a lot of code samples here on how to launch the Maps app but none of them actually launch the native app, they all launch Google's website on Safari instead (http://maps.google.com...). I've seen an app before, can't recall the name, that launched the iPhone maps application itself and on the address bar of the apps it has a string that looked like "hotel loc:XX.XXXX, XX.XXXX" which would select the current location on the map based on the coordinates provided on the address and pin point all hotels in the nearby area (visible area). I'm positive that it launched the native app because all the app settings were there and of course the app was among the running apps on the phone and safari wasn't open. I looked at the MapKit but wasn't able to pass that address to it from code ("hotel loc:longitude, latitude").
Does any of you guys happen to know how to launch the actual native app and pass an address to it?
https://developer.apple.com/library/archive/featuredarticles/iPhoneURLScheme_Reference/MapLinks/MapLinks.html
URLs launched from within an app that fulfil the criteria in the developer document will open up in the Maps application. This is a key difference, because in most applications you use a custom URL scheme, whereas for the maps you simply fire up a URL for maps.google.com
However, if you a) don't follow the specs in that document to the letter, or b) are running in the simulator, you'll go to the Google Maps web page in Safari.
I was trying to open the native map application to show direction from Current Location to the given location. Understandably, the url should work on all the smart phones, not just iPhone.
The most common url that can be used for all the phones can be maps.google.com.
For iPhone I have used http://maps.google.com/maps?saddr=Current%20Location&daddr=lat,lon. It works perfectly fine, iPhone opens the map with my Current Location and the destination location and draws direction. But it doesn't work on other devices.
Any suggestion ?
Thanks.
I've written a blog post addressing this topic and how open native map apps, not just the google site. Check it out here : http://habaneroconsulting.com/insights/Opening-native-map-apps-from-the-mobile-browser.aspx
I have web application for mobile (developed in .net), I want to use iPhone maps application from web application( i.e. from web browser on button click)..how to do it? I want to do same in android to.
I don't know about Android, but this page describes how to construct a URL that will open the iPhone's Maps application.
If you are trying to view a map from a web application (viewed in the mobile browser), simply link to Google maps as you normally would. Some mobile OS's will open their native maps application, and the others will receive Google's mobile-optimized maps website.
Edit:
As Robot K said, the http://maps.google.com URIs will be intercepted on iOS and open the native map application. If you want to force the same behavior on Android, you will have to do user agent detection and use the geo uri scheme documented here.
The user agent detection is to determine whether the link you attempt to load is the http scheme for iOS or the geo scheme for android.