Prevent recursion on map.setMaxBounds
This commit is contained in:
parent
6abcdb9751
commit
286f192ca9
@ -33,6 +33,8 @@
|
|||||||
var latlngs = L.rectangle(bounds).getLatLngs();
|
var latlngs = L.rectangle(bounds).getLatLngs();
|
||||||
L.polyline(latlngs.concat([latlngs[0]])).addTo(map);
|
L.polyline(latlngs.concat([latlngs[0]])).addTo(map);
|
||||||
|
|
||||||
|
map.setMaxBounds(bounds); // Should not enter infinite recursion
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -138,12 +138,14 @@ L.Map = L.Evented.extend({
|
|||||||
setMaxBounds: function (bounds) {
|
setMaxBounds: function (bounds) {
|
||||||
bounds = L.latLngBounds(bounds);
|
bounds = L.latLngBounds(bounds);
|
||||||
|
|
||||||
this.options.maxBounds = bounds;
|
|
||||||
|
|
||||||
if (!bounds) {
|
if (!bounds) {
|
||||||
return this.off('moveend', this._panInsideMaxBounds);
|
return this.off('moveend', this._panInsideMaxBounds);
|
||||||
|
} else if (this.options.maxBounds) {
|
||||||
|
this.off('moveend', this._panInsideMaxBounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.options.maxBounds = bounds;
|
||||||
|
|
||||||
if (this._loaded) {
|
if (this._loaded) {
|
||||||
this._panInsideMaxBounds();
|
this._panInsideMaxBounds();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user