Is there a way to limit panning out of the world's edge? On this picture, brown is the world, grey is emptiness. I want to make it impossible to pan like this.
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
This is how I resolved it for the world map
See working example both for version .7.0.7 http://jsfiddle.net/exqar2w4/18/ and for version 1.0.3 http://jsfiddle.net/exqar2w4/20/
Leaflet allows you to control how much the map resists being dragged out of bounds with the
maxBoundsViscosity
option (value: 0 to 1). Setting it to maximum disables dragging out of bounds entirely.This feature is available in 1.0.0. The relevant pull request includes a working example: