Issue #3 -- implemented invisibility
This commit is contained in:
parent
ae58a69b02
commit
370e8bdedb
2 changed files with 15 additions and 1 deletions
12
map.html
12
map.html
|
@ -59,6 +59,7 @@
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
var self_icons = icons;
|
var self_icons = icons;
|
||||||
|
var self_invisible_icon = icons[1];
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
// INIT MAP
|
// INIT MAP
|
||||||
|
@ -91,8 +92,17 @@
|
||||||
|
|
||||||
socket.on("changeColor", function(data){
|
socket.on("changeColor", function(data){
|
||||||
console.log("changeColor", data);
|
console.log("changeColor", data);
|
||||||
|
if(data.id in colors && colors[data.id] == -1 && data.id in markers)
|
||||||
|
markers[data.id].addTo(map);
|
||||||
colors[data.id] = data.color;
|
colors[data.id] = data.color;
|
||||||
|
if(data.color == -1){
|
||||||
if(data.id in markers){
|
if(data.id in markers){
|
||||||
|
if(data.id == id)
|
||||||
|
markers[data.id].setIcon(self_invisible_icon);
|
||||||
|
else
|
||||||
|
markers[data.id].remove();
|
||||||
|
}
|
||||||
|
} else if(data.id in markers){
|
||||||
if(data.id == id)
|
if(data.id == id)
|
||||||
markers[data.id].setIcon(self_icons[data.color]);
|
markers[data.id].setIcon(self_icons[data.color]);
|
||||||
else
|
else
|
||||||
|
@ -111,6 +121,8 @@
|
||||||
else
|
else
|
||||||
icon = icons[colors[data.id]];
|
icon = icons[colors[data.id]];
|
||||||
markers[data.id] = L.marker(data.position, {"icon": icon}).addTo(map);
|
markers[data.id] = L.marker(data.position, {"icon": icon}).addTo(map);
|
||||||
|
if(colors[data.id] == -1)
|
||||||
|
markers[data.id].remove();
|
||||||
if(data.id in names)
|
if(data.id in names)
|
||||||
markers[data.id].bindPopup(names[data.id]);
|
markers[data.id].bindPopup(names[data.id]);
|
||||||
} else{
|
} else{
|
||||||
|
|
|
@ -65,6 +65,8 @@ io.sockets.on('connection', function(socket){
|
||||||
if(socket.shown)
|
if(socket.shown)
|
||||||
for(i in equipes)
|
for(i in equipes)
|
||||||
equipes[i].emit('moving', {"id": socket.id, "position": d.position});
|
equipes[i].emit('moving', {"id": socket.id, "position": d.position});
|
||||||
|
else
|
||||||
|
socket.emit('moving', {"id": socket.id, "position": d.position});
|
||||||
});
|
});
|
||||||
socket.on('changeColor', function(d){
|
socket.on('changeColor', function(d){
|
||||||
socket.color = d.color - 0;
|
socket.color = d.color - 0;
|
||||||
|
|
Loading…
Reference in a new issue