Skip to content

Instantly share code, notes, and snippets.

@Dzoge
Forked from danharper/demo.md
Created July 1, 2021 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dzoge/e023c7b28c33d907eac970d369358d3d to your computer and use it in GitHub Desktop.
Save Dzoge/e023c7b28c33d907eac970d369358d3d to your computer and use it in GitHub Desktop.
Open native Maps apps on iOS and Android in Cordova
iOS (with pin, iOS will lookup address too and show that as label)
maps://?q=LAT,LNG
Android, no pin (just open at location)
geo:LAT,LNG
Android, with pin
geo:0,0?q=LAT,LNG
Android, with pin, with custom label
geo:0,0?q=LAT,LNG(LABEL)
var geocoords = lat + ',' + lng;
if (iOS) {
window.open('maps://?q=' + geocoords, '_system');
}
else {
var label = encodeURI('7 East Street'); // encode the label!
window.open('geo:0,0?q=' + geocoords + '(' + label + ')', '_system');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment