Changeset 153
- Timestamp:
- Sep 2, 2014, 9:31:07 PM (10 years ago)
- Location:
- binary-improvements/webserver
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/webserver/css/style.css
r149 r153 1 html, body, #map { 1 html, body { 2 height: 100%; 3 margin: 0px; 4 padding: 0px; 5 background-color: #230000; 6 } 7 #map { 2 8 height: 100%; 3 9 margin: 0px; -
binary-improvements/webserver/index.html
r150 r153 6 6 <link rel="stylesheet prefetch" href="leaflet/leaflet.css"> 7 7 <link rel="stylesheet" href="css/style.css" media="screen" type="text/css" /> 8 </head> 8 <script type="text/javascript" src="leaflet/leaflet.js"></script> 9 <script type="text/javascript" src="js/jquery-1.11.1.min.js"></script> 10 </head> 9 11 <body> 10 12 <div id="map"></div> … … 13 15 </div> 14 16 15 <script type="text/javascript" src="leaflet/leaflet.js"></script>16 17 <script type="text/javascript" src="js/index.js"></script> 17 18 </body> -
binary-improvements/webserver/js/index.js
r150 r153 124 124 } 125 125 126 var playersOnlineMarkerGroup = L.layerGroup(); 127 var playersOfflineMarkerGroup = L.layerGroup(); 128 126 129 var baseLayers = { 127 130 //"Map": tileLayer … … 129 132 130 133 var overlays = { 131 "Region files": regionLayer 134 "Region files": regionLayer, 135 "Players (online)" : playersOnlineMarkerGroup, 136 "Players (offline)" : playersOfflineMarkerGroup 132 137 }; 133 138 … … 140 145 L.DomUtil.get('pos').textContent = FormatCoord(e.latlng); 141 146 }); 147 148 var playersMappingList = {}; 149 150 var setPlayerMarkers = function(data) { 151 $.each( data, function( key, val ) { 152 var marker; 153 if (playersMappingList.hasOwnProperty(val.steamid)) { 154 marker = playersMappingList[val.steamid].currentPosMarker; 155 marker.setLatLng([val.position.z, val.position.x]); 156 } else { 157 marker = L.marker([val.position.z, val.position.x]).bindPopup(val.name); 158 playersOnlineMarkerGroup.addLayer(marker); 159 playersMappingList[val.steamid] = { online: !val.online }; 160 } 161 if (playersMappingList[val.steamid].online != val.online) { 162 if (val.online) { 163 marker.setOpacity(1.0); 164 playersOfflineMarkerGroup.removeLayer(marker); 165 playersOnlineMarkerGroup.addLayer(marker); 166 } else { 167 marker.setOpacity(0.5); 168 playersOnlineMarkerGroup.removeLayer(marker); 169 playersOfflineMarkerGroup.addLayer(marker); 170 } 171 } 172 val.currentPosMarker = marker; 173 playersMappingList[val.steamid] = val; 174 }); 175 } 176 177 var updatePlayerEvent = function() { 178 $.getJSON( "../api/getplayerslocation") 179 .done(setPlayerMarkers) 180 .fail(function() { 181 console.log("Error fetching players list"); 182 }) 183 .always(function() { 184 window.setTimeout(updatePlayerEvent, 2000); 185 }); 186 } 187 188 window.setTimeout(updatePlayerEvent, 500); 189
Note:
See TracChangeset
for help on using the changeset viewer.