I'm currently working on a ride-sharing web app for a local business through my college and I'm new to this project that has been ongoing for a few terms. Right now, riders can see their ongoing rides on a map, but the location updates every few seconds, which isn't very smooth—it jumps rather than flowing. Our client wants to have real-time location updates similar to what you see on Google Maps. I've done some research but I'm not sure if I'm looking in the right places or using the right terms. Is it possible to make the location updates real-time?
1 Answer
You might be looking at the wrong features! To get real-time location updates, you'll need to check into the Geolocation API, Websockets, and Server-sent events. Use the Geolocation API to track the ride’s position, then send that info to your server using Websockets, and finally push the location updates to the rider with Server-sent events. If it's just for the rider's own location, the Geolocation API alone could be enough—it should update smoothly!
Exactly! There's really no need for the round trip to the server if all you're tracking is the rider's location. It's all happening on their device!