Snap to zoom and drag on jVectorMap

Does jVectorMap have built-in methods for binding map scaling and dragging the map with the mouse? I did not find them in the documentation.

I want to do something like this.

var map = $('#world-map').vectorMap(); map.on('zoom', function(){ .. }) 

Of course, I can bind to the element where the jvectormap was initialized, for example

 $('#world-map').on('mousewheel', functon(){ .. }) 

But it will look like a "quick fix."

+4
source share
2 answers

if you are using version 1.1.1, you need to add the onViewportChange event in the api events and in the applyTransform method.

Please check http://pastebin.com/s5GwcEMy

+3
source

OK, I decided that without a built-in solution

To scale

 $('#world-map svg').on('mousewheel', functon(){ console.log('cool, you are zooming') }) 

To drag and drop

 var isPressed = false; $('#world-map svg').mousedown(function(){ isPressed = true; }).mouseup(function(){ isPressed = false; }).mousemove(function(){ if(isPressed){ console.log('fine, you are dragging') } }) 
+3
source

All Articles