From dbb65b50b6b159558a983d7dcd5d85f45ec671c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Taneli=20Riihim=C3=A4ki?= <m3034@student.jamk.fi> Date: Thu, 13 Jun 2019 13:22:54 +0300 Subject: [PATCH] mocking data WIP af --- src/components/UserMap.js | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/components/UserMap.js b/src/components/UserMap.js index b6c4363..1958b27 100644 --- a/src/components/UserMap.js +++ b/src/components/UserMap.js @@ -25,8 +25,8 @@ class UserMap extends Component { geometry: { type: "Point", coordinates: [ - null, - null + 62.2416479, + 25.7597186 ] } }] @@ -37,10 +37,15 @@ class UserMap extends Component { } componentDidMount(){ + console.log(JSON.stringify(this.state.marker)) this.getCurrentPosition((position) => { this.setCurrentPosition(position); }); console.log(JSON.stringify(this.state.marker)) + //sendGeoJSON() + } + // Sends the players marker to the backend + sendGeoJSON(){ fetch('http://localhost:5000/mapmarkers/insertLocation', { method: 'PUT', headers: { @@ -54,6 +59,7 @@ class UserMap extends Component { .then(result => console.log(result)) } + componentWillUnmount(){ if(this.watchPositionId != null){ navigator.geolocation.clearWatch(this.watchPositionId); @@ -78,6 +84,7 @@ class UserMap extends Component { ] } }); + console.log(this.state.marker) } getCurrentPosition(callback){ @@ -118,6 +125,26 @@ class UserMap extends Component { return JSON.stringify(geoJSON); } + mockGeoJSON(){ + return (JSON.stringify({ + type: "FeatureCollection", + latitude: "", + longitude: "", + timestamp: "", + features: [{ + type: "Feature", + properties: {}, + geometry: { + type: "Point", + coordinates: [ + 62.2416479, + 25.7597186 + ] + } + }] + })) + } + render() { return ( <Map className='map' center={this.props.position} zoom={this.props.zoom}> -- GitLab