(Making an Uber like app) I wanna make a global marker for all drivers will be registered on my app with the name shown

If you use an emulator you cannot use the LocationSensor. The emulator does NOT have the required hardware to use the gps. So from now own, test with a real device.

As mentioned in the tutorial "The Blocks determine how frequently the location sensor will attempt to achieve a fresh satellite fix (Using values lower than 30 seconds has limited value) and link the LocationSensor to the Map component."

The LocationChanged block is used to call setLocationStore. If your cell phone is resting on your desk, it is not moving is it so why do you expect it to tell you it has triggered a movement.

Keep trying, you are making progress to learn how the CloudDB works (your FirebaseDB works in a similar way). If you set your device data on (so it does not depend on wifi to access the OpenStreetMap and database) and go outside for a walk, your device will update much more frequently. Remember to set StayAwake so you device Screen does not close or you will loose updates while it is closed.

1 Like

What is the problem with my blocks please if I wanna make all opened customers and drivers seeing each others on the app map as markers with their distance by metres?
and each one has his name in the tab from the tinydb


here are the blocks

image

image

image

Any help here please!

lets check my blocks to fix any issues in

I see you trying to use location sensor results in a permission granted event.

That's the wrong event.

Try the location changed event.

Also, your markers will grow without limits, so there is no point trying to number them in your blocks.

Learn tables.

i just copied that blocks just changed the name and the data store

so do you mean to adjust blocks like that or lets show me exactly what to do to not to miss any other issues

You need to learn to code to build your Uber like app. It is not possible to slightly mofify the CloudDB / Location Marker Tutorial. The tutorial uses routines and examples that can be used in the NEW app you code.

Here is what I suggest:

  • build a test app that does not use a LocationSensor that will let you decide how you want to handle the different things you need to do in your app. If you do not initially use a LS you can make the basic parts more simply.
  • I expect you will want to make an example of how you will handle drivers, customer, calculate distance to customer (routine of one way shown in tutorial), etc

-You might want to make a list or csv: like this:
1,Mustafa,11111111,42.36646,-71.11139\n
2,Ahmed,2222222222,42.35137,-71.11377\n
3,Abraham,3333333333,42.36957,-71.08035\n
4,Steve ,4444444444,42.36801,-71.11459

containing Marker Number, Name, phone number, home latitude, home longitude to place in driver's Marker nearest the customer or number of open seats available in the driver's vehicle and anything else the driver should share with the customer.

  • Here are some simple possibilities to handle drivers:

  • if you have a List of drivers (name, coordinates, availability, phone contact) in your firebase it is easy to determine which is the nearest available driver. Determine the nearest to the user (customer) and post only the nearest driver available as Marker1 to show the driver location on your map. Calculate either straight line distance between the customer and driver or more complexly using the Navigate tool to determine nearest driver. Straight line distance should be good in most instances and not significantly different than road driving distance.

  • alternatively post the Markers for all the drivers on the Map.

  • just determine the nearest available driver to the customer. Provide the customer with the drivers name, distance and phone number. You don't even have to have a map to provide the info the customer needs to identify.

  • it is possible to use circles on the map to show the distance of all the drivers available and various other schemes. Most other options will just use up more of your realtime database time to post fancy things on the Map.

When you get one part working save it as a separate project. Keep marking individual parts work, then combine them to make the app you want. To do that you will have to experiment.

This is a long holiday here. I am visiting with my grandchild so sorry I can't be more specific as programming is not what I expect to do for the next week through New Year.

ok thanks for you reply, have a good holiday

You can try something like this @mustafaalbasel

Sorted Driver Distance Matrix -
shortestDistanceFromCustomer.aia (12.6 KB)

The example I use with a CloudDB. You can do something similar with your FirebaseDB or Spreadsheet. For the example I did not use a LocationSensor to make the testing easy. A fixed presentLatitude,presentLongitude ( 42.35914 , -71.09361 ) was used instead to show the customer. The location is shown with a red marker. You can later set the location to the LS coordinates (your job).

  • if you have a List of drivers (place holder for distance, driver number, name, phone contact, coordinates, availability, number of passengers that can be carried) in your firebase it can be easy to determine which is the nearest available driver. Determine the nearest to the user (customer) and post only the nearest driver available as Marker1 to show the driver location on your map. Calculate either straight line distance between the customer and driver( or more complexly using the Navigate tool) to determine nearest driver. Straight line distance should be good in most instances and not significantly different than road driving distance.

  • I've also was able to post the Markers for all the drivers using Run time Markers (with slightly different code) using a diffferent example. Posting all the driver Markers can get messy and may be slow on the OSM map server.

  • just determine the nearest available driver to the customer. Provide the customer with the drivers name, distance and phone number and other data like number of seats available. You don't even have to have a map to provide the info the customer needs to identify.

  • Label5 displays the distances in km. for all the drivers. Presently set to Visibility false.

  • Label6 displays all the driver info (not pretty) and the distance from the customer. Presently set to Visibility false.

  • Lable7 displays the distance from the driver nearest the customer in km.

