Skip to content
Snippets Groups Projects
Commit 800603a0 authored by L4721's avatar L4721
Browse files

Merge branch 'print-all-geojson' into 'development'

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

See merge request !9
parents 4d6113d0 17e773b9
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 {
} 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() {
......
......@@ -83,7 +83,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='&copy; <a href="https://www.maanmittauslaitos.fi/">Maanmittauslaitos</a>'
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