If I understood everything correctly, the reason was that the for-loop
doesn’t create a separate context, thus the reference to r was made for
the whole renderResonator function. This obviously references the latest
r after the loop has finished. Switching this to $.each where each
iteration is a new anonymous function and thus a closure, r is referenced
correctly.
Please reopen if this does not fix the problem.
if there were only minor changes (resos destroyed or energy level
changed). This likely lead to the sidebar showing outdates information.
The patch should solve #154, but please check carefully.
The lines look great against a dark background but are barely visible against
OSM CloudMade Minimal. Not sure what could be done about that though, other
than drawing differently for each.
At a glance high level indicator of portals in disrepair. Opacity is
used to denote how much it's hurting. (Bright means needs the most
attention.) Factors in current energy, missing shields, or missing
resonators. Red means it needs attention. Orange means the same thing,
except that it's down at least one resonator.
I realise this is in opposition to game convention where dim == almost
dead, but I tried it that way, and it just made no sense to me to do it
that way. The whole point is a high level way to quickly identify
portals that most need repairing. If opacity isn't done this way your
eyes are most drawn to the portals that least need your attention.
– fix#103 by always re-rendering resonator details.
A follow-up patch could also avoid re-rendering resos if they did not
change. Given that there are only a few on these high zoom levels, perf
improvement might be negligible though.
- fix#91. This avoids drawing portals/links/fields again if they are
hidden. The patch looks for those hidden entities and either removes
them before re-drawing (portals) or skips re-drawing altogether:
- Fields and Links are assumed to never change as long as their GUID is
the same. This avoids deleting and re-creating links/fields all the
time and might improve speed. Haven’t tested though.
Change:
Add "RESONATOR_DISPLAY_ZOOM_LEVEL" to control minimum zoom level resonator will display
Add layerGroup "resonatorsLayers" to draw resonators on it.
Add "window.resonators" to store references to resonators on map
Resonator will have guid of portal with ".11" or ".12" replaced with ".r0"~".r7"
Add function "window.renderResontor" to draw resonators (use sorgo's code [sorgo](https://github.com/sorgo))
"window.renderPortal" will call "window.renderResontor" before add portal to portalsLayers
Change "window.removeByGuid" to handle resonators
Change "window.cleanUp" to handle resonators cleanup