Skip to content

Commit

Permalink
Generate event when map viewport is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
bjornd committed Jan 1, 2013
1 parent abbbdeb commit 7372054
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/world-map.js
Expand Up @@ -70,7 +70,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.
* @param {Function} params.onViewportChange <code>(Event e, Number scale)</code> Triggered when the map's viewport is changed (map was panned or zoomed).
*/
jvm.WorldMap = function(params) {
var map = this,
Expand Down Expand Up @@ -251,6 +251,8 @@ jvm.WorldMap.prototype = {
if (this.markers) {
this.repositionMarkers();
}

this.container.trigger('viewportChange', [this.scale/this.baseScale, this.transX, this.transY]);
},

bindContainerEvents: function(){
Expand Down Expand Up @@ -971,5 +973,5 @@ jvm.WorldMap.apiEvents = {
onMarkerOut: 'markerOut',
onMarkerClick: 'markerClick',
onMarkerSelected: 'markerSelected',
onZoom: 'zoom'
onViewportChange: 'viewportChange'
};
4 changes: 2 additions & 2 deletions tests/markers.html
Expand Up @@ -142,8 +142,8 @@
);
}
},
onZoom: function(e, scale){
console.log('viewportChange', scale);
onViewportChange: function(e, scale, transX, transY){
console.log('viewportChange', scale, transX, transY);
}
});

Expand Down

0 comments on commit 7372054

Please sign in to comment.