added image and made it work with 1 client

This commit is contained in:
catvayor 2022-09-09 14:43:41 +02:00
parent e7bf3c4684
commit 17b4df5c4b
4 changed files with 28 additions and 16 deletions

BIN
def.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

View file

@ -35,11 +35,30 @@
protocol+"://"+server+":"+port);
var id = -1;
var names = {};
var colors = {};
var markers = {};
var icons = { /* TODO */ };
var self_icons = { /* TODO */ };
var names = [];
var colors = [];
var markers = [];
var icons = [
L.icon({
iconUrl: 'def.png',
iconSize: [10, 10],
iconAnchor: [5, 5],
popupAnchor: [5, 5],
//shadowUrl: 'my-icon-shadow.png',
//shadowSize: [68, 95],
//shadowAnchor: [22, 94]
}),
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]
})
];
var self_icons = icons;
//////////////////////////////////////////////////////////////////////////////
// INIT MAP
@ -92,8 +111,9 @@
else
icon = icons[colors[data.id]];
markers[data.id] = L.marker(data.position, {"icon": icon}).addTo(map);
} else
markers[data.id].setLatLng(position);
} else{
markers[data.id].setLatLng(data.position);
}
});
//////////////////////////////////////////////////////////////////////////////
@ -115,7 +135,6 @@
// GEOLOCALISATION
function geoLoc_success(pos) {
console.log(pos);
socket.emit("geoLoc", {"position": [pos.coords.latitude, pos.coords.longitude]});
}

BIN
track.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 590 B

View file

@ -60,32 +60,25 @@ io.sockets.on('connection', function(socket){
socket.shown = true;
socket.color = 0;
socket.on('geoLoc', function(d){
console.log("new loc :", d);
socket.position = d.position;
if(socket.shown)
for(i in equipes)
equipes[i].emit('moving', {"id": socket.id, "position": d.position});
});
socket.on('changeColor', function(d){
console.log(d);
socket.color = d.color - 0;
console.log("new color2");
if(d.color == -1)
socket.shown = false;
else{
console.log("new color3");
if(!socket.shown)
for(i in equipes)
equipes[i].emit('moving', {"id": socket.id, "position": socket.position});
socket.shown = true;
console.log("new color4");
}
for(i in equipes)
equipes[i].emit('changeColor', {"id": socket.id, "color": d.color});
console.log("new color5");
});
socket.on('setName', function(d){
console.log("new name");
socket.name = d.name;
for(i in equipes)
equipes[i].emit('setName', {"id": socket.id, "name": d.name});
@ -95,4 +88,4 @@ io.sockets.on('connection', function(socket){
console.log("Launch server");
server.listen(9000);
console.log("Running!");
console.log("Running !");