Changeset 315 for binary-improvements/webserver/js
- Timestamp:
- Jan 31, 2018, 2:52:42 PM (7 years ago)
- Location:
- binary-improvements/webserver/js
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/webserver/js/leaflet.layer.sdtdtiles.js
r249 r315 4 4 var tileLayer = L.tileLayer('../map/{z}/{x}/{y}.png?t={time}', { 5 5 maxZoom: isMiniMap ? mapinfo.maxzoom : mapinfo.maxzoom + 1, 6 minZoom: isMiniMap ? 0: Math.max(0, mapinfo.maxzoom - 5),6 minZoom: isMiniMap ? -1 : Math.max(0, mapinfo.maxzoom - 5), 7 7 maxNativeZoom: mapinfo.maxzoom, 8 minNativeZoom: 0, 8 9 tileSize: mapinfo.tilesize, 9 continuousWorld: true,10 tms: true,11 unloadInvisibleTiles: false,12 10 time: initTime 13 11 }); 14 12 15 // TileLayer w/ TMS=true fix for zoomlevel >= 816 tileLayer._getWrapTileNum = function () {17 return L. point(0, 0);13 tileLayer.getTileUrl = function (coords) { 14 coords.y = (-coords.y) - 1; 15 return L.TileLayer.prototype.getTileUrl.bind (tileLayer) (coords); 18 16 }; 17 19 18 20 19 return tileLayer; -
binary-improvements/webserver/js/leaflet.regionlayer.js
r244 r315 4 4 } 5 5 6 var regionLayer = L. tileLayer.canvas({6 var regionLayer = L.gridLayer({ 7 7 maxZoom: mapinfo.maxzoom + 1, 8 8 minZoom: 0, 9 9 maxNativeZoom: mapinfo.maxzoom + 1, 10 10 tileSize: mapinfo.tilesize, 11 continuousWorld: true12 11 }); 13 12 14 regionLayer. drawTile = function(canvas, tilePoint, zoom) {15 var blockWorldSize = mapinfo.tilesize * Math.pow(2, mapinfo.maxzoom - zoom);13 regionLayer.createTile = function(tilePoint) { 14 var blockWorldSize = mapinfo.tilesize * Math.pow(2, mapinfo.maxzoom - tilePoint.z); 16 15 var tileLeft = tilePoint.x * blockWorldSize; 17 16 var tileBottom = (-1-tilePoint.y) * blockWorldSize; 18 17 var blockPos = L.latLng(tileLeft, tileBottom); 19 18 19 var canvas = L.DomUtil.create('canvas', 'leaflet-tile'); 20 canvas.width = mapinfo.tilesize; 21 canvas.height = mapinfo.tilesize; 20 22 var ctx = canvas.getContext('2d'); 21 23 … … 63 65 } 64 66 } 65 67 return canvas; 66 68 } 67 69 -
binary-improvements/webserver/js/map.js
r306 r315 155 155 //measure.addTo(map); 156 156 157 //new L.Control.GameTime({}).addTo(map);157 new L.Control.GameTime({}).addTo(map); 158 158 159 159 if (HasPermission ("webapi.getlandclaims")) { … … 198 198 }); 199 199 200 var openedPopup = null;201 200 var updatingMarkers = false; 202 201 203 map.on ("popupopen", function (event) {204 console.log ("open");205 console.log (event.popup._source);206 openedPopup = event.popup._source;207 });208 map.on ("popupclose", function (event) {209 if (!updatingMarkers) {210 console.log ("close");211 openedPopup = null;212 }213 });214 202 215 203 var setPlayerMarkers = function(data) { 216 var online = 0; 217 var offline = 0; 204 var onlineIds = []; 218 205 updatingMarkers = true; 219 206 $.each( data, function( key, val ) { … … 228 215 : "") 229 216 ); 217 marker.on("move", function ( e ) { 218 if ( this.isPopupOpen () ) { 219 map.flyTo (e.latlng, map.getZoom ()); 220 } 221 }); 230 222 playersMappingList[val.steamid] = { online: !val.online }; 223 } 224 225 if (val.online) { 226 onlineIds.push (val.steamid); 231 227 } 232 228 233 229 oldpos = marker.getLatLng (); 234 if ( playersMappingList[val.steamid].online != val.online || oldpos.lat != val.position.x || oldpos.lng != val.position.z) {230 if ( playersMappingList[val.steamid].online != val.online ) { 235 231 if (playersMappingList[val.steamid].online) { 236 232 playersOnlineMarkerGroup.removeLayer(marker); 233 playersOfflineMarkerGroup.addLayer(marker); 237 234 } else { 238 235 playersOfflineMarkerGroup.removeLayer(marker); 239 } 236 playersOnlineMarkerGroup.addLayer(marker); 237 } 238 } 239 if ( oldpos.lat != val.position.x || oldpos.lng != val.position.z ) { 240 240 marker.setLatLng([val.position.x, val.position.z]); 241 241 if (val.online) { 242 242 marker.setOpacity(1.0); 243 playersOnlineMarkerGroup.addLayer(marker);244 243 } else { 245 244 marker.setOpacity(0.5); 246 playersOfflineMarkerGroup.addLayer(marker);247 245 } 248 246 } … … 250 248 val.currentPosMarker = marker; 251 249 playersMappingList[val.steamid] = val; 252 253 if (val.online) 250 }); 251 252 var online = 0; 253 var offline = 0; 254 $.each ( playersMappingList, function ( key, val ) { 255 if ( val.online && onlineIds.indexOf (key) < 0 ) { 256 var marker = val.currentPosMarker; 257 playersOnlineMarkerGroup.removeLayer(marker); 258 playersOfflineMarkerGroup.addLayer(marker); 259 val.online = false; 260 } 261 if (val.online) { 254 262 online++; 255 else263 } else { 256 264 offline++; 257 }); 265 } 266 }); 267 258 268 updatingMarkers = false; 259 if (openedPopup != null) { 260 openedPopup.openPopup (); 261 } 269 262 270 $( "#mapControlOnlineCount" ).text( online ); 263 271 $( "#mapControlOfflineCount" ).text( offline ); … … 265 273 266 274 var updatePlayerTimeout; 275 var playerUpdateCount = -1; 267 276 var updatePlayerEvent = function() { 268 $.getJSON( "../api/getplayerslocation") 277 playerUpdateCount++; 278 279 $.getJSON( "../api/getplayerslocation" + ((playerUpdateCount % 15) == 0 ? "?offline=true" : "")) 269 280 .done(setPlayerMarkers) 270 281 .fail(function(jqxhr, textStatus, error) {
Note:
See TracChangeset
for help on using the changeset viewer.