diff --git a/def.png b/def.png new file mode 100644 index 0000000..b1a2a13 Binary files /dev/null and b/def.png differ diff --git a/map.html b/map.html index e7ca931..442fc8b 100644 --- a/map.html +++ b/map.html @@ -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]}); } diff --git a/track.png b/track.png new file mode 100644 index 0000000..5acc717 Binary files /dev/null and b/track.png differ diff --git a/traque.js b/traque.js index d24fa13..ee692c6 100644 --- a/traque.js +++ b/traque.js @@ -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 !");