猿问

amcharts,仅在缩小时禁用平移

仅在完全缩小时,如何才能在AmCharts地图中禁用平移(拖动)。

我尝试使用,chart.seriesContainer.draggable = false;但是它完全禁用了平移,但是我想在放大时能够拖动地图。


潇湘沐
浏览 167回答 1
1回答

万千封印

您可以通过属性调整地图互动行为,并通过事件监视地图何时更改,例如:MapChart.panBehaviorzoomLevel"zoomlevelchanged"chart.panBehavior = "none";chart.events.on("zoomlevelchanged", function(){&nbsp; // queue event loop so a final zoomlevelchanged can be "cauight"&nbsp; setTimeout(&nbsp; &nbsp; function() {&nbsp; &nbsp; &nbsp; if (chart.zoomLevel <= 1) {&nbsp; &nbsp; &nbsp; &nbsp; chart.panBehavior = "none";&nbsp; &nbsp; &nbsp; } else if (chart.zoomLevel > 1) {&nbsp; &nbsp; &nbsp; &nbsp; chart.panBehavior = "move";&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; }, 0);});这是一个演示:https://codepen.io/team/amcharts/pen/8d767bd62c8cb238ecb633e2123317ed
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答