Merge branch '2-client-team-names-are-not-shown' into 'master'

ajouté popups

Closes #2

See merge request sgay/traque!1
This commit is contained in:
Sylvain Gay 2022-09-09 17:15:55 +02:00
commit 6235e0c14e

View file

@ -85,8 +85,8 @@
socket.on("setName", function(data){ socket.on("setName", function(data){
console.log("setName", data); console.log("setName", data);
names[data.id] = data.name; names[data.id] = data.name;
//if(data.id in markers) if(data.id in markers)
// markers[data.id].setIcon(icons[data.color]); markers[data.id].bindPopup(data.name);
}); });
socket.on("changeColor", function(data){ socket.on("changeColor", function(data){
@ -111,6 +111,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(data.id in names)
markers[data.id].bindPopup(names[data.id]);
} else{ } else{
markers[data.id].setLatLng(data.position); markers[data.id].setLatLng(data.position);
} }