|
|
|
|
@ -15,7 +15,7 @@ import {
|
|
|
|
|
|
|
|
|
|
import RunInfo from './components/run-info';
|
|
|
|
|
import RunInfoNumeric from './components/run-info-num';
|
|
|
|
|
import {updateAreas} from './update-map'
|
|
|
|
|
import {updateAreas, sendArea} from './update-map'
|
|
|
|
|
import MapView from 'react-native-maps';
|
|
|
|
|
import WalkButton from "./components/new-button";
|
|
|
|
|
import JoinButton from "./components/join-button";
|
|
|
|
|
@ -39,15 +39,23 @@ export default class App extends Component<Props> {
|
|
|
|
|
}, 5000);
|
|
|
|
|
|
|
|
|
|
let watchID = navigator.geolocation.watchPosition((position) => {
|
|
|
|
|
this.setState({
|
|
|
|
|
walkMarkers: [
|
|
|
|
|
...this.state.walkMarkers, {
|
|
|
|
|
coordinate: position.coords,
|
|
|
|
|
key: id++
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
}, null, {enableHighAccuracy: true, timeout: 20000, distanceFilter: 15});
|
|
|
|
|
console.log(this.state.activeWalk)
|
|
|
|
|
if(this.state.activeWalk){
|
|
|
|
|
this.setState({
|
|
|
|
|
walkMarkers: [
|
|
|
|
|
...this.state.walkMarkers, {
|
|
|
|
|
coordinate: position.coords,
|
|
|
|
|
key: id++
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
// if(!this.state.activeWalk){
|
|
|
|
|
// this.setState({
|
|
|
|
|
// walkMarkers: []
|
|
|
|
|
// })
|
|
|
|
|
// }
|
|
|
|
|
}, null, {enableHighAccuracy: true, timeout: 20000, distanceFilter: 10});
|
|
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
|
activeWalk: false,
|
|
|
|
|
@ -84,11 +92,15 @@ export default class App extends Component<Props> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
startWalk(){
|
|
|
|
|
console.log("starting walk")
|
|
|
|
|
this.setState({walkMarkers: [], activeWalk: true})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stopWalk(){
|
|
|
|
|
console.log("stopping walk")
|
|
|
|
|
sendArea(this.state.gameNumber, this.state.username, this.state.walkMarkers)
|
|
|
|
|
this.setState({activeWalk: false})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
|
@ -108,12 +120,13 @@ export default class App extends Component<Props> {
|
|
|
|
|
latitudeDelta: 0.02,
|
|
|
|
|
longitudeDelta: 0.02,
|
|
|
|
|
}}
|
|
|
|
|
// onRegionChange = {(region)=> this.addMarker((region))}
|
|
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
<MapView.Polyline
|
|
|
|
|
coordinates={this.state.walkMarkers.map((marker) => marker.coordinate)}
|
|
|
|
|
strokeWidth={5}
|
|
|
|
|
strokeColor={"rgb(148,0,211)"}
|
|
|
|
|
/>
|
|
|
|
|
{this.state.captures.map((capture, i) => {
|
|
|
|
|
return <MapView.Polygon
|
|
|
|
|
|