Skip to content

Commit d4378eb

Browse files
authored
Merge pull request #9 from Wayfinder-CS262-2020/map/gps
gps now tracks location and heading
2 parents 68c0206 + b77ee7a commit d4378eb

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

assets/wayfinder-logo-yellow.png

299 KB
Loading

screens/mapScreen.js

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export default function mapScreen({ navigation }) {
3030
const [pointX, setPointX] = useState(-100);
3131
const [pointY, setPointY] = useState(-100);
3232
const [isLoading, setLoading] = useState(false);
33+
const [heading, setHeading] = useState(0);
3334

3435

3536
useEffect(() => {
@@ -48,20 +49,20 @@ export default function mapScreen({ navigation }) {
4849
// let long = 0.006000;
4950

5051
// Top left corner coordinates
51-
let absLat = 42.937980
52-
let absLon = -85.593117
52+
let absLat = 42.937858
53+
let absLon = -85.593565
5354
// Bottom right corner coordinates
54-
let maxLat = 42.926039
55-
let maxLon = -85.570271
55+
let maxLat = 42.926166
56+
let maxLon = -85.570076
5657

5758
let lat = Math.abs(pos.coords.latitude - absLat);
5859
let long = pos.coords.longitude - absLon;
59-
6060

6161
if (lat >= 0 && lat <= Math.abs(absLat-maxLat) && long >= 0 && long <= Math.abs(absLon-maxLon)) {
6262
setPointX(long * imageWidth / Math.abs(absLon-maxLon));
6363
setPointY(lat * imageHeight / Math.abs(absLat-maxLat));
6464
setLoading(false);
65+
setHeading(pos.coords.heading);
6566
console.log(pointX);
6667
console.log(pointY);
6768
} else {
@@ -70,7 +71,8 @@ export default function mapScreen({ navigation }) {
7071
}
7172

7273
};
73-
}, [posAvailable]);
74+
75+
}, [pos]);
7476

7577
return (
7678
<View style={styles.main}>
@@ -121,14 +123,16 @@ export default function mapScreen({ navigation }) {
121123
<Image style={styles.sb} source={require("../assets/SB-0.jpg")} />
122124
</Pressable>
123125

124-
<View style={{
125-
marginTop: pointY,
126-
marginLeft: pointX,
127-
backgroundColor: '#ff0000',
128-
width: 20,
129-
height: 20,
130-
position: 'absolute',
131-
}}/>
126+
<View style={[
127+
styles.dot,
128+
{
129+
marginTop: pointY,
130+
marginLeft: pointX,
131+
transform: [{ rotateZ: String(heading) + "deg" }]
132+
},
133+
]}>
134+
<Image style={{ width: 20, height: 20 }} source={require("../assets/wayfinder-logo-yellow.png")} />
135+
</View>
132136
</ImageZoom>
133137
</View>
134138

@@ -184,6 +188,11 @@ const styles = StyleSheet.create({
184188
height: 170 * 1.02,
185189
opacity: 0.5,
186190
},
191+
dot: {
192+
width: 20,
193+
height: 20,
194+
position: 'absolute',
195+
},
187196
footer: {
188197
backgroundColor: "#2D2D2D",
189198
color: "#2D2D2D",

0 commit comments

Comments
 (0)