如何在AMCHART5的地图图表上禁用Zoom和Pan5

发布于 2025-01-26 11:21:18 字数 690 浏览 4 评论 0 原文

我之前曾使用过Amchart4地图,并且刚刚切换到Amchart5地图。我知道有一个关于在Amchart4的地图图表上禁用Zoom和Pan,但我找不到有关Amchart5的任何内容。

因此,我尝试将相同的概念应用于Amchart5,并且仅适用于 Zoom 。我可以使用此代码禁用Amchart5中的地图Zoom:

var map = root.container.children.push(am5map.MapChart.new(root, {
        panX: "none",
        projection: am5map.geoMercator(),
        maxZoomLevel: 1,
        draggable: false,
        resizeable: false
    })
);

如上所述,我还添加了 draggable:false and 可重复:false ,但没有工作。

是否有任何解决方案可以禁用可拖动和可重新固定的地图?感谢您的帮助。

I used the amChart4 Map before and have just switched to amChart5 Map. I know there is a document about disabling zoom and pan on map chart of amChart4, but I can't find any about amChart5.

So I've tried to apply the same concept to amChart5 and it worked only with Zoom. I could disable the map zoom in amChart5 with this code:

var map = root.container.children.push(am5map.MapChart.new(root, {
        panX: "none",
        projection: am5map.geoMercator(),
        maxZoomLevel: 1,
        draggable: false,
        resizeable: false
    })
);

As code shown above, I also added the draggable: false and resizeable: false into it, but it didn't work.

Is there any solution to disable the draggable and resizeable map? I appreciate your kind help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

长亭外,古道边 2025-02-02 11:21:18

这是我自己的问题,但是在我对上述代码进行了一些测试并找到了正确的解决方案之后,我想在答案中分享它。

问题的解决方案是通过添加

var map = root.container.children.push(am5map.MapChart.new(root, {
        panX: "none",
        panY: "none",
        projection: am5map.geoMercator(),
        maxZoomLevel: 1
    })
);

panx:无是禁用水平拖动和 pany:无是禁用verticle拖动。 draggable:false 可重复:false 不再在amchart5中应用。

It is my own question, but after I did some testing on the mentioned code above and found the right solution, so I would like to share it here in the answer.

The solution to the question is just by adding

var map = root.container.children.push(am5map.MapChart.new(root, {
        panX: "none",
        panY: "none",
        projection: am5map.geoMercator(),
        maxZoomLevel: 1
    })
);

So the panX: none is to disable the horizontal drag and panY: none is to disable the verticle drag. And the draggable: false and resizeable: false are no longer applied in amChart5 anymore.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文