diff --git a/src/components/DrawTools.js b/src/components/DrawTools.js index a0ae6a95aa7d766914d319ecd15f333cf6c87ced..cad46ebc192b29ccec8321ab819882a32a767561 100644 --- a/src/components/DrawTools.js +++ b/src/components/DrawTools.js @@ -36,14 +36,23 @@ class DrawTools extends Component { // this.props.sendGeoJSON(e.poly); }; - _onEditStart = () => { + _onEditDeleteStart = () => { this.setState({ editModeActive: true }); }; - _onEditStop = () => { + _onEditDeleteStop = () => { this.setState({ editModeActive: false }); }; + _onDeleted = e => { + console.log(e.layers._layers); + /* to be added once back-end functionality is available + for(layer in e.layers._layers) { + this.sendGeoJSON(layer.options.id); + } + */ + }; + shouldComponentUpdate() { // disable re-rendering when edit mode is active return !this.state.editModeActive; @@ -92,12 +101,14 @@ class DrawTools extends Component { <EditControl position="topright" onCreated={this._onCreated} - onDrawStop={this._onDrawStop} - onEditStart={this._onEditStart} - onEditStop={this._onEditStop} + onEditStart={this._onEditDeleteStart} + onEditStop={this._onEditDeleteStop} onEditMove={this._onEditMove} onEditResize={this._onEditResize} onEditVertex={this._onEditVertex} + onDeleted={this._onDeleted} + onDeleteStart={this._onEditDeleteStart} + onDeleteStop={this._onEditDeleteStop} draw={{ circle: { repeatMode: true, // allows using the tool again after finishing the previous shape diff --git a/src/components/UserMap.js b/src/components/UserMap.js index 33a82debf4160ceac62e5c94a68bd2c8893cf6bf..b79dfc25d30f695adf6aee96e9361837944146bc 100644 --- a/src/components/UserMap.js +++ b/src/components/UserMap.js @@ -133,7 +133,7 @@ class UserMap extends Component { <ZoomControl position="topright" /> <DrawTools position={this.props.position} - addToGeojsonLayer={this.addToGeojsonLayer} + sendGeoJSON={this.sendGeoJSON} geoJSONLayer={this.state.geoJSONLayer} /> {this.state.ownLat !== null && (