mirror of
https://github.com/owntracks/recorder.git
synced 2026-08-27 16:57:21 +00:00
allow auto-refresh markers
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
var map;
|
||||
var markers = {};
|
||||
var livemarkers = true;
|
||||
|
||||
function initialize() {
|
||||
var lat = 50.098280;
|
||||
@@ -28,6 +29,18 @@ function clog(upd, id, s) {
|
||||
console.log(upd + ": " + ident + " " + s);
|
||||
}
|
||||
|
||||
/*
|
||||
* Close all the infowindows in the `markers' object, and then open the
|
||||
* infowindow in the specified marker.
|
||||
*/
|
||||
|
||||
function refreshmarkers(m) {
|
||||
for (var k in markers) {
|
||||
markers[k]['infowindow'].close();
|
||||
}
|
||||
m['infowindow'].open(map, m);
|
||||
}
|
||||
|
||||
/*
|
||||
* `loc' is a location object obtained via Websockets from the recorder
|
||||
*/
|
||||
@@ -54,6 +67,9 @@ function map_marker(loc)
|
||||
|
||||
/* Grab the InfoWindow of this marker and change content */
|
||||
m['infowindow'].setContent(loc.description);
|
||||
if (livemarkers) {
|
||||
refreshmarkers(m);
|
||||
}
|
||||
} else {
|
||||
clog("NEW", id, JSON.stringify(loc));
|
||||
var circle ={
|
||||
@@ -82,6 +98,9 @@ function map_marker(loc)
|
||||
google.maps.event.addListener(m, "click", function(e) {
|
||||
this['infowindow'].open(map, this);
|
||||
});
|
||||
if (livemarkers) {
|
||||
refreshmarkers(m);
|
||||
}
|
||||
|
||||
markers[id] = m;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user