open iPhone map app ?
Hi,
I am willing to add a "get directions" in my app, but as it is not possible from inside the app (correct me if I am wrong), I would like to open the iPhone map (or plan ?) app with lat and long in parameters ?
Is it possible at all ? Or I'll have to set a webview with Google Maps ?
Would be great if it would work for Android too !
Thanks !
3 Answers
-
Accepted Answer
Ti.Platform.openURL('http://maps.google.com/maps?daddr={address here}&ie=UTF8&t=h&z=16');
You just open the url and the iPhone will automatically open the native map application. In the stimulator, safari is opened.
-
The answer from Sj Singh is a bit outdated. I had the same problem while working on my map app and found a better solution.
For iOS you will need to use
Ti.Platform.openURL()
as mentioned in the previous answer but the URL scheme is different now that Apple offers their own native map solution.Ti.Platform.openURL("http://maps.apple.com/?saddr=[Start Address]&daddr=[Destination Address]")
I believe the starting address is optional. I would recommend this url scheme since Apple now has a native map app available on iOS devices (no longer can depend on Google map app).
For Android you will need to use an Intent like this:
var mapIntent = Ti.Android.createIntent({ action : Ti.Android.ACTION_VIEW, data : "http://maps.google.com/maps?saddr=[Start Address]&daddr=[Destination Address]" }); Ti.Android.currentActivity.startActivity(mapIntent);
Android supports the geo: url scheme but it is not fully implemented yet. I'm using these solutions for our map app template and they both work out fine.
Hope this helps anyone who comes across this question.
-
Thanks a lot. It really helped me