手动添加L.Control.Draw到传单

  • 本文关键字:Draw Control 添加 leaflet
  • 更新时间 :
  • 英文 :


我想添加一个绘制控件到我的传单地图,像这样:

const drawnItems = L.featureGroup().addTo(map)
map.addControl(new L.Control.Draw({
  edit: {
    featureGroup: drawnItems
  }
}))

但是我总是在leaflet.draw.js_initModeHandler方法中得到这个错误

TypeError: Cannot set property 'polyline' of undefined

似乎this._modes[type] = {};失败了,因为this._modesundefined

我试图使this._modes一个对象,如果undefined,但这只是抛出了另一个错误关于如何addToolbar方法是undefined,太。

此错误来自另一个L.Toolbar类,该类确实覆盖了Leaflet.draw提供的类。

另一个L.Toolbar没有在initialize()中设置this._modes

最新更新