2015-12-02 61 views
1

我设置了一个自定义按钮,按照How to click a button and start a new polygon without using the Leaflet.draw UIHow to initiate the draw function without toolbar?来启动绘图。但是,一旦有人点击这个自定义按钮,我无法弄清楚如何模仿Cancel按钮的行为,这样我可以有类似leaflet.draw中的“取消”按钮触发了什么功能/事件?

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

function stopEdits() { 
    //Cancel Drawing 
} 

回答

2

因此,这是由下面的代码解决,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();