make (portals/lihnks/fields)Layers private to IITC core again - they're not for plugins

now only some portals are drawn to the map it's OK to bring them all to front at the end of the render
use larger squares for portal clustering on mobile - as the portal markers are larger
This commit is contained in:
Jon Atkins 2013-09-08 20:43:23 +01:00
parent 695804524e
commit 543e586723
2 changed files with 14 additions and 19 deletions

View File

@ -4,12 +4,10 @@
window.Render = function() { window.Render = function() {
// below this many portals displayed, we reorder the SVG at the end of the render pass to put portals above fields/links
this.LOW_PORTAL_COUNT = 350;
// when there are lots of portals close together, we only add some of them to the map // when there are lots of portals close together, we only add some of them to the map
// the idea is to keep the impression of the dense set of portals, without rendering them all // the idea is to keep the impression of the dense set of portals, without rendering them all
this.CLUSTER_SIZE = 8; // the map is divited into squares of this size in pixels for clustering purposes this.CLUSTER_SIZE = L.Browser.mobile ? 16 : 8; // the map is divited into squares of this size in pixels for clustering purposes. mobile uses larger markers, so therefore larger clustering areas
this.CLUSTER_PORTAL_LIMIT = 4; // no more than this many portals are drawn in each cluster square this.CLUSTER_PORTAL_LIMIT = 4; // no more than this many portals are drawn in each cluster square
@ -134,23 +132,22 @@ window.Render.prototype.endRenderPass = function() {
} }
} }
// reorder portals to be after links/fields, but only if the number is low // reorder portals to be after links/fields
if (Object.keys(window.portals).length <= this.LOW_PORTAL_COUNT) { this.bringPortalsToFront();
for (var i in window.portalsLayers) {
var layer = window.portalsLayers[i];
if (window.map.hasLayer(layer)) {
layer.eachLayer (function(p) {
p.bringToFront();
});
}
}
}
this.isRendering = false; this.isRendering = false;
} }
window.Render.prototype.bringPortalsToFront = function() {
for (var i in portalsLayers) {
var layer = portalsLayers[i];
if (window.map.hasLayer(layer)) {
layer.eachLayer (function(p) {
p.bringToFront();
});
}
}
}
window.Render.prototype.deleteEntity = function(guid) { window.Render.prototype.deleteEntity = function(guid) {

View File

@ -212,9 +212,7 @@ window.selectedPortal = null;
window.portalRangeIndicator = null; window.portalRangeIndicator = null;
window.portalAccessIndicator = null; window.portalAccessIndicator = null;
window.mapRunsUserAction = false; window.mapRunsUserAction = false;
window.portalsLayers = undefined; var portalsLayers, linksLayer, fieldsLayer;
window.linksLayer = undefined;
window.fieldsLayer = undefined;
// contain references to all entities loaded from the server. If render limits are hit, // contain references to all entities loaded from the server. If render limits are hit,
// not all may be added to the leaflet layers // not all may be added to the leaflet layers