This commit is contained in:
Sylvain Gay 2022-09-14 14:14:52 +02:00
parent b0ccf9284d
commit 2d229fc7bc
4 changed files with 12 additions and 18 deletions

View file

@ -57,7 +57,7 @@
markers[data.id].setOpacity(0);
else
if(data.color == -1)
markers[data.id].setIcon(icon_invisible);
markers[data.id].setIcon(self_invisible);
else
markers[data.id].setIcon(icons[data.color]);
}

View file

@ -26,7 +26,7 @@
<div id="map"></div><br/>
<input id="name"/><button id="setName">Set team name</button><br/>
<input id="message"/><button id="sendMessage">Send message to base</button><br/>
<input id="message"/><button id="sendMessage">Enter code</button><br/>
<script type="text/javascript">
//////////////////////////////////////////////////////////////////////////////

View file

@ -13,19 +13,13 @@ var icons = [
iconUrl: 'def.png',
iconSize: [10, 10],
iconAnchor: [5, 5],
popupAnchor: [5, 5],
//shadowUrl: 'my-icon-shadow.png',
//shadowSize: [68, 95],
//shadowAnchor: [22, 94]
popupAnchor: [5, 5]
}),
L.icon({
iconUrl: 'track.png',
iconSize: [10, 10],
iconAnchor: [5, 5],
popupAnchor: [5, 5],
//shadowUrl: 'my-icon-shadow.png',
//shadowSize: [68, 95],
//shadowAnchor: [22, 94]
popupAnchor: [5, 5]
})
];
var self_icons = icons;
@ -34,10 +28,7 @@ var self_invisible =
iconUrl: 'invi.png',
iconSize: [10, 10],
iconAnchor: [5, 5],
popupAnchor: [5, 5],
//shadowUrl: 'my-icon-shadow.png',
//shadowSize: [68, 95],
//shadowAnchor: [22, 94]
popupAnchor: [5, 5]
});
//////////////////////////////////////////////////////////////////////////////
@ -48,7 +39,7 @@ var map;
function setup_map(){
map = L.map('map').setView([48.8448, 2.3550], 13);
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
L.tileLayer('https://stamen-tiles.a.ssl.fastly.net/toner/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '© OpenStreetMap'
}).addTo(map);
@ -88,6 +79,11 @@ function setup_socket_common(){
if(data.id in markers)
markers[data.id].bindPopup(data.name);
});
socket.on("remove", function(data){
if(data.id in markers)
markers[data.id].remove();
});
}
function setup_socket_not_admin(){

View file

@ -143,10 +143,8 @@ io.sockets.on('connection', function(socket){
equipes[i].emit('setName', {"id": socket.id, "name": d.name});
});
socket.on("disconnect", function(_){
socket.shown = false;
socket.color = -1;
for(i in equipes)
equipes[i].emit('changeColor', {"id": socket.id, "color": -1});
equipes[i].emit('remove', {"id": socket.id});
});
socket.emit('yourId', {"id": socket.id});