Skip to content

Instantly share code, notes, and snippets.

@mklarsen
Forked from danharper/demo.md
Created September 24, 2020 06:49
Show Gist options
  • Save mklarsen/a094efb7878abd072c6c7a1452d8fa92 to your computer and use it in GitHub Desktop.
Save mklarsen/a094efb7878abd072c6c7a1452d8fa92 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