UdriversSorted.csv (168 Bytes)
0,1,Mustafa,11111111,42.36646,-71.11139\n
0,2,Ahmed,2222222222,42.35137,-71.11377\n
0,3,Abraham,3333333333,42.36957,-71.08035\n
0,4,Steve,4444444444,42.36801,-71.11459

Is this what you wanted to know? :thinking:

thanks so much for your effort, i will try to check it but lets help me about that
i see you are getting the locations from the csv file or sheets but how can i adjust blocks to get locaions from the firebase instead of the csv file and that are my tags
you can advice me to change the tag if needed

and what can i add here in the missing blck ?

You do not need to add anything. I just works without the empty block. :slightly_smiling_face:

You need to do the changes.

To work in the example you need six items
where 0 is a temporary value, 1 is a driver number, Mustafa is a driver name, 1111111111 is a phone number followed by the driver's coordinates.

0,1,Mustafa,11111111,42.36646,-71.11139
0,2,Ahmed,2222222222,42.35137,-71.11377
0,3,Abraham,3333333333,42.36957,-71.08035
0,4,Steve,4444444444,42.36801,-71.11459

looks close to what you already have in your database. :thinking:

ok but lets show me the block of the global num+1
to make the sequence
1
2
3

111111111
22222222
33333333
44444444
and lets let me know how can i usefirebase instead of the csv file and i will try, thanks in advance

1,2,3,4 driver numbers are entered manually.

I recommend you use some of your data and modify it to look like the example data,
then run the example with the data you modified.

but when i dont wanna a fixed location so drivers are moving everywhere so i wanna an updated location so the data will be always updated so when the customer search for the nearest one or we can say like public markers if the customer searched by the app name which will be in all users tags so all markers has the app name will be appeared and he can choose whatever he want so i can add anything manually

I did not use a LocationSensor to make the testing easy. A fixed presentLatitude,presentLongitude ( 42.35914 , -71.09361 ) was used to show the customer. The customer location is shown with a red marker. Set the location LS coordinates (your job) of each user to the presentLatitude,presentLongitude . This is your app, not mine. I cannot provide advice other than I assume your firebase coordinates are the updated coordinates for each driver.

Take some time and see how my example works. Run the example app and make it work for you in your app.. How are you updating the driver's location now?

like that


@mustafaalbasel

Try this instead. :thinking:

Modified example with LocationSensor and ability to display ALL the driver's as Run time Markers

This is just the code required to use the LocationSensor to display the 'passenger/customer' location on the map

All of this is done for you in the New aia Some variables have been 'renamed' to help identify their functions. :slightly_smiling_face:
driverSelectionExample.aia (15.3 KB)

Happy New Year! Now make the example work with your Firebase data.

thanks so much for your effort, really appreciate it,
Lets show me what can i do with my aia file to make it worked, as still a beginner and i tried another way before so am a pretty confused, here is my aia lets fix the blocks and show me how is works, thanks in advance, BTW I used the google sheet instead of firebase to make the file fit with yours that you
driverSelectionExample2.aia (17.3 KB)
added

Sorry, I can't understand your coding. You appear to want to export

0
No (driver number)
Name
phone number
home latitude
home longitude

In the example driver permanent database this will always be

place holder for distance to cusomer (always 0),driver number (assigned manually in the example), driver name, phone number, home latitude, home longitude
0,1,Mustafa,11111111,31.44561,31.67933
0,2,Ahmed,2222222222,42.35137,-71.11377
0,3,Abraham,3333333333,42.36957,-71.08035
0,4,Steve,4444444444,42.36801,-71.11459

The app will change the some databbase information when you ask it to find distance to something like
2.1,1,Mustafa,11111111,31.44598,31.67974
where 2.1 represents the distance in kilometers from the customer, driver number, phone number , presentLatitude (from the LS), presentLongitude (from the LS). It has to sort based on the present coordinates.


You don't need to use the csv, you already have a ListOfLists it appears, it just needs to be set so the columns are the same as above I think.

Perhaps if you show several customers in your GoogleSheets example I can modify the example to use that data. You appear to be trying to fix everything at once. That is complex and impossible for me to understand (possibly as my example is difficult for you to understand :thinking: :frowning_face:

nope i dont want a permanent location, i need an updated location for all by moving so lets adjust the aia file you sent and lets add the firebase or a google sheet to store locations and to get locations from
and all i need that the marker and the tag has the app name (Waslalna) and the driver or customer name for which the checkbox will be enabled which is checkbox customer or checkbox driver and i will make it fit to my app,
thanks in advance for your help
i will make the location initialized for the driver to be always on while opening the GPS and will make the customer when press on find driver btn so the location will be updated to show all drivers markers to select which is nearest to him