// check if a drawn polyline has just one point in it
// check if a drawn polyline has just one point in it
if (e.layerType==='polyline'&&e.layer.getLatLngs().length===1){
if (e.layerType==='polyline'&&e.layer.getLatLngs().length===1){
e.layer.remove();
e.layer.remove();
return;
return;
}
}
if (e.layerType==='marker'){
if (e.layerType==='marker'){
e.layer.bindTooltip('say hello to mr. akers');
e.layer.bindTooltip('say hello to mr. akers');
}
}
lettype=e.layerType;// from the example; isn't used right now, but may be relevant in the future
lettype=e.layerType;// from the example; isn't used right now, but may be relevant in the future
letlayer=e.layer;
letlayer=e.layer;
letgeoJSON=layer.toGeoJSON();
letgeoJSON=layer.toGeoJSON();
console.log(JSON.stringify(geoJSON,null,4));// makes the output readable in the console
console.log(JSON.stringify(geoJSON,null,4));// makes the output readable in the console
}
}
render(){
render(){
return (
return (
// "It's important to wrap EditControl component into FeatureGroup component from react-leaflet. The elements you draw will be added to this FeatureGroup layer, when you hit edit button only items in this layer will be edited."
// "It's important to wrap EditControl component into FeatureGroup component from react-leaflet. The elements you draw will be added to this FeatureGroup layer, when you hit edit button only items in this layer will be edited."
<FeatureGroup>
<FeatureGroup>
<EditControl
<EditControl
position='topright'
position='topright'
onCreated={this._onCreated}
onCreated={this._onCreated}
draw={{
draw={{
circle:{
circle:{
repeatMode:true,// allows using the tool again after finishing the previous shape
repeatMode:true,// allows using the tool again after finishing the previous shape
shapeOptions:{
shapeOptions:{
color:'#f9f10c',
color:'#f9f10c',
opacity:1
opacity:1
}
}
},
},
rectangle:{
rectangle:{
repeatMode:true
repeatMode:true
},
},
polygon:{
polygon:{
repeatMode:true,
repeatMode:true,
allowIntersection:false,// Restricts shapes to simple polygons
allowIntersection:false,// Restricts shapes to simple polygons
drawError:{
drawError:{
color:'#e1e100',// Color the shape will turn when intersects
color:'#e1e100',// Color the shape will turn when intersects
message:'<strong>Oh snap!<strong> you can\'t draw that!'// Message that will show when intersect
message:'<strong>Oh snap!<strong> you can\'t draw that!'// Message that will show when intersect