Hendini21 / Local_Flood_Navigation

0 stars 2 forks source link

React Native #3

Open Hendini21 opened 4 years ago

Hendini21 commented 4 years ago

I am trying to understand how React Native works, but I can't figure it out. I am trying to use React Navigation, but I don't know how to get the entirety of the Snack before the navigation, because once I have the navigation, I can actually do stuff, because I am ready for that aspect.

cheehieu commented 4 years ago

Hey @Hendini21! What exactly are you stuck with? How far have you gotten with React Native and React Navigation? Are you able to move between screens?

Hendini21 commented 4 years ago

I can move between screens, I just can't get the actual map to work. From there, the navigation algorithm is the easy part.

cheehieu commented 4 years ago

Hmm. What part of the map is not working? Are you using a library like react-native-maps? Can you upload your React Native project code to the repo?

Hendini21 commented 4 years ago

Sure.

Hendini21 commented 4 years ago

I was trying to use google maps as the base, but I can try react-native-maps

Hendini21 commented 4 years ago

I have no idea what to do with react-native-maps. The program itself looks like it will work, but I have no idea how to implement it.

cheehieu commented 4 years ago

I haven't actually used the library before, but it looks like many have had success. Maybe take a look at these recent articles? https://www.instamobile.io/react-native-tutorials/react-native-maps/ https://blog.logrocket.com/introduction-to-react-native-maps/

Hendini21 commented 4 years ago

I tried following the tutorial and it didn't work.

Hendini21 commented 4 years ago

The first tutorial doesn't work... It doesn't seem to function at all.

cheehieu commented 4 years ago

What specifically are you having trouble with? What is not working and how far into the tutorial are you able to get? It will be easier to help if you can provide more details/code.

Hendini21 commented 4 years ago

So I got a functional map, the tutorial was outdated, now I am just trying to figure out how to access the user's location so that the map can center on that and start there.

cheehieu commented 4 years ago

Is this helpful? https://medium.com/@arvind.chak128/how-to-auto-zoom-into-your-current-location-using-react-native-maps-88f9b3063fe7

Hendini21 commented 4 years ago

That code doesn't work... I have this https://snack.expo.io/@hendini/1d78dc but it doesn't work with the code they added, without it though, it works fine on android and ios.

Hendini21 commented 4 years ago

at this link you can see the code that works. https://docs.expo.io/versions/v38.0.0/sdk/map-view/

cheehieu commented 4 years ago

Check this out. I tried to simplify the code from the tutorial to make it easier to understand. Added a "Get Location" button to get the current lat/long position and then animate the MapView to the region. It worked fine for me in the browser Android simulator and on a real iPhone with Expo. Hope this helps.

https://snack.expo.io/@cheehieu/5f8a8e

Hendini21 commented 4 years ago

That is perfect! Thank you so much!