Question

I have an application for android for my business that automatically tracks the users GPS location. This location is then stored in a database and shown on a Google Maps using API V3 with HTML and PHP.

We are using this for a long time now and it works perfectly, the only thing i can't get to work is the updating the markers live without refreshing the page. I've been looking for a long time now and hope that someone here can help me.

Was it helpful?

Solution

It's been a while so I don't know if you are still looking for an answer.

Create a function that deletes all current markers and then adds them. You need to loop through all map items by interrogating the map.

Create a php file that returns the current marker locations. This will be basically Javascript that you can query which has an array of locations.

Finally you need a timeout loop in Javascript, something like

function timeout() {
    setTimeout(function () {
    // Read new markers in via AJAX
    // Delete markers
    // Add Markers
       timeout();
    }, 1000);
}

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top