amcharts,仅在缩小时禁用平移

时间:2019-04-08 04:29:06

标签: javascript amcharts amcharts4 ammap

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

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

1 个答案:

答案 0 :(得分:2)

您可以通过adjust map interaction behavior MapChart.panBehavior property并通过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