Leaflet.Editable:点击地图控件时防止绘图
Leaflet.Editable: Prevent drawing when clicked on map control
我正在使用 Leaflet.Editable 绘制多边形,它会在加载地图后自动激活。当我单击主页按钮(通过 Leaflet.EasyButton 添加)或除默认缩放控件之外的任何其他添加的控件时,将绘制新顶点。那么如何防止点击leaflet控件时绘制呢?
map = new L.Map('mapa', {
maxBounds: extent,
minZoom: 12,
touchZoom: true,
tap: false,
editable:true,
attributionControl:true,
zoomControl: true
});
L.easyButton('fa-home',function(btn,map){
map.setView(initialCenter,initialZoom);
},'Domů').addTo(map);
var overviewMap = L.control({position: 'bottomleft'});
var divOverviewMap;
overviewMap.onAdd = function (map) {
divOverviewMap = L.DomUtil.create('div', 'prehledka');
return divOverviewMap;
};
overviewMap.addTo(map);
var prehledkaButton=L.control({position: 'bottomleft'});
prehledkaButton.onAdd = function (prehledkaMap) {
divOverviewMapButton = L.DomUtil.create('div', 'prehledkaButton');
divOverviewMapButton.innerHTML='<img src="toggle.png" class="toggleButton">';
$(divOverviewMapButton).attr('title','Skrýt přehledku...');
return divOverviewMapButton;
};
prehledkaButton.addTo(prehledkaMap);
newFeature_polygon=map.editTools.startPolygon();
我大概明白了。当我添加
时它起作用了
$('.leaflet-control-container').on("mousedown", L.DomEvent.stopPropagation);
我正在使用 Leaflet.Editable 绘制多边形,它会在加载地图后自动激活。当我单击主页按钮(通过 Leaflet.EasyButton 添加)或除默认缩放控件之外的任何其他添加的控件时,将绘制新顶点。那么如何防止点击leaflet控件时绘制呢?
map = new L.Map('mapa', {
maxBounds: extent,
minZoom: 12,
touchZoom: true,
tap: false,
editable:true,
attributionControl:true,
zoomControl: true
});
L.easyButton('fa-home',function(btn,map){
map.setView(initialCenter,initialZoom);
},'Domů').addTo(map);
var overviewMap = L.control({position: 'bottomleft'});
var divOverviewMap;
overviewMap.onAdd = function (map) {
divOverviewMap = L.DomUtil.create('div', 'prehledka');
return divOverviewMap;
};
overviewMap.addTo(map);
var prehledkaButton=L.control({position: 'bottomleft'});
prehledkaButton.onAdd = function (prehledkaMap) {
divOverviewMapButton = L.DomUtil.create('div', 'prehledkaButton');
divOverviewMapButton.innerHTML='<img src="toggle.png" class="toggleButton">';
$(divOverviewMapButton).attr('title','Skrýt přehledku...');
return divOverviewMapButton;
};
prehledkaButton.addTo(prehledkaMap);
newFeature_polygon=map.editTools.startPolygon();
我大概明白了。当我添加
时它起作用了$('.leaflet-control-container').on("mousedown", L.DomEvent.stopPropagation);