From 59008528144ca757dc2e41745209699e22a35a8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Taneli=20Riihim=C3=A4ki?= <m3034@student.jamk.fi> Date: Wed, 19 Jun 2019 10:42:57 +0300 Subject: [PATCH] ADD multiple drawings and fetch them (still problems with duplicated elements) --- src/components/UserMap.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/UserMap.js b/src/components/UserMap.js index e6409ab..1340fe5 100644 --- a/src/components/UserMap.js +++ b/src/components/UserMap.js @@ -17,7 +17,6 @@ class UserMap extends Component { ownLat: null, ownLng: null, mapUrl: "https://tiles.kartat.kapsi.fi/taustakartta/{z}/{x}/{y}.jpg", - geoJSONFeatures: [], geoJSONLayer: { type: "FeatureCollection", features: [] @@ -65,7 +64,9 @@ class UserMap extends Component { .then(data => { let newFeatures = []; data.map(item => { - newFeatures.push(item.features[0][0]); + item.features[0].map(feature => { + newFeatures.push(feature); + }); return newFeatures; }); @@ -131,7 +132,7 @@ class UserMap extends Component { // Function to be passed to DrawTools so it can add geojson data to this components state addToGeojsonLayer(layerToAdd) { - let oldFeatures = [...this.state.geoJSONFeatures]; + let oldFeatures = []; oldFeatures.push(layerToAdd); const newFeatures = oldFeatures; this.setState({ geoJSONLayer: { features: newFeatures } }); -- GitLab