added invisiblity support #24

Merged
sgay merged 2 commits from 3-client-invisibility-is-not-implemented into master 2022-09-12 09:40:47 +02:00
2 changed files with 23 additions and 3 deletions
Showing only changes of commit c97767b8f9 - Show all commits

BIN
invi.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

View file

@ -59,6 +59,16 @@
})
];
var self_icons = icons;
var self_invisible =
L.icon({
iconUrl: 'invi.png',
iconSize: [10, 10],
iconAnchor: [5, 5],
popupAnchor: [5, 5],
//shadowUrl: 'my-icon-shadow.png',
//shadowSize: [68, 95],
//shadowAnchor: [22, 94]
});
//////////////////////////////////////////////////////////////////////////////
// INIT MAP
@ -94,10 +104,18 @@
colors[data.id] = data.color;
if(data.id in markers){
if(data.id == id)
if(data.color == -1)
markers[data.id].setIcon(self_invisible);
else
markers[data.id].setIcon(self_icons[data.color]);
else
if(data.color == -1)
markers[data.id].setOpacity(0);
else{
markers[data.id].setOpacity(1);
markers[data.id].setIcon(icons[data.color]);
}
}
});
socket.on("moving", function(data){
@ -111,6 +129,8 @@
else
icon = icons[colors[data.id]];
markers[data.id] = L.marker(data.position, {"icon": icon}).addTo(map);
if(data.id == id)
markers[data.id].setZIndexOffset(10000);
if(data.id in names)
markers[data.id].bindPopup(names[data.id]);
} else{