0

Hi I was wondering if there was a way to limit the amount you can move the map so that you can't get to a gray area off the map. For instance having the initial view of the map be the farthest you can zoom out and that map would not move at all. However, when you zoom you would be able to move the map only to the edges of the map. Thanks.

swade77
  • 23
  • 3
  • 1
    Does this answer your question? [Can I prevent panning Leaflet map out of the world's edge?](https://stackoverflow.com/questions/22155017/can-i-prevent-panning-leaflet-map-out-of-the-worlds-edge) – Seth Lutske May 20 '21 at 17:44

1 Answers1

0

maxBoundsViscosity of 1 makes the bounds fully solid, preventing the user from dragging outside the bounds.

      <MapContainer
        maxBounds={[[-90, -360], [90, 360]]}
        maxBoundsViscosity={1}
      >
      </MapContainer
teddybeard
  • 1,964
  • 1
  • 12
  • 14