Changeset 179 for binary-improvements/webserver/js
- Timestamp:
- Sep 8, 2014, 5:29:23 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/webserver/js/index.js
r178 r179 60 60 // =============================================================================================== 61 61 // Map and basic tile layers 62 63 var tileTime = new Date().getTime(); 62 64 63 65 var map = L.map('map', { … … 75 77 continuousWorld: true, 76 78 tms: true, 77 unloadInvisibleTiles: true,78 time: function() { return new Date().getTime(); }79 unloadInvisibleTiles: false, 80 time: function() { return tileTime; } 79 81 }); 80 82 … … 86 88 continuousWorld: true, 87 89 tms: true, 88 unloadInvisibleTiles: true,89 time: function() { return new Date().getTime(); }90 unloadInvisibleTiles: false, 91 time: function() { return tileTime; } 90 92 }); 91 93 … … 155 157 156 158 157 // =============================================================================================== 158 // Overlays 159 160 // =============================================================================================== 161 // Reload control 162 163 L.Control.ReloadTiles = L.Control.extend({ 164 options: { 165 position: 'bottomleft' 166 }, 167 168 onAdd: function (map) { 169 var name = 'control-reloadtiles', 170 container = L.DomUtil.create('div', name + ' leaflet-bar'); 171 172 this._map = map; 173 174 this._reloadbutton = this._createButton( 175 "Reload tiles", "Reload tiles", 176 name + "-btn", container, this._reload, this); 177 178 return container; 179 }, 180 181 onRemove: function (map) { 182 }, 183 184 _reload: function (e) { 185 tileTime = new Date().getTime(); 186 tileLayer.redraw(); 187 tileLayerMiniMap.redraw(); 188 }, 189 190 _createButton: function (html, title, className, container, fn, context) { 191 var link = L.DomUtil.create('a', className, container); 192 link.innerHTML = html; 193 link.href = '#'; 194 link.title = title; 195 196 var stop = L.DomEvent.stopPropagation; 197 198 L.DomEvent 199 .on(link, 'click', stop) 200 .on(link, 'mousedown', stop) 201 .on(link, 'dblclick', stop) 202 .on(link, 'click', L.DomEvent.preventDefault) 203 .on(link, 'click', fn, context) 204 .on(link, 'click', this._refocusOnMap, context); 205 206 return link; 207 } 208 209 }); 210 211 new L.Control.ReloadTiles({ 212 }).addTo(map); 213 214 215 // =============================================================================================== 216 // Coordinates control 217 // <div id="info"> 218 // MouseCoords: <span id="pos"></span> 219 // </div> 220 221 L.Control.Coordinates = L.Control.extend({ 222 options: { 223 position: 'bottomleft' 224 }, 225 226 onAdd: function (map) { 227 var name = 'control-coordinates', 228 container = L.DomUtil.create('div', name + ' leaflet-bar'); 229 230 container.innerHTML = "- N / - E" 231 232 this._map = map; 233 this._div = container; 234 235 map.on('mousemove', this._onMouseMove, this); 236 237 return container; 238 }, 239 240 onRemove: function (map) { 241 }, 242 243 _onMouseMove: function (e) { 244 this._div.innerHTML = FormatCoord(e.latlng); 245 } 246 247 248 }); 249 250 new L.Control.Coordinates({ 251 }).addTo(map); 252 253 254 255 // =============================================================================================== 256 // Overlays and controls 159 257 160 258 var playersOnlineMarkerGroup = L.layerGroup(); … … 183 281 }).addTo(map); 184 282 185 map.on('mousemove', function(e) {186 L.DomUtil.get('pos').textContent = FormatCoord(e.latlng);187 });283 //map.on('mousemove', function(e) { 284 // L.DomUtil.get('pos').textContent = FormatCoord(e.latlng); 285 //}); 188 286 189 287 var miniMap = new L.Control.MiniMap(tileLayerMiniMap, { 190 288 toggleDisplay: true 191 289 }).addTo(map); 192 193 290 194 291 … … 358 455 }) 359 456 .always(function() { 360 window.setTimeout(updateClaimsEvent, 5000);457 //updateClaimTimer = window.setTimeout(updateClaimsEvent, 3000); 361 458 }); 362 459 } 363 460 364 window.setTimeout(updateClaimsEvent, 750); 365 461 462 463 // =============================================================================================== 464 // Layer events 465 466 var updateClaimTimer; 467 map.on('overlayadd', function(e) { 468 if (e.layer == landClaimsGroup) { 469 updateClaimsEvent(); 470 } 471 }); 472 473 map.on('overlayremove', function(e) { 474 if (e.layer == landClaimsGroup) { 475 //window.clearTimeout(updateClaimTimer); 476 } 477 }); 478 479
Note:
See TracChangeset
for help on using the changeset viewer.