Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Add a new plugin to display portal levels as numbers, directly on the map #104

merged 1 commit into from

8 participants


This is mostly a straight copy of the portal-keys-on-map plugin. I've been using it for a day or two, seems to work pretty well.


this will clash with the show keys-on-map plugin, right?

One option is to make them layers that can be toggled - but there'd still need to be inter-plugin communication to prevent both being on at once.

A simpler option is to warn. Perhaps some code along these lines, in both this and keys-on-map plugins, in the setup functions:

var thisPlugin = 'Portal level numbers';
if ( window.plugins.DIGITS_ON_PORTALS !== undefined )
    alert ( 'The '+thisPlugin+' plugin conflicts with the '+window.plugins.DIGITS_ON_PORTALS+' plugin - please uninstall one' );
   window.plugins.DIGITS_ON_PORTALS = thisPlugin;

Does anyone have any better ideas?


Could the layer control make the two layers exclusive?


I hadn't realised they were already layers that could be turned on/off. That could be an option, yes.


I'm not sure they can be mutually exclusive (radio) but having them as options should be good enough, and if the person has both on then that's their problem. Could always have the keys be yellow font or something, so if they're both on it's clear what's what.

Though, in that case, it would probably be best to remember their overlay selections and have them persist from load to load, which isn't a bad idea either way.


Is there a way to figure out how popular a plugin is? Personally I don't think the keys and keys-on-map plugins are that useful since they involve lots of manual data entry. I've uninstalled them myself.

Not saying we should remove them, but if someone really wants them, maybe they can deal with the conflict?


I might be in the minority but I really like the keys plugin and probably wouldn't use the portal level one if there was a conflict. Portal level is pretty overrated, imo.


As plugins don't work on IITC, I would very much prefer that this functionality were folded into the main code. Seeing portal levels on IITC Mobile would be extremely valuable....and it's a very small amount of additional rendering.


current Firefox versions can’t handle additional SVG entities without severe performance loss. I therefore strongly advise to not make this mandatory in main until Firefox has improved. I wanted to make a test case and bug report for it, but have not yet gotten around to it.


Persist the overlay seems a good option, I couldn't find an easy way to make them mutually exclusive.


Is there anything I can do to get this merged? Maybe we just need to leave both layers unchecked by default, and add some warning verbiage that they overlap?


Apologies - I've been a little slow in handling some things, and @breunigs warning about Firefox was a concern. Not had a chance to test for myself here. Have you tried on Firefox?

Depending on how bad it is in Firefox, you could

  • add a warning into the description field
  • disable the layer by default in FF
  • add a warning dialog for FF users.

I like your plugin very much. It's very useful for documenting some "actions". The numers where just a little bit too small for me so I made a little bit finetuning with the size and the colour of the numbers and the placement of the icon.
Now it looks like this - just for my personal needs...


@rongou you can make the overlay selection persist by using function in following PR #214. Here is an example #215.

@jonatkins jonatkins merged commit cb20746 into jonatkins:master
@rongou rongou deleted the rongou:portal-level-numbers branch

Did a quick test myself for FF - seems pretty slow both with and without this installed when large numbers of portals are on screen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 100 additions and 0 deletions.
  1. +100 −0 plugins/portal-level-numbers.user.js
100 plugins/portal-level-numbers.user.js
@@ -0,0 +1,100 @@
+// ==UserScript==
+// @id iitc-plugin-portal-level-numbers@rongou
+// @name IITC plugin: Portal Level Numbers
+// @version 0.1.0.@@DATETIMEVERSION@@
+// @namespace
+// @updateURL @@UPDATEURL@@
+// @downloadURL @@DOWNLOADURL@@
+// @description [@@BUILDNAME@@-@@BUILDDATE@@] Show portal level numbers on map.
+// @include*
+// @include*
+// @match*
+// @match*
+// ==/UserScript==
+function wrapper() {
+// ensure plugin framework is there, even if iitc is not yet loaded
+if(typeof window.plugin !== 'function') window.plugin = function() {};
+// PLUGIN START ////////////////////////////////////////////////////////
+// use own namespace for plugin
+window.plugin.portalLevelNumbers = function() {};
+window.plugin.portalLevelNumbers.levelLayers = {};
+window.plugin.portalLevelNumbers.levelLayerGroup = new L.LayerGroup();
+// Use portal add and remove event to control render of portal level numbers
+window.plugin.portalLevelNumbers.portalAdded = function(data) {
+ data.portal.on('add', function() {
+ plugin.portalLevelNumbers.renderLevel(this.options.guid, this.getLatLng());
+ });
+ data.portal.on('remove', function() {
+ plugin.portalLevelNumbers.removeLevel(this.options.guid);
+ });
+window.plugin.portalLevelNumbers.renderLevel = function(guid,latLng) {
+ plugin.portalLevelNumbers.removeLevel(guid);
+ var d = window.portals[guid].options.details;
+ var levelNumber = Math.floor(window.getPortalLevel(d));
+ var level = L.marker(latLng, {
+ icon: L.divIcon({
+ className: 'plugin-portal-level-numbers',
+ iconAnchor: [6,7],
+ iconSize: [12,10],
+ html: levelNumber
+ }),
+ guid: guid
+ });
+ plugin.portalLevelNumbers.levelLayers[guid] = level;
+ level.addTo(plugin.portalLevelNumbers.levelLayerGroup);
+window.plugin.portalLevelNumbers.removeLevel = function(guid) {
+ var previousLayer = plugin.portalLevelNumbers.levelLayers[guid];
+ if(previousLayer) {
+ plugin.portalLevelNumbers.levelLayerGroup.removeLayer(previousLayer);
+ delete plugin.portalLevelNumbers.levelLayers[guid];
+ }
+var setup = function() {
+ $("<style>")
+ .prop("type", "text/css")
+ .html(".plugin-portal-level-numbers {\
+ font-size: 10px;\
+ color: #FFFFBB;\
+ font-family: monospace;\
+ text-align: center;\
+ text-shadow: 0 0 0.5em black, 0 0 0.5em black, 0 0 0.5em black;\
+ pointer-events: none;\
+ -webkit-text-size-adjust:none;\
+ }")
+ .appendTo("head");
+ window.layerChooser.addOverlay(window.plugin.portalLevelNumbers.levelLayerGroup, 'Portal Levels');
+ map.addLayer(window.plugin.portalLevelNumbers.levelLayerGroup);
+ window.addHook('portalAdded', window.plugin.portalLevelNumbers.portalAdded);
+// PLUGIN END //////////////////////////////////////////////////////////
+if(window.iitcLoaded && typeof setup === 'function') {
+ setup();
+} else {
+ if(window.bootPlugins)
+ window.bootPlugins.push(setup);
+ else
+ window.bootPlugins = [setup];
+} // wrapper end
+// inject code into site context
+var script = document.createElement('script');
+script.appendChild(document.createTextNode('('+ wrapper +')();'));
+(document.body || document.head || document.documentElement).appendChild(script);
Something went wrong with that request. Please try again.