Open Mapping app like Waze, Google Maps, and Apple Maps (iOS only) From Salesforce1

675    Asked by nitin_7621 in Salesforce , Asked on Aug 5, 2021

I have requirement :

Add a "Directions" button on the restaurant mobile page,"Directions" button should pass the restaurant's location to the device's selected mapping app. Once this button is tapped, the user should be prompted to select their mapping app.

So Using VF page (Salesforce1) how can I open Mapping apps like Waze, Google Maps, and Apple Maps (iOS only) etc ?

For Skype we can use the "skype://call?415-555-1212" URL Scheme. Regarding Mapping applications, what URL scheme do I need to use?

Thanks,


Answered by Ben Butler

1.) Waze Map:

          var address = "{!Account.ShippingStreet}, " + "{!Account.ShippingCity}, " + "{!Account.ShippingPostalCode}, " + "{!Account.ShippingCountry}";
    var encodedAddress = encodeURIComponent(address); sforce.one.navigateToURL("waze://?q="+encodedAddress +"navigate=yes");

2.) Apple Maps (iOS only):

          sforce.one.navigateToURL("maps://maps.apple.com/?saddr=My+Location Daddr="+encoded long"& directions mode=driving");

3.) Google Maps :

if (mobileOperSys=="iOS")
sforce.one.navigateToURL("comgooglemaps://?saddr=My+Location Daddr="+encoded long"&directionsmode=driving");

else

sforce.one.navigateToURL("http://maps.google.com/?saddr=My+Location&daddr="+encodedlatlong+"&directionsmode=transit");

Your Answer

Interviews

Parent Categories