Skip to content
Snippets Groups Projects
Commit b05d7a76 authored by L4929's avatar L4929
Browse files

Removed useless code

parent 7cb10e1e
No related branches found
No related tags found
1 merge request!2Drawing functions
...@@ -6,17 +6,16 @@ import { ...@@ -6,17 +6,16 @@ import {
class DrawTools extends Component { class DrawTools extends Component {
_onCreated = (e) => { _onCreated = (e) => {
let type = e.layerType; let type = e.layerType; // from the example; isn't used right now, but may be relevant in the future
let layer = e.layer; let layer = e.layer;
let geoJSON = layer.toGeoJSON(); let geoJSON = 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
this._onChange();
} }
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 ref={ (reactFGref) => {this._onFeatureGroupReady(reactFGref);} }> <FeatureGroup>
<EditControl <EditControl
position='topright' position='topright'
onCreated={this._onCreated} onCreated={this._onCreated}
...@@ -59,31 +58,6 @@ class DrawTools extends Component { ...@@ -59,31 +58,6 @@ class DrawTools extends Component {
</FeatureGroup> </FeatureGroup>
) )
} }
_editableFG = null
_onFeatureGroupReady = (reactFGref) => {
// store the ref for future access to content
console.log("reactFGref:");
console.log(reactFGref);
this._editableFG = reactFGref;
}
_onChange = () => {
// this._editableFG contains the edited geometry, which can be manipulated through the leaflet API
const { onChange } = this.props;
console.log("onChange: ");
console.log(onChange);
console.log("this.props: ");
console.log(this.props);
if (!this._editableFG || !onChange) {
return;
}
const geojsonData = this._editableFG.leafletElement.toGeoJSON();
onChange(geojsonData);
}
} }
export default DrawTools; export default DrawTools;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment