【问题标题】:How can I set an offset on a centered react-leaflet map?如何在居中的反应传单地图上设置偏移量?
【发布时间】:2018-11-13 19:55:51
【问题描述】:

我正在将边界对象传递给地图组件上的边界道具 (https://react-leaflet.js.org/docs/en/v1/components.html#map)。

我希望它使用边界来居中并设置缩放(就像默认情况下一样),但带有偏移量(如工具提示)以允许从用户部分进行一些微调。

我的界限来自:

L.geoJson(currentZone.geoJson).getBounds();

【问题讨论】:

    标签: leaflet react-leaflet


    【解决方案1】:

    您可以通过boundsOptions 的配置对象以数组的形式设置paddingTopLeft, paddingBottomRight or padding

    传单文档: https://leafletjs.com/reference-1.3.0.html#fitbounds-options

    React 传单文档: https://react-leaflet.js.org/docs/en/components.html#map

     <Map
        ... attrs
        boundsOptions={{
          paddingBottomRight: [250, 0],
        }}
      >
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-30
      • 2022-08-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-29
      相关资源
      最近更新 更多