我在地图上有一个可拖动窗口(在我的情况下为https://github.com/mapshakers/leaflet-control-window),我想将其可拖动区域限制在地图框上,以防止其超出可见空间并且无法将其拖动回去。 >
var draggable = new L.Draggable(this._container,this._containerTitleBar); draggable.enable();
它是使用上面的代码创建的,但是无法传递jQuery中提供的包含元素
$('#elem').draggable({axis: 'y', containment : [0,containmentTop,0,containmentBottom] });
[我确定必须有一种使用L.Draggable而不是使用Jquery的draggable来限制拖动区域的方法。
我在地图上有一个可拖动窗口(在我的情况下为https://github.com/mapshakers/leaflet-control-window),该窗口的可拖动区域我想限制在地图框上以防止其向外移动。 ..
您可以覆盖showOn函数: