I have read up on GPS Real time tracking and found out several things about it, mostly requiring PHP, zope and a database to store the incoming data. Some other methods uses ajax with relations to PHP.
As regards to my question, is it possible to do so with just html and JS, using markers or anything else to populate the Google Map when you move anywhere in the city? Need some help on this, Thanks!
Yes, it is possible. Most browsers in the latest smartphones have implemented the W3C Geolocation API:
Using the Geolocation API to plot a point on Google Maps, will look something like this:
The above will only gather the position once, and will not auto update when you start moving. To handle that, you would need to keep a reference to your marker, periodically call the
getCurrentPosition()method, and move the marker to the new coordinates. The code might look something like this:Now if by tracking you mean that you should also store this information on a server (so that someone else could see you moving from a remote location), then you’d have to send the points to a server-side script using AJAX.
In addition, make sure that the Google Maps API Terms of Use allow this usage, before you engage in such a project.
UPDATE: The W3C Geolocation API exposes a
watchPosition()method that can be used instead of thesetTimeout()mechanism we used in the above example.