'Cordova 10/11 iOS app not able to open google maps URI
After upgrading to cordova 11 from cordova 9, I am unable to open a google maps URI (On Button click Cordova app should open Google maps with the co-cordinates)
What worked in cordova 9:
var coord = lat + ',' + lon;
window.open(`comgooglemaps://${coord}?q=${coord}`, `_system`);
Ref: https://developers.google.com/maps/documentation/urls/ios-urlscheme
Now, this does nothing. No errors or logs.
Working config: Cordova 9, cordova-ios 5.1.1
Current config: Cordova 11, cordova-ios 6.2.0
Solution 1:[1]
My issue was with the installed InAppBrowser plugin.
I've previously done as they suggested:
window.open = cordova.InAppBrowser.open;
But this no longer seems to work. As soon as I changed the code to use InAppBrowser explicitly:
window.cordova.InAppBrowser.open(`comgooglemaps://${coord}?q=${coord}`, _system);
it started working again.
Solution 2:[2]
Try to use geo instead
var coord = lat + ',' + lon;
window.open('geo://'+coord, `_system`);
Or
window.open("http://maps.apple.com/?q="+coord, '_system');
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Leo |
| Solution 2 | Eric |
