Arquisoft / radarin_en2b

0 stars 2 forks source link

Map view #69

Closed saruedreams closed 3 years ago

saruedreams commented 3 years ago

Showing a map with different markers that specify where the user is located, and where the nearby friends are too.

The API chosen for this is the one from Google Maps.

saruedreams commented 3 years ago

As we were having trouble with getting the nearby friends list for creating the markers, we have chosen to just show the current position of the logged user.

The other functionality could be added later if we find a solution.

saruedreams commented 3 years ago

I solved the problem regarding getting the nearby friends list, however, I was not able to solve the other problems.

Found no solution to adding the markers for the friends in the map. The reason is that the map component renders before the data (the nearby friends list) is computed, therefore getting an error because the list is empty. I tried delaying the rendering of the map but found out it is not possible, as React makes the computations while rendering, but does not wait for them to render in any situation, so the render usually occurs before the data is ready.

Knowing that, I tried having the data ready before calling the map, but it did not work either. My first idea was to create some json file with the list of friends and their coordinates, but it needs to be periodically updated and be always ready before the map needs to render. I also tried having some array as global variable which updates when needed. Lastly, I tried creating an empty map and adding the markers afterwards.

Tried using React Components with componentDidMount, also useState and useEffect. However, these made geolocation to not work in time, therefore always getting the "Geolocation is not active" message instead of showing some map.

At this point, I decided to leave the map as is, and focus in other functionality. If someone thinks they can solve this, feel free.