Android Phonegap - How to Open Native Google Maps Application

£可爱£侵袭症+ 提交于 2019-11-27 12:11:21

Use the geo: type uri.

<a href="geo:38.897096,-77.036545">open map</a>

and the user will get the choice of opening any of the mapping applications installed on their device.

Carlos Galeano

This work for me...

var addressLongLat = yourLatitude+','+yourLongitude

For Android Maps App:

window.open("geo:"+addressLongLat);

For iOs Maps App:

window.open("http://maps.apple.com/?q="+addressLongLat, '_system');

For Google Maps in App Browser:

window.open("http://maps.google.com/?q="+addressLongLat, '_system');

For all version of phonegap/cordova or web browser. It will Google map native app.

For Navigation from current location to q - window.open("google.navigation:q=23.3728831,85.3372199&mode=d" , '_system');

For Search - window.open("geo:0,0?q=pizza" , '_system');

Read Here - https://developers.google.com/maps/documentation/android/intents

Launch Navigator Cordova/Phonegap Plugin can be used to navigate to a destination using the native navigation app on:-

  1. Android: Google Navigator
  2. iOS: Apple Maps/Google Maps
  3. Windows Phone: Bing Maps

This is what I use:

function (lat, lon) {
    var latLon = lat + ',' + lon;

    if (device.platform.toUpperCase() === "ANDROID") {
        window.open("geo:" + latLon, "_system");
    } else if (device.platform.toUpperCase() === "IOS") {
        window.open("http://maps.apple.com/?sll=" + latLon + "&z=100&t=k", "_system");
    }
}

Note: when opening Apple maps, the sll=... and t=k, which means I'm specifying an exact longitude and latitude, and t=k means I want apple maps to display satellite imagery. Also, I'm only writing for iOS and Android, so if you're using other platforms be sure to check explicitly for each! I'm pretty sure Android's geo: always works as you would expect, but I could be wrong. Remember: test everything on a real device!

Mark Kamyszek

This works in cordova 3.4

window.open("http://maps.google.com/?q=" + address, "_system");

With this method Google Maps shows a marker and can use text address, not only lat-long coordinates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!