I want to create an app like uber

Hello developers, I am looking for your help with the code of my application, an Uber type app.

The problem I have is how can I review the locations of the drivers to select the closest one to the user (I use Firebase)

I already have a list viewer that shows the active drivers and another list with all the locations together but how do I check one by one to see which driver is closest.

structure of my list
Captura de pantalla (20)

at the end of the project i will make a tutorial step by step how to create an app for delivery or similar to uber.

I thank you for your support.

If you want to be part of the project, you can join and at the end of the project I will see a way to reward your time and support, greetings from Mexico.

1 Like

The simplest but inaccurate solution would be to consider the Euclidean distance, because the surface of the earth is curved and the fact that the cab won’t arrive in a straight line from wherever it is to the user.
An alternate solution, still inaccurate, would be the Taxi Cab distance.
Slightly better in theory but still inaccurate due to not accounting for roads would be the Great Circle distance.
For something reasonably accurate you would need to get a graph to represent the road network, place the drivers and the user on the graph and then apply Dijkstra, A* or another search algorithm to find the shortest path and the respective path lengths to find the shortest driver.

TL;DR: The true solution involves quite a bit of DSA and you need to manually map out the roads or find an API to do it for you.

1 Like

I think I probably didn’t explain myself well;

I already have most of the application developed,I use firebase to store the data As shown in the first capture.

Likewise, I already have the method to obtain the list of the id’s active drivers along with its latitude and longitude and what is failing me in the blocks, it is like checking the latitude and longitude of the drivers one by one to see which one is closest to the user.

This screenshot shows how I obtain the ID of the active drivers in green and their respective latitude and longitude separately in gray.

You can try any of these extensions

1 Like