只有在完全缩小时,我才能在 AmCharts 地图中禁用平移(拖动)。
我尝试使用chart.seriesContainer.draggable = false;
但它完全禁用了平移,但我希望能够在放大时拖动地图。
只有在完全缩小时,我才能在 AmCharts 地图中禁用平移(拖动)。
我尝试使用chart.seriesContainer.draggable = false;
但它完全禁用了平移,但我希望能够在放大时拖动地图。
您可以通过属性调整地图交互行为并通过事件监控何时更改,例如:MapChart.panBehavior
zoomLevel
"zoomlevelchanged"
chart.panBehavior = "none";
chart.events.on("zoomlevelchanged", function(){
// queue event loop so a final zoomlevelchanged can be "cauight"
setTimeout(
function() {
if (chart.zoomLevel <= 1) {
chart.panBehavior = "none";
} else if (chart.zoomLevel > 1) {
chart.panBehavior = "move";
}
}, 0);
});
这是一个演示:
https://codepen.io/team/amcharts/pen/8d767bd62c8cb238ecb633e2123317ed