11import React , { useState , useEffect } from "react" ;
2- import calvinmap from "../assets/calvin-0-cropped .jpg" ;
2+ import calvinmap from "../assets/calvin-map-01 .jpg" ;
33import {
44 StyleSheet ,
55 Text ,
@@ -19,14 +19,18 @@ import ImageZoom from "react-native-image-pan-zoom";
1919import MapView from "expo" ;
2020import { globalStyles } from "../styles/global" ;
2121
22+ const imageWidth = 4285 ;
23+ const imageHeight = 3001 ;
24+
2225export default function mapScreen ( { navigation } ) {
2326 // FYI, I had to wrap the ImageZoom in an ImageBackground to be able to
2427 // render things on top of it. The ScrollView is so the input/search box doesn't hike up the map
2528 const [ pos , setPos ] = useState ( { } ) ;
2629 const [ posAvailable , setPosAvailable ] = useState ( false ) ;
2730 const [ pointX , setPointX ] = useState ( - 100 ) ;
2831 const [ pointY , setPointY ] = useState ( - 100 ) ;
29- const [ isLoading , setLoading ] = useState ( true ) ;
32+ const [ isLoading , setLoading ] = useState ( false ) ;
33+
3034
3135 useEffect ( ( ) => {
3236 navigator . geolocation . getCurrentPosition (
@@ -42,12 +46,21 @@ export default function mapScreen({ navigation }) {
4246 if ( posAvailable ) {
4347 // let lat = 0.006500;
4448 // let long = 0.006000;
45- let lat = Math . abs ( pos . coords . latitude - 42.935352 ) ;
46- let long = pos . coords . longitude + 85.590951 ;
4749
48- if ( lat >= 0 && lat <= 0.006573 && long >= 0 && long <= 0.006075 ) {
49- setPointX ( long * 219686.6 ) ;
50- setPointY ( lat * 334702.571 ) ;
50+ // Top left corner coordinates
51+ let absLat = 42.937980
52+ let absLon = - 85.593117
53+ // Bottom right corner coordinates
54+ let maxLat = 42.926039
55+ let maxLon = - 85.570271
56+
57+ let lat = Math . abs ( pos . coords . latitude - absLat ) ;
58+ let long = pos . coords . longitude - absLon ;
59+
60+
61+ if ( lat >= 0 && lat <= Math . abs ( absLat - maxLat ) && long >= 0 && long <= Math . abs ( absLon - maxLon ) ) {
62+ setPointX ( long * imageWidth / Math . abs ( absLon - maxLon ) ) ;
63+ setPointY ( lat * imageHeight / Math . abs ( absLat - maxLat ) ) ;
5164 setLoading ( false ) ;
5265 console . log ( pointX ) ;
5366 console . log ( pointY ) ;
@@ -60,9 +73,13 @@ export default function mapScreen({ navigation }) {
6073 } , [ posAvailable ] ) ;
6174
6275 return (
63- < ScrollView style = { styles . main } >
64- { isLoading ? < ActivityIndicator /> : (
65- < ImageBackground style = { styles . imageViewWrapper } >
76+ < View style = { styles . main } >
77+ { isLoading ? (
78+ < View >
79+ < ActivityIndicator animating = { true } />
80+ </ View >
81+ ) : (
82+ < View >
6683 { /* Footer for search bar and buttons */ }
6784 < View style = { styles . footer } >
6885 { /* Search Bar */ }
@@ -82,12 +99,12 @@ export default function mapScreen({ navigation }) {
8299 < ImageZoom
83100 cropWidth = { Dimensions . get ( "window" ) . width }
84101 cropHeight = { Dimensions . get ( "window" ) . height }
85- imageWidth = { 1444 }
86- imageHeight = { 2200 }
102+ imageWidth = { imageWidth }
103+ imageHeight = { imageHeight }
87104 panToMove = { true }
88105 pinchToZoom = { true }
89106 enableCenterFocus = { false }
90- minScale = { 0.25 }
107+ minScale = { 0.15 }
91108 >
92109 < Image style = { styles . map } source = { calvinmap } />
93110 < Pressable
@@ -113,7 +130,7 @@ export default function mapScreen({ navigation }) {
113130 position : 'absolute' ,
114131 } } />
115132 </ ImageZoom >
116- </ ImageBackground >
133+ </ View >
117134
118135 // {/* The_Dunco: Experimenting around with react-native-apps, it gets into some really wonky stuff.
119136 // Expo hides a lot of the files that you need to add your API key and stuff like that. */ }
@@ -132,7 +149,7 @@ export default function mapScreen({ navigation }) {
132149 // showsUserLocation={true}
133150 // /> */ }
134151 ) }
135- </ ScrollView >
152+ </ View >
136153 ) ;
137154}
138155
@@ -141,6 +158,7 @@ const styles = StyleSheet.create({
141158 flex : 1 ,
142159 flexDirection : "row" ,
143160 alignContent : "space-around" ,
161+ backgroundColor : '#FFFFFF'
144162 } ,
145163 imageViewWrapper : {
146164 flex : 1 ,
@@ -150,21 +168,21 @@ const styles = StyleSheet.create({
150168 height : "100%" ,
151169 } ,
152170 map : {
153- width : 1444 ,
154- height : 2200 ,
171+ width : imageWidth * 1 ,
172+ height : imageHeight * 1 ,
155173 zIndex : 0 ,
156174 } ,
157175 press : {
158176 width : 220 * 1.2 ,
159177 height : 170 * 1.2 ,
160- marginLeft : 300 ,
161- marginTop : 1325 ,
178+ marginLeft : 718 ,
179+ marginTop : 1665 ,
162180 position : "absolute" ,
163181 } ,
164182 sb : {
165- width : 220 * 1.2 ,
166- height : 170 * 1.2 ,
167- opacity : 0.8 ,
183+ width : 220 * 1.02 ,
184+ height : 170 * 1.02 ,
185+ opacity : 0.5 ,
168186 } ,
169187 footer : {
170188 backgroundColor : "#2D2D2D" ,
0 commit comments