CheshireCat
Posts: 6
Joined: Sun Jun 17, 2012 10:19 pm

Show mobile web _server_ location on a map

Tue May 07, 2019 9:13 am

There are plenty of examples of how to show a web client's locations on a map but so far, I have failed to find any code snippets presenting a server's location.

The project uses a Pi3B+ with an Adafruit Ultimate GPS HAT. The GPS is working and presents plausible data though gpsmon and cgps. The next stage is to present the location so that a client can see it on a map with updates at an appropriate frequency. The server moves no faster than 15mph/24kph so updates can be at, say, 15 second intervals. As it can't go very far, a local cache of Open Street Map tiles would be fine. The Pi is running Stretch Lite 2019-04-08 and currently has lighttpd as a web server but that could easily be changed.

My current thinking is to build and update an xml file in tmpfs that the client can poll but I would rather not re-invent the wheel if there is a good design available already. Pointers to useful code snippets, applications or gotchas would be much appreciated.

Thanks in advance!


CheshireCat
Posts: 6
Joined: Sun Jun 17, 2012 10:19 pm

Re: Show mobile web _server_ location on a map

Tue Jun 11, 2019 8:55 pm

Server Sent Events have been the key to getting this project going. Every second (for example), the server sends a message with its location to the client, which can process the location data using standard HTML5 features. See
https://www.w3schools.com/html/html5_se ... events.asp

The application can then handle the location data in the same way that it would handle location data generated by an on-board GPS. The clients will normally be phones and tablets, which is just as well because the only browsers that don't handle Server Sent Events are those from Microsoft. Bizarrely, MicroSoft ASP /will/ create Server Sent Events.

CheshireCat
Posts: 6
Joined: Sun Jun 17, 2012 10:19 pm

Re: Show mobile web _server_ location on a map

Tue Jun 11, 2019 9:01 pm

Apologies @BespokeTech - I missed your response.
I'll bear Traccar in mind if the homebrew doesn't deliver adequately.
Thank you.

Return to “Advanced users”