This commit is contained in:
Jon Atkins
2015-10-11 15:46:36 +01:00
5 changed files with 45 additions and 16 deletions

View File

@ -104,3 +104,16 @@ window.addHook = function(event, callback) {
else else
_hooks[event].push(callback); _hooks[event].push(callback);
} }
// callback must the SAME function to be unregistered.
window.removeHook = function(event, callback) {
if (typeof callback !== 'function') throw('Callback must be a function.');
if (_hooks[event]) {
var index = _hooks[event].indexOf(callback);
if(index == -1)
console.warn('Callback wasn\'t registered for this event.');
else
_hooks[event].splice(index, 1);
}
}

View File

@ -95,7 +95,7 @@ window.outOfDateUserPrompt = function()
dialog({ dialog({
title: 'Reload IITC', title: 'Reload IITC',
html: '<p>IITC is using an outdated version code. This will happen when Niantic update the standard intel site.</p>' html: '<p>IITC is using an outdated version code. This will happen when Niantic updates the standard intel site.</p>'
+'<p>You need to reload the page to get the updated changes.</p>' +'<p>You need to reload the page to get the updated changes.</p>'
+'<p>If you have just reloaded the page, then an old version of the standard site script is cached somewhere.' +'<p>If you have just reloaded the page, then an old version of the standard site script is cached somewhere.'
+'In this case, try clearing your cache, or waiting 15-30 minutes for the stale data to expire.</p>', +'In this case, try clearing your cache, or waiting 15-30 minutes for the stale data to expire.</p>',

View File

@ -414,6 +414,16 @@ window.addLayerGroup = function(name, layerGroup, defaultDisplay) {
layerChooser.addOverlay(layerGroup, name); layerChooser.addOverlay(layerGroup, name);
} }
window.removeLayerGroup = function(layerGroup) {
if(!layerChooser._layers[layerGroup._leaflet_id]) throw('Layer was not found');
// removing the layer will set it's default visibility to false (store if layer gets added again)
var name = layerChooser._layers[layerGroup._leaflet_id].name;
var enabled = isLayerGroupDisplayed(name);
map.removeLayer(layerGroup);
layerChooser.removeLayer(layerGroup);
updateDisplayedLayerGroup(name, enabled);
};
window.clampLat = function(lat) { window.clampLat = function(lat) {
// the map projection used does not handle above approx +- 85 degrees north/south of the equator // the map projection used does not handle above approx +- 85 degrees north/south of the equator
if (lat > 85.051128) if (lat > 85.051128)

View File

@ -212,8 +212,6 @@ S2.S2Cell.FromLatLng = function(latLng,level) {
var ij = STToIJ(st,level); var ij = STToIJ(st,level);
return S2.S2Cell.FromFaceIJ (faceuv[0], ij, level); return S2.S2Cell.FromFaceIJ (faceuv[0], ij, level);
return result;
}; };
S2.S2Cell.FromFaceIJ = function(face,ij,level) { S2.S2Cell.FromFaceIJ = function(face,ij,level) {

View File

@ -2,7 +2,7 @@
// @id iitc-plugin-basemap-opencyclepam@jonatkins // @id iitc-plugin-basemap-opencyclepam@jonatkins
// @name IITC plugin: OpenCycleMap.org map tiles // @name IITC plugin: OpenCycleMap.org map tiles
// @category Map Tiles // @category Map Tiles
// @version 0.1.1.@@DATETIMEVERSION@@ // @version 0.2.0.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion // @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@ // @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@ // @downloadURL @@DOWNLOADURL@@
@ -24,21 +24,29 @@
// use own namespace for plugin // use own namespace for plugin
window.plugin.mapTileOpenCycleMap = function() {}; window.plugin.mapTileOpenCycleMap = {
addLayer: function() {
//the Thunderforest (OpenCycleMap) tiles are free to use - http://www.thunderforest.com/terms/
window.plugin.mapTileOpenCycleMap.addLayer = function() { var ocmOpt = {
attribution: 'Tiles © OpenCycleMap, Map data © OpenStreetMap',
maxNativeZoom: 18,
maxZoom: 21,
};
//the Thunderforest (OpenCycleMap) tiles are free to use - http://www.thunderforest.com/terms/ var layers = {
'cycle': 'OpenCycleMap',
'transport': 'Transport',
'transport-dark': 'Transport Dark',
'outdoors': 'Outdoors',
'landscape': 'Landscape',
};
osmAttribution = 'Map data © OpenStreetMap'; for(var i in layers) {
var ocmOpt = {attribution: 'Tiles © OpenCycleMap, '+osmAttribution, maxNativeZoom: 18, maxZoom: 21}; var layer = new L.TileLayer('http://{s}.tile.thunderforest.com/' + i + '/{z}/{x}/{y}.png', ocmOpt);
var ocmCycle = new L.TileLayer('http://{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png', ocmOpt); layerChooser.addBaseLayer(layer, 'Thunderforest ' + layers[i]);
var ocmTransport = new L.TileLayer('http://{s}.tile2.opencyclemap.org/transport/{z}/{x}/{y}.png', ocmOpt); }
var ocmLandscape = new L.TileLayer('http://{s}.tile3.opencyclemap.org/landscape/{z}/{x}/{y}.png', ocmOpt); },
layerChooser.addBaseLayer(ocmCycle, "Thunderforest OpenCycleMap");
layerChooser.addBaseLayer(ocmTransport, "Thunderforest Transport");
layerChooser.addBaseLayer(ocmLandscape, "Thunderforest Landscape");
}; };
var setup = window.plugin.mapTileOpenCycleMap.addLayer; var setup = window.plugin.mapTileOpenCycleMap.addLayer;