|
@@ -3,6 +3,7 @@ import React, { Component } from 'react'
|
|
|
import './App.css'
|
|
|
import Map from 'pigeon-maps'
|
|
|
import Marker from 'pigeon-marker'
|
|
|
+import { geolocated } from "react-geolocated"
|
|
|
|
|
|
|
|
|
import Tables from './Tables';
|
|
@@ -35,16 +36,17 @@ const providers = {
|
|
|
}
|
|
|
|
|
|
const markers = {
|
|
|
- Bernie: [[50.879, 4.6997], 13],
|
|
|
- Martin: [[48.1542144, 13.9952128], 13],
|
|
|
- Simon: [[50.85050, 4.35149], 11],
|
|
|
- Lukas: [[51.0514, 3.7103], 12],
|
|
|
+ Bernie: [[48.1542150, 13.9952130], 13],
|
|
|
+ Martin: [[48.1642150, 13.9952130], 12],
|
|
|
+ Simon: [[48.1642160, 13.9852140], 11],
|
|
|
+ Lukas: [[48.1542134, 14.0052118], 10],
|
|
|
}
|
|
|
|
|
|
const lng2tile = (lon, zoom) => (lon + 180) / 360 * Math.pow(2, zoom)
|
|
|
const lat2tile = (lat, zoom) => (1 - Math.log(Math.tan(lat * Math.PI / 180) + 1 / Math.cos(lat * Math.PI / 180)) / Math.PI) / 2 * Math.pow(2, zoom)
|
|
|
|
|
|
|
|
|
+
|
|
|
function isMapBox (provider) {
|
|
|
return provider === 'streets' || provider === 'satellite' || provider === 'outdoors' || provider === 'light' || provider === 'dark'
|
|
|
}
|
|
@@ -90,6 +92,7 @@ export default class App extends Component {
|
|
|
minZoom: 1,
|
|
|
maxZoom: 18,
|
|
|
dragAnchor: [48.1665, 14.0223]
|
|
|
+
|
|
|
};
|
|
|
this.componentDidMount = this.componentDidMount.bind(this)
|
|
|
}
|
|
@@ -119,6 +122,7 @@ export default class App extends Component {
|
|
|
|
|
|
handleMarkerClick = ({ event, payload, anchor }) => {
|
|
|
console.log(`Marker #${payload} clicked at: `, anchor)
|
|
|
+
|
|
|
}
|
|
|
|
|
|
handleAnimationStart = () => {
|
|
@@ -141,6 +145,7 @@ export default class App extends Component {
|
|
|
.then(data =>{
|
|
|
console.log(data["users"]);
|
|
|
this.setState({ persons: data["users"] })
|
|
|
+
|
|
|
}).catch(error => {
|
|
|
console.log(error);
|
|
|
});
|
|
@@ -149,8 +154,9 @@ export default class App extends Component {
|
|
|
receivedPosition = (position) => {
|
|
|
const axios = require('axios');
|
|
|
axios.put(this.apiUrl + "/report-location", {
|
|
|
- "longitude": position.coords.longitude + Math.random()*10,
|
|
|
+ "longitude": position.coords.longitude,
|
|
|
"latitude": position.coords.latitude,
|
|
|
+
|
|
|
"timestamp": position.timestamp/1000, // in seconds
|
|
|
"name": this.name
|
|
|
}).then(this.reloadLocations)
|
|
@@ -164,6 +170,8 @@ export default class App extends Component {
|
|
|
navigator.geolocation.getCurrentPosition(this.receivedPosition);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -230,18 +238,34 @@ export default class App extends Component {
|
|
|
<button
|
|
|
onClick={ () => {
|
|
|
this.name = "Bernie";
|
|
|
+
|
|
|
+ this.updateLocation();
|
|
|
+ markers.Bernie=[[this.state.persons[3].latitude,this.state.persons[3].longitude], 13];
|
|
|
+
|
|
|
}}> Bernie </button>
|
|
|
<button
|
|
|
onClick={ () => {
|
|
|
this.name = "Martin";
|
|
|
+
|
|
|
+ this.updateLocation();
|
|
|
+ markers.Martin=[[this.state.persons[0].latitude,this.state.persons[0].longitude], 12];
|
|
|
+
|
|
|
}}> Martin </button>
|
|
|
<button
|
|
|
onClick={ () => {
|
|
|
this.name = "Simon";
|
|
|
+
|
|
|
+ this.updateLocation();
|
|
|
+ markers.Simon=[[this.state.persons[1].latitude,this.state.persons[1].longitude], 11];
|
|
|
+
|
|
|
}}> Simon </button>
|
|
|
<button
|
|
|
onClick={ () => {
|
|
|
this.name = "Lukas";
|
|
|
+
|
|
|
+ this.updateLocation();
|
|
|
+ markers.Lukas=[[this.state.persons[2].latitude,this.state.persons[2].longitude], 10];
|
|
|
+
|
|
|
}}> Lukas </button>
|
|
|
</div>
|
|
|
|