diff --git a/code/boot.js b/code/boot.js
index 9635b788..16184bb2 100644
--- a/code/boot.js
+++ b/code/boot.js
@@ -54,18 +54,33 @@ window.setupMap = function() {
var views = [cmMid, cmMin, osm, new L.Google('INGRESS'), new L.Google('ROADMAP'),
new L.Google('SATELLITE'), new L.Google('HYBRID')];
- portalsLayer = L.layerGroup([]);
- linksLayer = L.layerGroup([]);
- fieldsLayer = L.layerGroup([]);
+
window.map = new L.Map('map', $.extend(getPosition(),
{zoomControl: !(localStorage['iitc.zoom.buttons'] === 'false')}
));
+
try {
map.addLayer(views[readCookie('ingress.intelmap.type')]);
} catch(e) { map.addLayer(views[0]); }
- map.addLayer(portalsLayer);
+
+ var addLayers = {};
+
+ portalsLayers = [];
+ for(var i = 0; i <= 8; i++) {
+ portalsLayers[i] = L.layerGroup([]);
+ map.addLayer(portalsLayers[i]);
+ var t = (i === 0 ? 'Unclaimed' : 'Level ' + i) + ' Portals';
+ addLayers[t] = portalsLayers[i];
+ }
+
+ fieldsLayer = L.layerGroup([]);
map.addLayer(fieldsLayer, true);
+ addLayers['Fields'] = fieldsLayer;
+
+ linksLayer = L.layerGroup([]);
map.addLayer(linksLayer, true);
+ addLayers['Links'] = linksLayer;
+
map.addControl(new L.Control.Layers({
'OSM Cloudmade Midnight': views[0],
'OSM Cloudmade Minimal': views[1],
@@ -74,11 +89,7 @@ window.setupMap = function() {
'Google Roads': views[4],
'Google Satellite': views[5],
'Google Hybrid': views[6]
- }, {
- 'Portals': portalsLayer,
- 'Links': linksLayer,
- 'Fields': fieldsLayer
- }));
+ }, addLayers));
map.attributionControl.setPrefix('');
// listen for changes and store them in cookies
map.on('moveend', window.storeMapPosition);
@@ -179,7 +190,7 @@ function asyncLoadScript(a){return function(b,c){var d=document.createElement("s
var LLGMAPS = 'http://breunigs.github.com/ingress-intel-total-conversion/leaflet_google.js';
var JQUERY = 'https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js';
var LEAFLET = 'http://cdn.leafletjs.com/leaflet-0.5/leaflet.js';
-var AUTOLINK = 'https://raw.github.com/bryanwoods/autolink-js/master/autolink.js';
+var AUTOLINK = 'http://raw.github.com/bryanwoods/autolink-js/master/autolink.js';
// after all scripts have loaded, boot the actual app
load(JQUERY, LEAFLET, AUTOLINK).then(LLGMAPS).thenRun(boot);
diff --git a/code/debugging.js b/code/debugging.js
index 4a4931bc..0a3ce734 100644
--- a/code/debugging.js
+++ b/code/debugging.js
@@ -16,7 +16,8 @@ window.debug.printStackTrace = function() {
}
window.debug.clearPortals = function() {
- portalsLayer.clearLayers();
+ for(var i = 0; i < portalsLayers.length; i++)
+ portalsLayers[i].clearLayers();
}
window.debug.clearLinks = function() {
diff --git a/code/map_data.js b/code/map_data.js
index 748ee4d4..03739be4 100644
--- a/code/map_data.js
+++ b/code/map_data.js
@@ -119,14 +119,17 @@ window.cleanUp = function() {
var cnt = [0,0,0];
var b = getPaddedBounds();
var minlvl = getMinPortalLevel();
- portalsLayer.eachLayer(function(portal) {
- // portal must be in bounds and have a high enough level. Also don’t
- // remove if it is selected.
- if(portal.options.guid == window.selectedPortal ||
- (b.contains(portal.getLatLng()) && portal.options.level >= minlvl)) return;
- cnt[0]++;
- portalsLayer.removeLayer(portal);
- });
+ for(var i = 0; i < portalsLayers.length; i++) {
+ // i is also the portal level
+ portalsLayers[i].eachLayer(function(portal) {
+ // portal must be in bounds and have a high enough level. Also don’t
+ // remove if it is selected.
+ if(portal.options.guid == window.selectedPortal ||
+ (b.contains(portal.getLatLng()) && i >= minlvl)) return;
+ cnt[0]++;
+ portalsLayers[i].removeLayer(portal);
+ });
+ }
linksLayer.eachLayer(function(link) {
if(b.intersects(link.getBounds())) return;
cnt[1]++;
@@ -153,7 +156,9 @@ window.removeByGuid = function(guid) {
case '11':
case '12':
if(!window.portals[guid]) return;
- portalsLayer.removeLayer(window.portals[guid]);
+ var p = window.portals[guid];
+ for(var i = 0; i < portalsLayers.length; i++)
+ portalsLayers[i].removeLayer(p);
break;
case '9':
if(!window.links[guid]) return;
@@ -212,13 +217,24 @@ window.renderPortal = function(ent) {
guid: ent[0]});
p.on('remove', function() { delete window.portals[this.options.guid]; });
- p.on('add', function() { window.portals[this.options.guid] = this; });
+ p.on('add', function() {
+ window.portals[this.options.guid] = this;
+ // handles the case where a selected portal gets removed from the
+ // map by hiding all portals with said level
+ if(window.selectedPortal != this.options.guid)
+ window.portalResetColor(this);
+ });
p.on('click', function() { window.renderPortalDetails(ent[0]); });
p.on('dblclick', function() {
window.renderPortalDetails(ent[0]);
window.map.setView(latlng, 17);
});
- p.addTo(portalsLayer);
+ // portalLevel contains a float, need to round down
+ p.addTo(portalsLayers[parseInt(portalLevel)]);
+}
+
+window.portalResetColor = function(portal) {
+ portal.setStyle({color: portal.options.fillColor});
}
// renders a link on the map from the given entity
diff --git a/code/portal_detail_display.js b/code/portal_detail_display.js
index e78d662f..2187b34b 100644
--- a/code/portal_detail_display.js
+++ b/code/portal_detail_display.js
@@ -104,8 +104,7 @@ window.setPortalIndicators = function(d) {
window.selectPortal = function(guid) {
var update = selectedPortal === guid;
var oldPortal = portals[selectedPortal];
- if(!update && oldPortal)
- oldPortal.setStyle({color: oldPortal.options.fillColor});
+ if(!update && oldPortal) portalResetColor(oldPortal);
selectedPortal = guid;
diff --git a/code/request_handling.js b/code/request_handling.js
index 26b228f1..60aa00f6 100644
--- a/code/request_handling.js
+++ b/code/request_handling.js
@@ -34,7 +34,7 @@ window.requests.abort = function() {
}
// gives user feedback about pending operations. Draws current status
-// to website.
+// to website. Updates info in layer chooser.
window.renderUpdateStatus = function() {
var t = 'map status: ';
if(mapRunsUserAction)
@@ -50,15 +50,20 @@ window.renderUpdateStatus = function() {
t += ' RENDER LIMIT '
if(window.failedRequestCount > 0)
- t += ' ' + window.failedRequestCount + ' requests failed.'
+ t += ' ' + window.failedRequestCount + ' requests failed.'
t += '
(';
var minlvl = getMinPortalLevel();
if(minlvl === 0)
- t += 'showing all portals';
+ t += 'loading all portals';
else
- t+= 'only showing portals with level '+minlvl+' and up';
- t += ')';
+ t+= 'only loading portals with level '+minlvl+' and up';
+ t += ')';
+
+ var portalSelection = $('.leaflet-control-layers-overlays label');
+ portalSelection.slice(0, minlvl+1).addClass('disabled').attr('title', 'Zoom in to show those.');
+ portalSelection.slice(minlvl, 8).removeClass('disabled').attr('title', '');
+
$('#updatestatus').html(t);
}
diff --git a/main.js b/main.js
index 041d7725..48613420 100644
--- a/main.js
+++ b/main.js
@@ -149,7 +149,7 @@ window.selectedPortal = null;
window.portalRangeIndicator = null;
window.portalAccessIndicator = null;
window.mapRunsUserAction = false;
-var portalsLayer, linksLayer, fieldsLayer;
+var portalsLayers, linksLayer, fieldsLayer;
// contain references to all entities shown on the map. These are
// automatically kept in sync with the items on *sLayer, so never ever
diff --git a/style.css b/style.css
index 5e004843..17ea20f4 100644
--- a/style.css
+++ b/style.css
@@ -70,6 +70,11 @@ a:hover {
z-index: 1000;
}
+.leaflet-control-layers-overlays label.disabled {
+ text-decoration: line-through;
+ cursor: help;
+}
+
.help {
cursor: help;
}