How to open ios map

You must Login before you can answer or comment on any questions.

How to open ios map(native map application) with current location, I have tried this below one, but its is opening in safari

Ti.Platform.openURL('http://maps.google.com/maps');
I am using Titanium 1.7.5

Thanks in advance

4 Answers

Accepted Answer

This should do the trick:

in your app.js:

Ti.Geolocation.purpose = "Receive user location";
Ti.Geolocation.accuracy = Ti.Geolocation.ACCURACY_BEST;
Ti.Geolocation.preferredProvider = "gps";
Ti.Geolocation.distanceFilter = 10;
 
var userpos={};
 
Titanium.Geolocation.getCurrentPosition(function(e) {
    if(!e.success) {
        alert('Could not retrieve location');
 
    }else{
        userpos.longitude = e.coords.longitude;
        userpos.latitude = e.coords.latitude;
    }
});
and then anywhere you want to call the maps apps:
button.addEventListener('click',function(){
    Ti.Platform.openURL('http://maps.google.com/maps?ll='+userpos.latitude+','+userpos.longitude);
});
you may have to add some controls to check if you really have the user location (maybe the user didn't accept to be located... )

yes you can do that with

Ti.Platform.openURL('Maps://');

— answered 1 year ago by Mitul Bhalia
answer permalink
10 Comments
  • you can luanch third-party apps by using this

    see this

    — commented 1 year ago by Mitul Bhalia

  • one more thing test it in your device not simulator

    — commented 1 year ago by Mitul Bhalia

  • thanks, its works fine, is there any way to show the users location particularly

    — commented 1 year ago by Karthi Ponnusamy

  • Show 7 more comments

hi Karthi,

i think you talk about this

Try using parameters, this should open the Maps App (on a device, does not work on simulator):

Ti.Platform.openURL('http://maps.google.com/maps?daddr=San+Francisco,+CA&saddr=cupertino');

Your Answer

Think you can help? Login to answer this question!