gpt4 book ai didi

javascript - 用于自定义居中的 Mapbox 和传单

转载 作者:行者123 更新时间:2023-12-03 08:15:46 25 4
gpt4 key购买 nike

如果这个问题是针对傻瓜的,我很抱歉。

我在 Web 开发中使用 Mapbox,并且我的 map 旁边有“侧”面板。

问题是,我想将 map 集中在我通过双击捕获的位置上。

我知道 map.setView([lat,lng],number)map.panTo([lat,lng]) 具有居中魔法,但它们在 map 的实际大小或 div 宽度上执行此操作。

我想知道是否有人知道我是否可以进行自定义居中,例如使用相同的 map 尺寸,但中心“计算”发生在 map 的左半部分或右半部分。

我不知道如何捕捉这个“分辨率”,我所知道的是我需要 map 使用的宽度的一半。这是我想做的事情的图像 enter image description here

最佳答案

(可能与 GIS StackExchange 上的问题重复:Change the center point of leaflet)

您可能会对这些插件之一感兴趣:

  • Leaflet-active-area

    This plugin allows you to use a smaller portion of the map as an active area. All positioning methods (setView, fitBounds, setZoom) will be applied on this portion instead of the all map.

  • Leaflet.ControlledBounds

    Inspired by Leaflet-active-area, automatically detects the largest area of the map not covered by any map controls and applies setView, fitBounds, setZoom, getBounds to that area.

关于javascript - 用于自定义居中的 Mapbox 和传单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33944128/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com