我想添加一个绘制控件到我的传单地图,像这样:
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._modes
是undefined
。
我试图使this._modes
一个对象,如果undefined
,但这只是抛出了另一个错误关于如何addToolbar
方法是undefined
,太。
此错误来自另一个L.Toolbar
类,该类确实覆盖了Leaflet.draw提供的类。
另一个L.Toolbar
没有在initialize()
中设置this._modes