So I am trying to disable the zoom option in my Map when a user clicks on a map region, using the event handlers it works well for the attributtes like color and so, but not working to disable the zoom.
/* ... */
, defaultArea: {
attrs : {
fill : "#28282b"
//, stroke: "#474c4b"
}
, attrsHover : {
fill: "#3da879"
}
, text : {
attrs : {
fill : "#6d6d6d"
}
, attrsHover : {
fill : "#fff"
}
}
,eventHandlers: {
click: function (e, id, mapElem, textElem,elemOptions) {
var newData = {
'areas': {}
,'zoom': {}
};
if (mapElem.originalAttrs.fill == "#28282b") {
newData.areas[id] = {
attrs: {
fill: "#3da879"
}
, text : {
attrs : {
fill : "#fff"
}
, attrsHover : {
fill : "#fff"
}
}
};
newData.zoom[id] = {
enabled : false,
maxLevel : 10
};
} else {
newData.areas[id] = {
attrs: {
fill: "#28282b"
}
, text : {
attrs : {
fill : "#6d6d6d"
}
, attrsHover : {
fill : "#fff"
}
}
};
}
$(".mapcontainer").trigger('update', [newData]);
}
}
/* ... */
答案 0 :(得分:1)
你检查过这个JSFiddle示例:http://jsfiddle.net/neveldo/ejf9dsL9/?它显示了如何通过触发“缩放”来缩放特定区域。用户点击按钮时的事件:
$maparea2.trigger('zoom', {level : 10, latitude : 45.758888888889, longitude : 4.8413888888889});
如果您想在之后禁用缩放功能,则可以取消绑定鼠标滚轮'地图容器上的事件。
我希望它会对你有所帮助。