问题描述
首先,我编写代码以使用 leaflet.draw
创建工具栏var drawPluginoptions = {
position: 'topright',draw: {
polyline: false,circle: false,// Turns off this drawing tool
rectangle: false,marker: false,polygon: {
allowIntersection: false,// Restricts shapes to simple polygons
showArea: true,drawError: {
color: '#ffc107',// Color the shape will turn when intersects
},shapeOptions: {
color: '#057d50'
},},edit: {
featureGroup: editableLayers,//required!!
remove: true,edit: true,}
};
var drawControl = new L.Control.Draw(drawPluginoptions);
map.addControl(drawControl);
在那之后,我使用 L.drawLocal 对消息和标题进行了本地化。 我需要重新创建地图,但会导致错误无法读取未定义的属性“错误” 我想知道如何同时使用它们
解决方法
我意识到,出现此问题的原因是因为 L.drawLocal ,而不是 map.addControl 。
首先,我检查了错误代码,并且“ 无法读取未定义的属性'error'”消息与折线错误有关。因此,我添加了不需要本地化的错误,如下所示: https://stackoverflow.com/a/53401594/2543986
此后,我将 L.drawLocal 的位置更改为 map.addControl
的 top