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

GeoJSON data is now saved into one array. Also added min and max zoom, and...

GeoJSON data is now saved into one array. Also added min and max zoom, and removed zoom control from top left corner
parent 4c125a44
No related branches found
No related tags found
2 merge requests!15Get game creation to user-marker-database-interactions,!9GeoJSON data is now saved into one array. Also added min and max zoom, and...
...@@ -5,11 +5,27 @@ import { ...@@ -5,11 +5,27 @@ import {
} from 'react-leaflet' } from 'react-leaflet'
class DrawTools extends Component { class DrawTools extends Component {
constructor(props){
super(props);
this.state = {
geoJSONAll: [] // property for all GeoJSON data in the map
}
}
_onCreated = (e) => { _onCreated = (e) => {
let type = e.layerType; // from the example; isn't used right now, but may be relevant in the future 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(); this.makeGeoJSON(e.layer);
console.log(JSON.stringify(geoJSON, null, 4)); // makes the output readable in the console }
// 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() { render() {
......
...@@ -79,7 +79,13 @@ class UserMap extends Component { ...@@ -79,7 +79,13 @@ class UserMap extends Component {
render() { render() {
return ( 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 <TileLayer
attribution='&copy; <a href="https://www.maanmittauslaitos.fi/">Maanmittauslaitos</a>' attribution='&copy; <a href="https://www.maanmittauslaitos.fi/">Maanmittauslaitos</a>'
url={this.props.mapUrl} url={this.props.mapUrl}
......
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