Page 1 of 1

Open Google Maps app (rather than Google Maps webpage) directly

Posted: Mon Jan 13, 2025 9:39 am
by Bob.Tern
I want my app to have a link which can open Google Maps app (rather than Google Maps webpage) directly. How can I do it?

Re: Open Google Maps app (rather than Google Maps webpage) directly

Posted: Mon Jan 13, 2025 9:41 am
by aantsypau
You can use the following approach which open external application which is registered as default map app

const query = "53.723337, -69.995790";
if (this.$a.isIOS()) {
window.location.href = encodeURI(`maps://?q=${query}`);
} else if (this.$a.isAndroid()) {
window.open(encodeURI(`geo:0,0?q=${query}`), "_system");
}

Alternatively you can open particular application and pass parameters using Launch Navigator plugin

image.png

The following code check if Google Map app is installed and if yes then open it for particular address or coordinates

window.launchnavigator?.isAppAvailable(window.launchnavigator.APP.GOOGLE_MAPS, (isAvailable) => {
var app;
if (isAvailable) {
app = window.launchnavigator.APP.GOOGLE_MAPS;
} else {
console.warn("Google Maps not available - falling back to user selection");
app = window.launchnavigator.APP.USER_SELECT;
}
window.launchnavigator.navigate("London, UK", {
app: app
});
});

More information about this plugin you can read here https://github.com/dpa99c/phonegap-launch-navigator

Please pay attention that for building android app it is needed to pass plugin parameter GOOGLE_API_KEY_FOR_ANDROID