diff --git a/src/components/DrawTools.js b/src/components/DrawTools.js index 791233b3996d525e4c1da055f69011f66546aa46..0fbf85c1f2ad0fdf391b0b07dcee8350363e3fad 100644 --- a/src/components/DrawTools.js +++ b/src/components/DrawTools.js @@ -5,11 +5,27 @@ import { } from 'react-leaflet' class DrawTools extends Component { + constructor(props){ + super(props); + this.state = { + geoJSONAll: [] // property for all GeoJSON data in the map + } + } + _onCreated = (e) => { let type = e.layerType; // from the example; isn't used right now, but may be relevant in the future - let layer = e.layer; - let geoJSON = layer.toGeoJSON(); - console.log(JSON.stringify(geoJSON, null, 4)); // makes the output readable in the console + let layer = e.layer; + this.makeGeoJSON(e.layer); + } + + // turn layer to GeoJSON data and add it to an array of all GeoJSON data of the current map + makeGeoJSON = (e) => { + let geoJSON = e.toGeoJSON(); + let newGeoJSONAll = this.state.geoJSONAll; + newGeoJSONAll.push(geoJSON); + this.setState({geoJSONAll: newGeoJSONAll}); + console.log(JSON.stringify(geoJSON, null, 4)); // printing GeoJSON data of the previous object create + console.log("newGeoJSONAll.length: " + newGeoJSONAll.length); } render() { diff --git a/src/components/UserMap.js b/src/components/UserMap.js index 1ec4c484d990b5b29ff443a7840a86e2517bda78..877cca2ce37db4adfa44ce8200f9f1322f2e676e 100644 --- a/src/components/UserMap.js +++ b/src/components/UserMap.js @@ -79,7 +79,13 @@ class UserMap extends Component { render() { return ( - <Map className='map' center={this.props.position} zoom={this.props.zoom}> + <Map + className='map' + center={this.props.position} + zoom={this.props.zoom} + minZoom='7' + maxZoom='17' + zoomControl={false}> <TileLayer attribution='© <a href="https://www.maanmittauslaitos.fi/">Maanmittauslaitos</a>' url={this.props.mapUrl}