|
|
|
@ -36,10 +36,29 @@ export default class App extends Component<Props> {
|
|
|
|
constructor(props) {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let watchID = navigator.geolocation.watchPosition((position) => {
|
|
|
|
|
|
|
|
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 = {
|
|
|
|
this.state = {
|
|
|
|
activeWalk: false,
|
|
|
|
activeWalk: false,
|
|
|
|
username: "",
|
|
|
|
username: "samded",
|
|
|
|
gameNumber: "",
|
|
|
|
gameNumber: "samdum",
|
|
|
|
walkMarkers: [],
|
|
|
|
walkMarkers: [],
|
|
|
|
captures: [
|
|
|
|
captures: [
|
|
|
|
// new CapturedArea("fanded", [
|
|
|
|
// new CapturedArea("fanded", [
|
|
|
|
@ -56,30 +75,12 @@ export default class App extends Component<Props> {
|
|
|
|
{latitude: -43.5668, longitude:172.5615}
|
|
|
|
{latitude: -43.5668, longitude:172.5615}
|
|
|
|
], 'rgba(0,0,255, 1)', 'rgba(0,0,255, 0.2)', 53)
|
|
|
|
], 'rgba(0,0,255, 1)', 'rgba(0,0,255, 0.2)', 53)
|
|
|
|
],
|
|
|
|
],
|
|
|
|
watchID
|
|
|
|
watchID,
|
|
|
|
|
|
|
|
activity: "map"
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
componentDidMount() {
|
|
|
|
let watchID = navigator.geolocation.watchPosition((position) => {
|
|
|
|
|
|
|
|
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});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setInterval(() => {
|
|
|
|
setInterval(() => {
|
|
|
|
this.updateCaptures();
|
|
|
|
this.updateCaptures();
|
|
|
|
}, 5000);
|
|
|
|
}, 5000);
|
|
|
|
@ -104,6 +105,12 @@ export default class App extends Component<Props> {
|
|
|
|
stopWalk(){
|
|
|
|
stopWalk(){
|
|
|
|
console.log("stopping walk")
|
|
|
|
console.log("stopping walk")
|
|
|
|
sendArea(this.state.gameNumber, this.state.username, this.state.walkMarkers)
|
|
|
|
sendArea(this.state.gameNumber, this.state.username, this.state.walkMarkers)
|
|
|
|
|
|
|
|
.then(data => {
|
|
|
|
|
|
|
|
console.log(data);
|
|
|
|
|
|
|
|
if (data != []) {
|
|
|
|
|
|
|
|
this.takePicture(data.polygonID);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
this.setState({activeWalk: false})
|
|
|
|
this.setState({activeWalk: false})
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -111,41 +118,26 @@ export default class App extends Component<Props> {
|
|
|
|
componentWillUnmount() {
|
|
|
|
componentWillUnmount() {
|
|
|
|
navigator.geolocation.stopWatch(this.state.watchID);
|
|
|
|
navigator.geolocation.stopWatch(this.state.watchID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
takePicture = async function() {
|
|
|
|
|
|
|
|
|
|
|
|
takePicture = async function(polygonID) {
|
|
|
|
if (this.camera) {
|
|
|
|
if (this.camera) {
|
|
|
|
const options = { quality: 0.5, base64: true };
|
|
|
|
const options = { quality: 0.5, base64: true };
|
|
|
|
const data = await this.camera.takePictureAsync(options)
|
|
|
|
const data = await this.camera.takePictureAsync(options)
|
|
|
|
console.log(data.uri);
|
|
|
|
console.log(data.uri);
|
|
|
|
|
|
|
|
this.setState({activity: "map"});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
showCamera() {
|
|
|
|
|
|
|
|
this.setState({activity: "takePicture"});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
render() {
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
let view = "";
|
|
|
|
// <View style={styles.container}>
|
|
|
|
if (this.state.activity === "map") {
|
|
|
|
// <RNCamera
|
|
|
|
view =
|
|
|
|
// ref={ref => {
|
|
|
|
|
|
|
|
// this.camera = ref;
|
|
|
|
|
|
|
|
// }}
|
|
|
|
|
|
|
|
// style = {styles.preview}
|
|
|
|
|
|
|
|
// type={RNCamera.Constants.Type.back}
|
|
|
|
|
|
|
|
// flashMode={RNCamera.Constants.FlashMode.on}
|
|
|
|
|
|
|
|
// permissionDialogTitle={'Permission to use camera'}
|
|
|
|
|
|
|
|
// permissionDialogMessage={'We need your permission to use your camera phone'}
|
|
|
|
|
|
|
|
// onGoogleVisionBarcodesDetected={({ barcodes }) => {
|
|
|
|
|
|
|
|
// console.log(barcodes)
|
|
|
|
|
|
|
|
// }}
|
|
|
|
|
|
|
|
// />
|
|
|
|
|
|
|
|
// <View style={{flex: 0, flexDirection: 'row', justifyContent: 'center',}}>
|
|
|
|
|
|
|
|
// <TouchableOpacity
|
|
|
|
|
|
|
|
// onPress={this.takePicture.bind(this)}
|
|
|
|
|
|
|
|
// style = {styles.capture}
|
|
|
|
|
|
|
|
// >
|
|
|
|
|
|
|
|
// <Text style={{fontSize: 14}}> SNAP </Text>
|
|
|
|
|
|
|
|
// </TouchableOpacity>
|
|
|
|
|
|
|
|
// </View>
|
|
|
|
|
|
|
|
// </View>
|
|
|
|
|
|
|
|
<View style ={{flex: 1}}>
|
|
|
|
<View style ={{flex: 1}}>
|
|
|
|
<MapView
|
|
|
|
<MapView
|
|
|
|
showsUserLocation
|
|
|
|
showsUserLocation
|
|
|
|
@ -199,7 +191,34 @@ export default class App extends Component<Props> {
|
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
} else if (this.state.activity === "takePicture") {
|
|
|
|
|
|
|
|
view = <View style={styles.container}>
|
|
|
|
|
|
|
|
<RNCamera
|
|
|
|
|
|
|
|
ref={ref => {
|
|
|
|
|
|
|
|
this.camera = ref;
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
style = {styles.preview}
|
|
|
|
|
|
|
|
type={RNCamera.Constants.Type.back}
|
|
|
|
|
|
|
|
flashMode={RNCamera.Constants.FlashMode.on}
|
|
|
|
|
|
|
|
permissionDialogTitle={'Permission to use camera'}
|
|
|
|
|
|
|
|
permissionDialogMessage={'We need your permission to use your camera phone'}
|
|
|
|
|
|
|
|
onGoogleVisionBarcodesDetected={({ barcodes }) => {
|
|
|
|
|
|
|
|
console.log(barcodes)
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
<View style={{flex: 0, flexDirection: 'row', justifyContent: 'center',}}>
|
|
|
|
|
|
|
|
<TouchableOpacity
|
|
|
|
|
|
|
|
onPress={this.takePicture.bind(this)}
|
|
|
|
|
|
|
|
style = {styles.capture}
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<Text style={{fontSize: 14}}> SNAP </Text>
|
|
|
|
|
|
|
|
</TouchableOpacity>
|
|
|
|
|
|
|
|
</View>
|
|
|
|
|
|
|
|
</View>
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return view;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|