Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
嗨,我想知道是否有办法限制您可以移动地图的数量,这样您就无法到达地图之外的灰色区域。例如,将地图的初始视图设置为您可以缩小的最远位置,并且该地图根本不会移动。但是,当您缩放时,您只能将地图移动到地图的边缘。谢谢。
maxBoundsViscosityof1使边界完全固定,防止用户拖出边界。
maxBoundsViscosity
1
<MapContainer maxBounds={[[-90, -360], [90, 360]]} maxBoundsViscosity={1} > </MapContainer