Permalink
Browse files

Added event on map zoom

  • Loading branch information...
1 parent 6c558ee commit 6204669833a9b96e50c9069a3336f8fe181999f0 @bjornd committed Sep 21, 2012
Showing with 10 additions and 1 deletion.
  1. +7 −1 lib/world-map.js
  2. +3 −0 tests/markers.html
View
@@ -68,6 +68,7 @@
* @param {Function} params.onMarkerOut <code>(Event e, String code)</code> Will be called on marker mouse out event.
* @param {Function} params.onMarkerClick <code>(Event e, String code)</code> Will be called on marker click event.
* @param {Function} params.onMarkerSelected <code>(Event e, String code, Boolean isSelected, Array selectedMarkers)</code> Will be called when marker is (de)selected. <code>isSelected</code> parameter of the callback indicates whether marker is selected or not. <code>selectedMarkers</code> contains codes of all currently selected markers.
+ * @param {Function} params.onZoom <code>(Event e, Number scale)</code> Triggered the map is zoomed.
*/
jvm.WorldMap = function(params) {
var map = this,
@@ -442,7 +443,8 @@ jvm.WorldMap.prototype = {
},
setScale: function(scale, anchorX, anchorY, isCentered) {
- var zoomStep;
+ var zoomStep,
+ viewportChangeEvent = jvm.$.Event('zoom.jvectormap');
if (scale > this.params.zoomMax * this.baseScale) {
scale = this.params.zoomMax * this.baseScale;
@@ -463,6 +465,9 @@ jvm.WorldMap.prototype = {
this.scale = scale;
this.applyTransform();
+
+ console.log(this.baseScale);
+ this.container.trigger(viewportChangeEvent, [scale/this.baseScale]);
},
/**
@@ -862,4 +867,5 @@ jvm.WorldMap.apiEvents = {
onMarkerOut: 'markerOut',
onMarkerClick: 'markerClick',
onMarkerSelected: 'markerSelected',
+ onZoom: 'zoom'
};
View
@@ -134,6 +134,9 @@
JSON.stringify(selectedRegions)
);
}
+ },
+ onZoom: function(e, scale){
+ console.log('viewportChange', scale);
}
});

0 comments on commit 6204669

Please sign in to comment.