For Progressive Web Apps (PWA), invoking Google Maps using the maps URL on Android by default, launches the native version of Google Maps, if it is installed on the device. See Maps URL guidelines.
In some situations, we would like to use the browser-based Google Maps, regardless if the native app is installed on a device or not.
In my Ionic 4 / Angular 8 / Capacitor based application, I had a situation where loading Google Driving Directions in the native app would not properly set the source and destination addresses. I also prefer to use the browser-based map as it requires less resources. By changing the URL parameters it is possible to force launch the browser app all the time, by simply replacing the URL below,
https://maps.google.com/maps/dir/?api=1&destination= + destination
with —
https://maps.google.com?saddr=Current+Location&daddr= + destination
I was able to achieve the desired effect.
For a more detailed code implementation. See below:
async showDrivingDirections(place: any) { const destination = encodeURI(place.name); if (this.platform.is('android')) { if (this.platform.is('mobileweb')) { await Browser.open({url: 'https://maps.google.com?saddr=Current+Location&daddr=' + destination}); } else { await Browser.open({url: 'https://maps.google.com/maps/dir/?api=1&destination=' + destination}); } } else { window.open('https://maps.google.com/maps/dir/?api=1&destination=' + destination, '_self'); } }
This implementation supports invocation of Google Maps from iOS and Android app with provision to distinguish Progressive Web App (PWA) to achieve uniform behavior for all versions of the apps.
As a developer of an Android app, an iOS app, or a website, you can construct a common URL, and it will open Google Maps and perform the requested action, no matter the platform in use when the map is opened.
I have fun with, lead to I discovered exactly what I was taking a look for. Lanita Matty Jonna
I am so grateful for your post. Thanks Again. Really Great. Vilma Niki O’Toole
I truly appreciate this blog. Really looking forward to read more. Really Cool. Terrye Amory Dorsey
If you want to take a good deal from this article then you have to apply such techniques to your won weblog. Umeko Aldous Ho
If some one wants to be updated with most up-to-date technologies afterward he must be go to see this web page and be up to date daily. Elayne Ryon Buchheim