0

我正在使用颜色选择器选择对象的颜色以使用 Leaflet.Draw 绘制它,但找不到位置。

    $("#txtAPColor").on('change', function(){
        colorSelectPoi=$("#txtAPColor").value;
    });

   var circle_options = {
        stroke: true,
        color: colorSelectPoi,
        weight: 4,
        opacity: 0.5,
        fill: true,
        fillColor: null, //same as color by default
        fillOpacity: 0.2,
        clickable: true
      };
     new L.Draw.Circle(map, circle_options).enable();            
4

1 回答 1

2

我已经用以下代码解决了这个问题:

var optionColorSelected = '#000'
map.on(L.Draw.Event.CREATED, function (event) {
    event.layer.options.color = optionColorSelected;
    var layer = event.layer;
    drawnItems.addLayer(layer);
});

您只需使用您选择的颜色更新变量optionColorSelected 。我希望我能帮助你。

于 2019-12-20T14:51:52.057 回答