Skip to content
TempD edited this page Nov 22, 2014 · 6 revisions

JavaScript within the browser is event driven, meaning that JavaScript responds to interactions by generating events, and expects a program to listen to interesting events. The phonegap-googlemaps-plugin fires several events when the status of the map is changed. You can catch these events with addEventListener.

There are several events.

  • MAP_READY
  • MAP_CLICK
  • MAP_LONG_CLICK
  • MY_LOCATION_CHANGE(Android)
  • MY_LOCATION_BUTTON_CLICK
  • CAMERA_CHANGE
  • MAP_LOADED(Android)
  • MAP_WILL_MOVE(iOS)

###MAP_READY event Phonegap-googlemaps-plugin fires once MAP_READY event when the map has fully initialized. After the event, you can safely make calls to the Phonegap-googlemaps-plugin function.

var map = plugin.google.maps.Map.getMap();
map.addEventListener(plugin.google.maps.event.MAP_READY, function(map) {
  //The map is initialized.
});

###MAP_CLICK event MAP_CLICK event is fired when you tap on a map. The location of the tap position is passed as the argument.

map.on(plugin.google.maps.event.MAP_CLICK, function(latLng) {
  alert("Map is clicked.\n" + latLng.toUrlValue());
});

###MAP_LONG_CLICK event MAP_LONG_CLICK event is fired when you press and hold a while longer on a map. The location of the position is passed as the argument.

map.on(plugin.google.maps.event.MAP_LONG_CLICK, function(latLng) {
  alert("Map is long clicked.\n" + latLng.toUrlValue());
});

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