Launching the iPhone native Maps app with current location - iphone

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.

Related

How to launch Google Maps on iPhone via web link?

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&center=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.

Opening native map application from url in iPhone, Android, Blackberry

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

Android, Iphone app with JS and HTML

I have read some post about apps programming for Iphone and Android, but I have one question. Is it posible when there is a mobile website optimized for mobile phones, that I can create apps for Iphone, Android, Win 7 and Blackberry, that only statrts the browser as instance and display the mobile website? What do you think, is this ok? Do you have any ideas or examples for that kind of apps? I mean this is not an app, that should be has access to the hardware of the phone, only web app.
Thanks
Nik
This would work.
You could create an app that consists merely of a webview into which you load your content. The content could be loaded over the mobile network or be stored locally.
However most users (including yours truly) strongly dislike apps that merely present a single website to the user, because of the long delays if the content is loaded over the mobile network every time and because the UI is, in many cases, very different to what the he or she is used to from native apps.
Most users fail to see the need for a specialized app just to visit a website which they could as well keep as a favorite in their mobile browser. On the iPhone, you may even add favorite websites as icons on your homescreen, so there is no need for apps presenting a single website at all.
It's not only possible, such things are already done. One example I know of is cookd, a restaurant guide for Vienna. But there are some constraints; for example, cookd requires GPS data for the "Nearby" option; on my Android phone (HTC Legend), this is possible when I open the web page directly in the browser (the browser asks if I want to allow cookd.com to get this info); but the same webpage, running in an application that does nothing more than display the browser component, cannot do that. To fix that, they would have to build GPS reception into the app and forward this info to the browser component.
O'reilly has a fantastic article about this:
http://building-iphone-apps.labs.oreilly.com/
This is a little bit directed to iPhone only, but will give you a good overview about the topic and possibilities.

how to load iPhone application from web application

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.

Launching a native application from a link of website on iPhone

I have a query regarding launching a native application from a link of website on iPhone.
I will explain.
Generally a web based application is used to work online without using any feature of iPhone device (such as GPS, Camera, Accelerometer etc.)
I have a iPhone specific website which performs many tasks online.
Now while keeping all the functionality same, I want to add a feature of taking a picture from iPhone in-built camera.
i.e. when user clicks a button on website "Take Picture", my native application should be launched, which will take a picture and do specific tasks..
How to capture a event of button click which is performed on website?
Should I use UIWebView or Safari?
I know that using URL Scheme we can launch Safari from native application.
But how to achieve the opposite as explained above?
All other functionality works great on website, so I don't want to convert the whole website into native application.
(Otherwise I will have to deal with web services). Only this functionality needs to be added.
Register a URL Handler, then have a link on your site to myapphandle://some.parameters.here/
A la: http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html