Change resonators render min zoom level and radius

Change:
Resonators render minimum zoom level 16 -> 17
Resonators render radius 4 -> 3
Some cleanup and performance tuning
This commit is contained in:
Xelio
2013-02-11 02:22:35 +08:00
parent 259905b224
commit 7b7f229ac5
3 changed files with 8 additions and 8 deletions

View File

@ -102,7 +102,7 @@ window.setupMap = function() {
portalsLayers[i].eachLayer(function(item) { portalsLayers[i].eachLayer(function(item) {
var itemGuid = item.options.guid; var itemGuid = item.options.guid;
// check if 'item' is a resonator // check if 'item' is a resonator
if(!window.resonators[itemGuid]) return; if(getTypeByGuid(itemGuid) != TYPE_RESONATOR) return true;
portalsLayers[i].removeLayer(item); portalsLayers[i].removeLayer(item);
}); });
} }

View File

@ -146,11 +146,11 @@ window.cleanUp = function() {
portalsLayers[i].eachLayer(function(item) { portalsLayers[i].eachLayer(function(item) {
var itemGuid = item.options.guid; var itemGuid = item.options.guid;
// check if 'item' is a portal // check if 'item' is a portal
if(!window.portals[itemGuid]) return; if(getTypeByGuid(itemGuid) != TYPE_PORTAL) return true;
// portal must be in bounds and have a high enough level. Also dont // portal must be in bounds and have a high enough level. Also dont
// remove if it is selected. // remove if it is selected.
if(itemGuid == window.selectedPortal || if(itemGuid == window.selectedPortal ||
(b.contains(item.getLatLng()) && i >= minlvl)) return; (b.contains(item.getLatLng()) && i >= minlvl)) return true;
cnt[0]++; cnt[0]++;
portalsLayers[i].removeLayer(item); portalsLayers[i].removeLayer(item);
}); });
@ -188,7 +188,7 @@ window.removeByGuid = function(guid) {
break; break;
case TYPE_RESONATOR: case TYPE_RESONATOR:
if(!window.resonators[guid]) return; if(!window.resonators[guid]) return;
var r = window.resonators[guid] var r = window.resonators[guid];
for(var i = 1; i < portalsLayers.length; i++) for(var i = 1; i < portalsLayers.length; i++)
portalsLayers[i].removeLayer(r); portalsLayers[i].removeLayer(r);
break; break;
@ -297,7 +297,7 @@ window.renderResonators = function(ent) {
var lon0 = ent[2].locationE6.lngE6/1E6 + dLon * 180/Math.PI; var lon0 = ent[2].locationE6.lngE6/1E6 + dLon * 180/Math.PI;
var Rlatlng = [lat0, lon0]; var Rlatlng = [lat0, lon0];
var r = L.circleMarker(Rlatlng, { var r = L.circleMarker(Rlatlng, {
radius: 4, radius: 3,
// #AAAAAA outline seems easier to see the fill opacity // #AAAAAA outline seems easier to see the fill opacity
color: '#AAAAAA', color: '#AAAAAA',
opacity: 1, opacity: 1,
@ -318,11 +318,11 @@ window.renderResonators = function(ent) {
} }
// append portal guid with -resonator-[slot] to get guid for resonators // append portal guid with -resonator-[slot] to get guid for resonators
window.portalResonatorGuid = function(portalGuid, slot){ window.portalResonatorGuid = function(portalGuid, slot) {
return portalGuid + '-resonator-' + slot; return portalGuid + '-resonator-' + slot;
} }
window.isResonatorsShow = function(){ window.isResonatorsShow = function() {
return map.getZoom() >= RESONATOR_DISPLAY_ZOOM_LEVEL; return map.getZoom() >= RESONATOR_DISPLAY_ZOOM_LEVEL;
} }

View File

@ -145,7 +145,7 @@ var PLAYER = window.PLAYER;
var CHAT_SHRINKED = 60; var CHAT_SHRINKED = 60;
// Minimum zoom level resonator will display // Minimum zoom level resonator will display
var RESONATOR_DISPLAY_ZOOM_LEVEL = 16; var RESONATOR_DISPLAY_ZOOM_LEVEL = 17;
// Constants for resonator positioning // Constants for resonator positioning
var SLOT_TO_LAT = [0, Math.sqrt(2)/2, 1, Math.sqrt(2)/2, 0, -Math.sqrt(2)/2, -1, -Math.sqrt(2)/2]; var SLOT_TO_LAT = [0, Math.sqrt(2)/2, 1, Math.sqrt(2)/2, 0, -Math.sqrt(2)/2, -1, -Math.sqrt(2)/2];