Javascript 传单.画圆错误:无法读取属性';长度';空的
我使用传单.draw在地图中创建形状(地理区域),当我绘制圆时,由于圆没有长度,所以会出现此错误,当我在shapeOptions中放入可编辑:true时,也会出现此错误:Javascript 传单.画圆错误:无法读取属性';长度';空的,javascript,php,codeigniter,leaflet,leaflet.draw,Javascript,Php,Codeigniter,Leaflet,Leaflet.draw,我使用传单.draw在地图中创建形状(地理区域),当我绘制圆时,由于圆没有长度,所以会出现此错误,当我在shapeOptions中放入可编辑:true时,也会出现此错误: $("#mapContainer").on("click", ".btnCircleDraw",function(){ circleDrawer = new L.Draw.Circle(map, { shapeOptions: { color: colo
$("#mapContainer").on("click", ".btnCircleDraw",function(){
circleDrawer = new L.Draw.Circle(map, {
shapeOptions: {
color: color,
fillOpacity: opacity,
fillColor: color,
stroke: color,
opacity: opacity,
editable: true
}
});
map.on('draw:created', drawCreated);
circleDrawer.enable();
});
我创建了以下函数:
function drawCreated(e) {
type = e.layerType,
layer = e.layer;
layer.addTo(drawnItems);
console.log(type, ' drawn', layer);
layer.on("edit", function(event) {
var content = "";
if (type === "circle") {
//content = 'Circle with : <ul><li> Radius : ' + layer.getRadius() + '</li>'+
//'<li> Center : ' + layer.getLatLng() + ' </li></ul>';
var lngLat = layer.getLatLng();
console.log("new: ", lngLat);
}
});
if (type === 'circle') {
var theCenterPt = layer.getLatLng();
var theRadius = layer.getRadius();
points['lng'] = theCenterPt.lng;
points['lat'] = theCenterPt.lat;
points['radius'] = theRadius;
console.log(points);
drawnItems.addLayer(layer);
}
}
创建的函数(e){
类型=e.layerType,
层=e层;
图层。添加到(drawnItems);
控制台日志(类型“绘制”,图层);
图层打开(“编辑”,功能(事件){
var-content=“”;
如果(类型==“圆”){
//content='用:- 半径:'+layer.getRadius()+'
圈起来+
//“- 中心:”+layer.getLatLng()+”
”;
var lngLat=layer.getLatLng();
console.log(“新:”,lngLat);
}
});
如果(类型=='圆圈'){
var theCenterPt=layer.getLatLng();
var theRadius=layer.getRadius();
点['lng']=中心lng;
点['lat']=中心纬度;
点['radius']=theRadius;
控制台日志(点);
drawnItems.addLayer(层);
}
}
这个问题有解决方案或替代方案吗