make IITC first try to use the TILES_PER_EDGE and ZOOM_TO_LEVEL values from the stock script - only falling back (with a warning) to our pre-defined list on error
this way we automatically follow any changes to these made in the stock site, but have a fallback case in case the stock site renames the variables
This commit is contained in:
parent
f9d2346d72
commit
4f6631d1f7
@ -11,12 +11,28 @@
|
|||||||
|
|
||||||
|
|
||||||
window.getMapZoomTileParameters = function(zoom) {
|
window.getMapZoomTileParameters = function(zoom) {
|
||||||
// these arrays/constants are based on those in the stock intel site. it's essential we keep them in sync with their code
|
// attempt to use the values from the stock site. this way, if they're changed, IITC should continue to work
|
||||||
// (it may be worth reading the values from their code rather than using our own copies? it's a case of either
|
// however, if Niantic rename things, it would fail, so we'll fall back to the current known values
|
||||||
// breaking if they rename their variables if we do, or breaking if they change the values if we don't)
|
var ZOOM_TO_TILES_PER_EDGE, MAX_TILES_PER_EDGE, ZOOM_TO_LEVEL;
|
||||||
var ZOOM_TO_TILES_PER_EDGE = [32, 32, 32, 32, 256, 256, 256, 1024, 1024, 1536, 4096, 4096, 16384, 16384, 16384];
|
try {
|
||||||
var MAX_TILES_PER_EDGE = 65536;
|
ZOOM_TO_TILES_PER_EDGE = nemesis.dashboard.mercator.Tile.ZOOM_TO_NUM_TILES_PER_EDGE_;
|
||||||
var ZOOM_TO_LEVEL = [8, 8, 8, 8, 7, 7, 7, 6, 6, 5, 4, 4, 3, 2, 2, 1, 1];
|
if (ZOOM_TO_TILES_PER_EDGE === undefined) throw('ZOOM_TO_TILES_PER_EDGE not found');
|
||||||
|
MAX_TILES_PER_EDGE = nemesis.dashboard.mercator.Tile.MAX_NUM_TILES_PER_EDGE_;
|
||||||
|
if (MAX_TILES_PER_EDGE === undefined) throw('MAX_TILES_PER_EDGE not found');
|
||||||
|
ZOOM_TO_LEVEL = nemesis.dashboard.zoomlevel.ZOOM_TO_LOD_;
|
||||||
|
if (ZOOM_TO_LEVEL === undefined) throw('ZOOM_TO_LEVEL not found');
|
||||||
|
} catch(e) {
|
||||||
|
console.warn(e);
|
||||||
|
|
||||||
|
// known correct as of 2014-03-11
|
||||||
|
ZOOM_TO_TILES_PER_EDGE = [32, 32, 32, 32, 256, 256, 256, 1024, 1024, 1536, 4096, 4096, 16384, 16384, 16384];
|
||||||
|
MAX_TILES_PER_EDGE = 65536;
|
||||||
|
ZOOM_TO_LEVEL = [8, 8, 8, 8, 7, 7, 7, 6, 6, 5, 4, 4, 3, 2, 2, 1, 1];
|
||||||
|
|
||||||
|
// for developers, let's stop in the debugger
|
||||||
|
debugger;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
level: ZOOM_TO_LEVEL[zoom] || 0, // default to level 0 (all portals) if not in array
|
level: ZOOM_TO_LEVEL[zoom] || 0, // default to level 0 (all portals) if not in array
|
||||||
|
Loading…
x
Reference in New Issue
Block a user