Real time tracking with maps

Could you get the user to do the refresh ?

So set a timer so that the page “times out” after say … 10 seconds. Then the user presses a button and it refreshes ?

Although maps do update “on their own” when adding new markers. Wonder why they don’t when the address is updated ?. Maybe you could exploit this by deleting and recreating each time ? You could run some sort of CRON job to pull the markers and call a Bubble API ?

Interested to see this pans out.

Just out of curiosity here, when you say you assign the current geographical position to a bus, that bus has some sort of mobile device with an internet/location connection that detects the location?

Thanks very much for the help.

I haven’t yet got the time to site and try it out, but I’ll experiment with your approach.

I also found the Code-free startup course that might have what I need but haven’t purchased it yet.

The idea is to have the driver start the gps tracking on a phone before starting driving.

That’s an interesting approach, refreshing the page I don’t think would be ideal. But remaking the map it might be possible.

I’ll try to work on this way of doing too. I’m also interested if I can make it work with some Javascript/HTML code.

What about this CRON job you mention? I’m not familiar with it, could you give a brief explanation so I can search how to work with it?

I’ll sure post here on the forum when I make some progress, I haven’t worked much on the app these last days due to work and college. But after I figure it out I’m going to write how I did it so people can get to the solution easier in case they need it too.

1 Like

Are you certain that the map doesn’t already auto update?

I did a small experiment, using two edit fields auto-bound to a database thing’s fields, manually setting a new address as a position. The map auto updated, even when open on a different browser.

(I edited the time delay after recording this, it was more like a second or two between updates, due to manually editing the address)

^ would be my guess too. It works for additions to the database, so don’t see why updates wouldn’t work but I didn’t have time to test it as well.

Consider that updating a field with auto-binding doesn’t add to the workflow count, and neither does loading / auto-updating markers on a map.

Using javascript, can set the geographic position from Bubble into the Input field, and this auto-bound with a field in the database, updates the position. Wrap this in a Bubble timer event, this method is viable, and I just tested it, pretty fun walking down to the park and seeing my position update on a map.

You’d want to check that the position has changed before updating it, and have a generous interval so as not to spam the servers.

Also, it might be more efficient to update via lat/long, rather than address, if you can figure out how to get that into an auto-bound field.

I wasn’t getting the auto update simply by setting the address as a dynamic value.

I’ll try your last tip then since it seemed to work. Thanks for the feedback

did you tested it on a new app? Would you mind sharing it so I could take a look at the workflow?

Sure thing … I added the check for location not changed, to reduce spamming.
editor
runtime

2 Likes

Thanks. You’re awesome!

1 Like

Hey @mishav,

Do you know if it’s possible to track the route taken by the bus and save that data.

For example:

  • bus clicks start route
  • will bus is driving, app tracks the route
  • saves route data
  • able to view the route taken by each bus

Would you know how to do this.

Thank in advance,
Jonathon.

Probably the nicest way to do it is integrate with Google maps “Direction Services” API. Maybe the Bubble Google Map API could be leveraged, or maybe it’d need a new implementation.

1 Like

I know this post is fairly old, but im hoping you can tell me what mechanism is auto-binding to the database for map position updates? I ended up using a workflow to create the position database field.

Thanks

L

It is an Input element, its value (geographic position) is altered by javascript.

A “Every ten seconds” workflow alters a custom state, which is referenced in a HTML element as a dynamic expression. This change causes the HTML to be re-evaluated, including the current geographic position, another dynamic expression. The HTML contains javascript to update the Input element if needed.

It isn’t very kind on resources … effectively queries Google’s geographic API every ten seconds for every user viewing the page.

Thanks! Its definetly spamming the google api

On the topic of javascript and maps, does the Bubble map already include the javascript library? I don’t see it listed in the Plugin tab under the Google Maps Extended plugin, but when I add the library to the heading in the settings tab, the console throws errors saying that the library is being requested too many times. I am trying to use getZoom() to get the updated zoom whenever a user zooms in or out of the map. I hope to use the zoom to dynamically change the area displayed in the map, which will serve as a filter for a repeating group (there will be some calculating with the help of ESRI data). Essentially, I want the repeating group to dynamically display any markers visible in the map view.

The other option it’s to use a how tracker with a sim.card on each bus, then have that information send to a traccar server and access the traccar server from bubble using its API.

1 Like

Can anyone please recap on how to track drivers live ? I am very new at this and I do not know how to proceed.