diff --git a/src/components/UserMap.js b/src/components/UserMap.js index b6c43631bf138e2818de352cf9c47ddc7f7778f9..1958b27172c92e21f3c81e302a6d62c1ffb588eb 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}>