Skip to content

v2 beta

Masashi Katsumata edited this page Oct 4, 2016 · 20 revisions

Cordova GoogleMaps plugin for iOS and Android v2 (beta)

What is version 2?

The Cordova GoogleMaps plugin version 2 finally supports multiple maps in the same html file. You can create your maps in the same html file for multiple locations.

All most all code is recreated, and the most code run in the background thread. So it should be faster than version 1.

The greatest thing is the plugin recognizes all html element of the HTML. You don't need to turn on/off map.setClickable(true/false) when you display your HTML on the map div (such as HTML dialogs).

Why beta?

Masashi (who is the author of this plugin) wrote the plugin and tested it on his several devices. But he feel it is not enough to test the plugin. So during the tests with early developers, the plugin version 2 is still beta.

How to install?

Please use the multiple_maps branch.

$> cordova plugin add https://github.com/mapsplugin/cordova-plugin-googlemaps #multiple_maps --variable API_KEY_FOR_ANDROID="<YOUR KEY>" --variable API_KEY_FOR_IOS="<YOUR KEY>"

Migrate code from v1

Several methods are renamed in v2. Please rewrite your code.

method names
v1 v2
map.setCenter() map.setCameraTarget()
map.setZoom() map.setCameraZoom()
map.setBearing() map.setCameraBearing()
map.setTilt() map.setCameraTilt()
map.getCenter() map.getCameraTarget()
map.getZoom() map.getCameraZoom()
map.getBearing() map.getCaneraBearing()
map.getTilt() map.getCaneraTilt()
map.setBackgroundColor() Environent.setBackgroundColor()
#### Version 1.x events
event name Androide iOS
event name Android iOS
- - -|-
MAP_CLICK YES YES
MAP_LONG_CLICK YES YES
MY_LOCATION_CHANGE YES NO
MY_LOCATION_BUTTON_CLICK YES YES
INDOOR_BUILDING_FOCUSED YES YES
INDOOR_LEVEL_ACTIVATED YES YES
CAMERA_CHANGE YES YES
CAMERA_IDLE NO YES
MAP_READY YES YES
MAP_LOADED YES NO
MAP_WILL_MOVE NO YES
MAP_CLOSE YES YES
OVERLAY_CLICK YES YES
INFO_CLICK YES YES
MARKER_DRAG YES YES
MARKER_DRAG_START YES YES
MARKER_DRAG_END YES YES

Version 2.x events

event name Androide iOS arguments[0]
MAP_READY YES YES none
MAP_CLICK YES YES LatLng
MAP_LONG_CLICK YES YES LatLng
MY_LOCATION_BUTTON_CLICK YES YES none
INDOOR_BUILDING_FOCUSED YES YES none
INDOOR_LEVEL_ACTIVATED YES YES building information
CAMERA_MOVE_START YES YES true if the camera move start by gesture
CAMERA_MOVE YES YES CameraPosition
CAMERA_MOVE_END YES YES CameraPosition
POLYGON_CLICK YES YES LatLng(clicked position)
POLYLINE_CLICK YES YES LatLng(clicked position)
CIRCLE_CLICK YES YES LatLng(clicked position)
GROUND_OVERLAY_CLICK YES YES LatLng(clicked position)
INFO_CLICK YES YES LatLng(marker position)
INFO_LONG_CLICK YES YES LatLng(marker position)
INFO_CLOSE YES YES LatLng(marker position)
INFO_OPEN YES YES LatLng(marker position)
MARKER_CLICK YES YES LatLng(marker position)
MARKER_DRAG YES YES LatLng(marker position)
MARKER_DRAG_START YES YES LatLng(marker position)
MARKER_DRAG_END YES YES LatLng(marker position)

removed the xxxClicked properties

The plugin version 2 does not support the xxxClicked properties anymore. Please use addEventListener() or on() methods instead.

// version 1
map.addMarker({
  position: ...
  markerClick: function(marker) {
    marker.showInfoWindow();
  }
});


// version 2
map.addMarker({
  position: ...
}, function(marker) {

  map.addMarker(plugin.google.maps.event.MARKER_CLICK, function() {
    map.showInfoWindow();
  });

});

Getter synchronizing

The plugin version 2 synchronizes the class properties automatically. It means you don't need to use callback anymore.

For example,

// version 1
marker.getPosition(function(position) {
  // to do something
});

// version 2
var position = marker.getPosition();

Join the official community

New versions will be announced through the official community. Stay tune!

Do you have a question or feature request?

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

Clone this wiki locally