Recommend: Launch Navigator Cordova/Phonegap Plugin
The plugin does not implement some features, such as navigation, but the external applications have one. In this case, you can launch the external application.
The launchNavigation method launches the Google Maps app.
If Google Maps app is not available in iOS, Apple Maps app is launched.
You can just pass from
and to
parameters.
As of version 1.2.3, you can also specify the travelMode
parameter.
travelMode
driving
transit
bicycling
walking
plugin.google.maps.external.launchNavigation({
"from": "Tokyo, Japan",
"to": "Kyoto, Japan"
});
var yourLocation = null;
map.getMyLocation(function(location) {
yourLocation = location.latLng;
map.addMarker({
"position": yourLocation,
"title": "I am around here!"
}, function(marker) {
marker.showInfoWindow();
});
map.moveCamera({
"target": yourLocation,
"zoom": 12
});
});
map.on(plugin.google.maps.event.MAP_CLICK, function(latLng) {
map.addMarker({
"position": latLng,
"title": "Destination"
}, function(marker) {
marker.showInfoWindow();
setTimeout(function() {
if (confirm("Do you want to go?")) {
plugin.google.maps.external.launchNavigation({
"from": yourLocation,
"to": latLng
});
}
}, 2000);
});
});
Method | Return value | Description |
---|---|---|
launchNavigation() | void | Launch the external navigation app. |