-
Notifications
You must be signed in to change notification settings - Fork 916
Why use this plugin?
cordova-plugin-googlemaps has some nice features. Let's introduce them briefly.
cordova-plugin-googlemaps provides JavaScript API, which is kind of similar with Google Maps JavaScript API v3. For instance, display a map with a location:
Google Maps JavaScript API v3
var map = new google.maps.Map(mapDiv);
var GOOGLE = new google.maps.LatLng(37.422858, -122.085065);
map.setCenter(GOOGLE);
cordova-plugin-googlemaps
var GOOGLE = new plugin.google.maps.LatLng(37.422858, -122.085065);
var map = plugin.google.maps.Map.getMap(mapDiv);
map.addEventListener(plugin.google.maps.event.MAP_READY, function() {
map.setCenter(GOOGLE);
});
If you want to display a location with specified zoom level, you just need to pass these parameters to the animateCamera()
method.
map.animateCamera({
target: new plugin.google.maps.LatLng(37.422858, -122.085065),
zoom: 15
}, function() {
console.log("The animation is done.");
});
If you want to display the map with fitting a bound, pass an Array of LatLng, or an instance of LatLngBounds.
var GORYOKAKU_POINTS = [
new plugin.google.maps.LatLng(41.79883, 140.75675),
new plugin.google.maps.LatLng(41.799240000000005, 140.75875000000002),
new plugin.google.maps.LatLng(41.797650000000004, 140.75905),
new plugin.google.maps.LatLng(41.79637, 140.76018000000002),
new plugin.google.maps.LatLng(41.79567, 140.75845),
new plugin.google.maps.LatLng(41.794470000000004, 140.75714000000002),
new plugin.google.maps.LatLng(41.795010000000005, 140.75611),
new plugin.google.maps.LatLng(41.79477000000001, 140.75484),
new plugin.google.maps.LatLng(41.79576, 140.75475),
new plugin.google.maps.LatLng(41.796150000000004, 140.75364000000002),
new plugin.google.maps.LatLng(41.79744, 140.75454000000002),
new plugin.google.maps.LatLng(41.79909000000001, 140.75465),
new plugin.google.maps.LatLng(41.79883, 140.75673)
];
map.animateCamera({
'target': GORYOKAKU_POINTS
});
cordova-plugin-googlemaps has some original features, that Google Maps Android API v2 and Google Maps SDK for iOS do not provide them.
Display multiple lines in InfoWindow
Base64 encoded and title for Marker
cordova-plugin-googlemaps takes care of all of things of Google Maps Mobile SDKs (as much as possible).
And the most features of JavaScript API behaves the same working on both Android and iOS.
If you get an error, feel free to ask me on the official community or the issue list.
New version 2.0-beta2 is available.
The cordova-googlemaps-plugin v2.0 has more faster, more features.
https://github.com/mapsplugin/cordova-plugin-googlemaps-doc/tree/master/v2.0.0/README.md
New versions will be announced through the official community. Stay tune!
Feel free to ask me on the issues tracker.
Or on the official community is also welcome!
New version 2.0-beta2 is available.
The cordova-googlemaps-plugin v2.0 has more faster, more features.
https://github.com/mapsplugin/cordova-plugin-googlemaps-doc/tree/master/v2.0.0/README.md