Skip to content

Instantly share code, notes, and snippets.

@shafiqshams
Forked from schmidt1024/location.ts
Created November 22, 2017 15:06
Show Gist options
  • Save shafiqshams/d8ff40575b7398415433637f0d8a9e01 to your computer and use it in GitHub Desktop.
Save shafiqshams/d8ff40575b7398415433637f0d8a9e01 to your computer and use it in GitHub Desktop.
start external map navigation from ionic 2 app for ios and android; needs cordova-plugin-geolocation
startExternalMap() {
if (this.location.latitude) {
this.platform.ready().then(() => {
Geolocation.getCurrentPosition().then((position) => {
// ios
if (this.platform.is('ios')) {
window.open('maps://?q=' + this.location.name + '&saddr=' + position.coords.latitude + ',' + position.coords.longitude + '&daddr=' + this.location.latitude + ',' + this.location.longitude, '_system');
};
// android
if (this.platform.is('android')) {
window.open('geo://' + position.coords.latitude + ',' + position.coords.longitude + '?q=' + this.location.latitude + ',' + this.location.longitude + '(' + this.location.name + ')', '_system');
};
});
});
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment