【问题标题】:What function/event is fired by the "Cancel" button in leaflet.draw?Leaflet.draw 中的“取消”按钮会触发什么功能/事件?
【发布时间】:2015-12-02 01:58:34
【问题描述】:

我根据How to click a button and start a new polygon without using the Leaflet.draw UIHow to initiate the draw function without toolbar? 设置了一个自定义按钮来启动绘图。但是,一旦有人单击此自定义按钮,我就无法弄清楚如何模仿 Cancel 按钮的行为,以便我可以拥有类似

<input type="button" onclick="stopEdits()" value="Click to Stop Drawing">

function stopEdits() {
    //Cancel Drawing
}

【问题讨论】:

    标签: javascript leaflet leaflet.draw


    【解决方案1】:

    所以这通过以下代码解决,drawer.disable() 取消标记放置。

    var drawer = new L.Draw.Marker(map, drawControl.options.marker);
    
    function startDrawing() {
    
        drawer.enable();
    }
    
    function stopDrawing() {
        drawer.disable()
    }
    

    我遇到的问题是我以前在同一行中做的太多:

    var drawer = new L.Draw.Marker(map, drawControl.options.marker).enable();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-12
      • 2013-04-17
      • 1970-01-01
      • 2012-06-01
      • 2017-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多