1
我找到了代码在leaftlet地图上添加一个按钮到顶部的角落。但是现在我想要一个接一个地添加多个按钮。如何添加多个自定义控件按钮传单js?
是否可以在下面的代码中插入多个按钮?
我也尝试过使用复选框/单选按钮。但我不知道如何将标签添加到复选框和按钮。
- 并为它们添加选中/未选中的属性。
谢谢。
我的代码在这里:
var customControl = L.Control.extend({ options: {position: 'topleft'},onAdd: function (map) {
var container = L.DomUtil.create('div', 'leaflet-bar leaflet-control leaflet-control-custom');
onAdd: function (map) {
var container = L.DomUtil.create('input','my-button btn');
container.type="button";
container.title="x";
container.value = "x";
container.label = "x";
container.style.backgroundColor = 'white';
container.style.backgroundSize = "30px 30px";
container.style.width = '40px';
container.style.height = '40px';
container.style.borderRadius = "25px";
container.style.padding = "0";
container.style.margin = "10px";
container.onclick = function(){
console.log('buttonClicked');
}
return container;}});
是。一个很好的例子就是'Leaflet.draw'插件,它为工程图点,多边形,圆等添加了堆叠在一起的工具栏按钮。 – nothingisnecessary