I use global map DataMaps.js. I want to implement Mouse Zoom, when mouse wheel moves. There is a example of static zoom:
var zoom = new Datamap({
element: document.getElementById("zoom_map"),
scope: 'world',
// Zoom in on Africa
setProjection: function(element) {
var projection = d3.geo.equirectangular()
.center([23, -3])
.rotate([4.4, 0])
.scale(400)
.translate([element.offsetWidth / 2, element.offsetHeight / 2]);
var path = d3.geo.path()
.projection(projection);
return {path: path, projection: projection};
}
});
Also, I have event Mouse Wheel:
$('#zoom_map').bind('DOMMouseScroll mousewheel', function(e){
if (e.originalEvent.wheelDelta > 0 || e.originalEvent.detail < 0) {
console.log("+");
e.preventDefault();
}
else{
console.log("-");
e.preventDefault();
}
});
I tried to concatenate these parts. Also, I tried to change datamaps.js. But, unfortunately, I get fail.