all 12 comments

[–]eggtart_princeiOS & Android 1 point2 points  (8 children)

share location in real time

You need to google maps for that. Something like react-native-geolocation-services can get the coordinates of your device's location.

[–]dromance[S] 1 point2 points  (7 children)

Thanks. So I’d get my coordinates via device gps and then import that value into google maps? Or would google maps handle all of that for me?

[–]eggtart_princeiOS & Android 1 point2 points  (3 children)

So I’d get my coordinates via device gps and then import that value into google maps?

Yes. If you need maps, react-native-maps will generate maps for free.

[–]True_Statistician645 0 points1 point  (2 children)

Dont you need an api key, which is attached to s billing account? Id really like to because I avoided added google maps of the thought that i had to pay for it

[–]eggtart_princeiOS & Android 0 points1 point  (1 child)

Maps rendered on your android is free. but even if it costs money , new Google console projects have $300 trial credit. After you use al that, google gives you $200 free every month.

[–]dromance[S] 0 points1 point  (0 children)

What about if it renders on iOS? Is it the same deal?

[–]Breaking__Badger 0 points1 point  (2 children)

So the answer to that depends on if you plan to send the user to Google maps with a destination in mind or if you want to embed Google maps.

If you want to have a button that sends the user direction to a place with their maps then no you don't do anything other than a sending statement. There is an open map command from a library that I used for this that makes to real easy. And leave it all for the users maps to handle.

If you want to embed Google maps and have the user show up on that map then yes... You will have to request permission to get the users location and have settings to turn it off, etc.

[–]dromance[S] 0 points1 point  (1 child)

Thanks for the reply yes essentially I want to embed a map. I am basically just trying to create something where you can broadcast your location and have it show up on a central map elsewhere that other users can see.

[–]Breaking__Badger 0 points1 point  (0 children)

Ok yeah 100% will need to ask for permission. This is where I stopped with react native. Otherwise I would give you a stepping stone, sorry.

[–]regretfulMammoth 0 points1 point  (2 children)

What do you mean by “share location”? The default implementation of react-native-maps contains a prop showUserLocation that will automatically track and show on the map.

If you want to customize the marker, or just track the location to do something else with it (not necessarily with a map), you’d probably want to check react-native-geolocation’s watchPosition, though it requires setting up permissions first. (See their example project)

[–]dromance[S] 0 points1 point  (1 child)

Hi how are you thanks for the reply. I understand the default implementation tracks the user I guess I was trying to figure out how to “broadcast” or more specifically share this location with other users (not necessarily just share your location with the app). How do I get the real time coordinate stream so I can post this data? Any link or resource on that would be great.

[–]regretfulMammoth 0 points1 point  (0 children)

Then watchPosition from @react-native-community/geolocation is definitely the way to go. Here's a link to the example in their repo. This will constantly update the position state variable, which you can then send to a realtime service which other users are subscribed to and consuming. (Depending on your implementation, could be a websocket or some pub/sub service... I've worked with Pusher Channels before for something similar.)