revert: do not lint public directory
Signed-off-by: Vinayak Kulkarni <19776877+vinayakkulkarni@users.noreply.github.com>
This commit is contained in:
parent
85b1b69c93
commit
63fa46e356
8 changed files with 403 additions and 97293 deletions
|
|
@ -1,249 +1,243 @@
|
||||||
// @class TileLayer
|
// @class TileLayer
|
||||||
|
|
||||||
L.TileLayer.mergeOptions({
|
L.TileLayer.mergeOptions({
|
||||||
// @option keepBuffer
|
// @option keepBuffer
|
||||||
// The amount of tiles outside the visible map area to be kept in the stitched
|
// The amount of tiles outside the visible map area to be kept in the stitched
|
||||||
// `TileLayer`.
|
// `TileLayer`.
|
||||||
|
|
||||||
// @option dumpToCanvas: Boolean = true
|
// @option dumpToCanvas: Boolean = true
|
||||||
// Whether to dump loaded tiles to a `<canvas>` to prevent some rendering
|
// Whether to dump loaded tiles to a `<canvas>` to prevent some rendering
|
||||||
// artifacts. (Disabled by default in IE)
|
// artifacts. (Disabled by default in IE)
|
||||||
dumpToCanvas: L.Browser.canvas && !L.Browser.ie,
|
dumpToCanvas: L.Browser.canvas && !L.Browser.ie,
|
||||||
});
|
});
|
||||||
|
|
||||||
L.TileLayer.include({
|
L.TileLayer.include({
|
||||||
_onUpdateLevel: function (z, zoom) {
|
_onUpdateLevel: function(z, zoom) {
|
||||||
if (this.options.dumpToCanvas) {
|
if (this.options.dumpToCanvas) {
|
||||||
this._levels[z].canvas.style.zIndex =
|
this._levels[z].canvas.style.zIndex =
|
||||||
this.options.maxZoom - Math.abs(zoom - z);
|
this.options.maxZoom - Math.abs(zoom - z);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_onRemoveLevel: function (z) {
|
_onRemoveLevel: function(z) {
|
||||||
if (this.options.dumpToCanvas) {
|
if (this.options.dumpToCanvas) {
|
||||||
L.DomUtil.remove(this._levels[z].canvas);
|
L.DomUtil.remove(this._levels[z].canvas);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_onCreateLevel: function (level) {
|
_onCreateLevel: function(level) {
|
||||||
if (this.options.dumpToCanvas) {
|
if (this.options.dumpToCanvas) {
|
||||||
level.canvas = L.DomUtil.create(
|
level.canvas = L.DomUtil.create(
|
||||||
'canvas',
|
"canvas",
|
||||||
'leaflet-tile-container leaflet-zoom-animated',
|
"leaflet-tile-container leaflet-zoom-animated",
|
||||||
this._container,
|
this._container
|
||||||
);
|
);
|
||||||
level.ctx = level.canvas.getContext('2d');
|
level.ctx = level.canvas.getContext("2d");
|
||||||
this._resetCanvasSize(level);
|
this._resetCanvasSize(level);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_removeTile: function (key) {
|
_removeTile: function(key) {
|
||||||
if (this.options.dumpToCanvas) {
|
if (this.options.dumpToCanvas) {
|
||||||
var tile = this._tiles[key];
|
var tile = this._tiles[key];
|
||||||
var level = this._levels[tile.coords.z];
|
var level = this._levels[tile.coords.z];
|
||||||
var tileSize = this.getTileSize();
|
var tileSize = this.getTileSize();
|
||||||
|
|
||||||
if (level) {
|
if (level) {
|
||||||
// Where in the canvas should this tile go?
|
// Where in the canvas should this tile go?
|
||||||
var offset = L.point(tile.coords.x, tile.coords.y)
|
var offset = L.point(tile.coords.x, tile.coords.y)
|
||||||
.subtract(level.canvasRange.min)
|
.subtract(level.canvasRange.min)
|
||||||
.scaleBy(this.getTileSize());
|
.scaleBy(this.getTileSize());
|
||||||
|
|
||||||
level.ctx.clearRect(offset.x, offset.y, tileSize.x, tileSize.y);
|
level.ctx.clearRect(offset.x, offset.y, tileSize.x, tileSize.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
L.GridLayer.prototype._removeTile.call(this, key);
|
L.GridLayer.prototype._removeTile.call(this, key);
|
||||||
},
|
},
|
||||||
|
|
||||||
_resetCanvasSize: function (level) {
|
_resetCanvasSize: function(level) {
|
||||||
var buff = this.options.keepBuffer,
|
var buff = this.options.keepBuffer,
|
||||||
pixelBounds = this._getTiledPixelBounds(this._map.getCenter()),
|
pixelBounds = this._getTiledPixelBounds(this._map.getCenter()),
|
||||||
tileRange = this._pxBoundsToTileRange(pixelBounds),
|
tileRange = this._pxBoundsToTileRange(pixelBounds),
|
||||||
tileSize = this.getTileSize();
|
tileSize = this.getTileSize();
|
||||||
|
|
||||||
tileRange.min = tileRange.min.subtract([buff, buff]); // This adds the no-prune buffer
|
tileRange.min = tileRange.min.subtract([buff, buff]); // This adds the no-prune buffer
|
||||||
tileRange.max = tileRange.max.add([buff + 1, buff + 1]);
|
tileRange.max = tileRange.max.add([buff + 1, buff + 1]);
|
||||||
|
|
||||||
var pixelRange = L.bounds(
|
var pixelRange = L.bounds(
|
||||||
tileRange.min.scaleBy(tileSize),
|
tileRange.min.scaleBy(tileSize),
|
||||||
tileRange.max.add([1, 1]).scaleBy(tileSize), // This prevents an off-by-one when checking if tiles are inside
|
tileRange.max.add([1, 1]).scaleBy(tileSize) // This prevents an off-by-one when checking if tiles are inside
|
||||||
),
|
),
|
||||||
mustRepositionCanvas = false,
|
mustRepositionCanvas = false,
|
||||||
neededSize = pixelRange.max.subtract(pixelRange.min);
|
neededSize = pixelRange.max.subtract(pixelRange.min);
|
||||||
|
|
||||||
// Resize the canvas, if needed, and only to make it bigger.
|
// Resize the canvas, if needed, and only to make it bigger.
|
||||||
if (
|
if (
|
||||||
neededSize.x > level.canvas.width ||
|
neededSize.x > level.canvas.width ||
|
||||||
neededSize.y > level.canvas.height
|
neededSize.y > level.canvas.height
|
||||||
) {
|
) {
|
||||||
// Resizing canvases erases the currently drawn content, I'm afraid.
|
// Resizing canvases erases the currently drawn content, I'm afraid.
|
||||||
// To keep it, dump the pixels to another canvas, then display it on
|
// To keep it, dump the pixels to another canvas, then display it on
|
||||||
// top. This could be done with getImageData/putImageData, but that
|
// top. This could be done with getImageData/putImageData, but that
|
||||||
// would break for tainted canvases (in non-CORS tilesets)
|
// would break for tainted canvases (in non-CORS tilesets)
|
||||||
var oldSize = { x: level.canvas.width, y: level.canvas.height };
|
var oldSize = { x: level.canvas.width, y: level.canvas.height };
|
||||||
// console.info('Resizing canvas from ', oldSize, 'to ', neededSize);
|
// console.info('Resizing canvas from ', oldSize, 'to ', neededSize);
|
||||||
|
|
||||||
var tmpCanvas = L.DomUtil.create('canvas');
|
var tmpCanvas = L.DomUtil.create("canvas");
|
||||||
tmpCanvas.style.width = (tmpCanvas.width = oldSize.x) + 'px';
|
tmpCanvas.style.width = (tmpCanvas.width = oldSize.x) + "px";
|
||||||
tmpCanvas.style.height = (tmpCanvas.height = oldSize.y) + 'px';
|
tmpCanvas.style.height = (tmpCanvas.height = oldSize.y) + "px";
|
||||||
tmpCanvas.getContext('2d').drawImage(level.canvas, 0, 0);
|
tmpCanvas.getContext("2d").drawImage(level.canvas, 0, 0);
|
||||||
// var data = level.ctx.getImageData(0, 0, oldSize.x, oldSize.y);
|
// var data = level.ctx.getImageData(0, 0, oldSize.x, oldSize.y);
|
||||||
|
|
||||||
level.canvas.style.width = (level.canvas.width = neededSize.x) + 'px';
|
level.canvas.style.width = (level.canvas.width = neededSize.x) + "px";
|
||||||
level.canvas.style.height = (level.canvas.height = neededSize.y) + 'px';
|
level.canvas.style.height = (level.canvas.height = neededSize.y) + "px";
|
||||||
level.ctx.drawImage(tmpCanvas, 0, 0);
|
level.ctx.drawImage(tmpCanvas, 0, 0);
|
||||||
// level.ctx.putImageData(data, 0, 0, 0, 0, oldSize.x, oldSize.y);
|
// level.ctx.putImageData(data, 0, 0, 0, 0, oldSize.x, oldSize.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Translate the canvas contents if it's moved around
|
// Translate the canvas contents if it's moved around
|
||||||
if (level.canvasRange) {
|
if (level.canvasRange) {
|
||||||
var offset = level.canvasRange.min
|
var offset = level.canvasRange.min
|
||||||
.subtract(tileRange.min)
|
.subtract(tileRange.min)
|
||||||
.scaleBy(this.getTileSize());
|
.scaleBy(this.getTileSize());
|
||||||
|
|
||||||
// console.info('Offsetting by ', offset);
|
// console.info('Offsetting by ', offset);
|
||||||
|
|
||||||
if (!L.Browser.safari) {
|
if (!L.Browser.safari) {
|
||||||
// By default, canvases copy things "on top of" existing pixels, but we want
|
// By default, canvases copy things "on top of" existing pixels, but we want
|
||||||
// this to *replace* the existing pixels when doing a drawImage() call.
|
// this to *replace* the existing pixels when doing a drawImage() call.
|
||||||
// This will also clear the sides, so no clearRect() calls are needed to make room
|
// This will also clear the sides, so no clearRect() calls are needed to make room
|
||||||
// for the new tiles.
|
// for the new tiles.
|
||||||
level.ctx.globalCompositeOperation = 'copy';
|
level.ctx.globalCompositeOperation = "copy";
|
||||||
level.ctx.drawImage(level.canvas, offset.x, offset.y);
|
level.ctx.drawImage(level.canvas, offset.x, offset.y);
|
||||||
level.ctx.globalCompositeOperation = 'source-over';
|
level.ctx.globalCompositeOperation = "source-over";
|
||||||
} else {
|
} else {
|
||||||
// Safari clears the canvas when copying from itself :-(
|
// Safari clears the canvas when copying from itself :-(
|
||||||
if (!this._tmpCanvas) {
|
if (!this._tmpCanvas) {
|
||||||
var t = (this._tmpCanvas = L.DomUtil.create('canvas'));
|
var t = (this._tmpCanvas = L.DomUtil.create("canvas"));
|
||||||
t.width = level.canvas.width;
|
t.width = level.canvas.width;
|
||||||
t.height = level.canvas.height;
|
t.height = level.canvas.height;
|
||||||
this._tmpContext = t.getContext('2d');
|
this._tmpContext = t.getContext("2d");
|
||||||
}
|
}
|
||||||
this._tmpContext.clearRect(
|
this._tmpContext.clearRect(
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
level.canvas.width,
|
level.canvas.width,
|
||||||
level.canvas.height,
|
level.canvas.height
|
||||||
);
|
);
|
||||||
this._tmpContext.drawImage(level.canvas, 0, 0);
|
this._tmpContext.drawImage(level.canvas, 0, 0);
|
||||||
level.ctx.clearRect(0, 0, level.canvas.width, level.canvas.height);
|
level.ctx.clearRect(0, 0, level.canvas.width, level.canvas.height);
|
||||||
level.ctx.drawImage(this._tmpCanvas, offset.x, offset.y);
|
level.ctx.drawImage(this._tmpCanvas, offset.x, offset.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
mustRepositionCanvas = true; // Wait until new props are set
|
mustRepositionCanvas = true; // Wait until new props are set
|
||||||
}
|
}
|
||||||
|
|
||||||
level.canvasRange = tileRange;
|
level.canvasRange = tileRange;
|
||||||
level.canvasPxRange = pixelRange;
|
level.canvasPxRange = pixelRange;
|
||||||
level.canvasOrigin = pixelRange.min;
|
level.canvasOrigin = pixelRange.min;
|
||||||
|
|
||||||
// console.log('Canvas tile range: ', level, tileRange.min, tileRange.max );
|
// console.log('Canvas tile range: ', level, tileRange.min, tileRange.max );
|
||||||
// console.log('Canvas pixel range: ', pixelRange.min, pixelRange.max );
|
// console.log('Canvas pixel range: ', pixelRange.min, pixelRange.max );
|
||||||
// console.log('Level origin: ', level.origin );
|
// console.log('Level origin: ', level.origin );
|
||||||
|
|
||||||
if (mustRepositionCanvas) {
|
if (mustRepositionCanvas) {
|
||||||
this._setCanvasZoomTransform(
|
this._setCanvasZoomTransform(
|
||||||
level,
|
level,
|
||||||
this._map.getCenter(),
|
this._map.getCenter(),
|
||||||
this._map.getZoom(),
|
this._map.getZoom()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/// set transform/position of canvas, in addition to the transform/position of the individual tile container
|
/// set transform/position of canvas, in addition to the transform/position of the individual tile container
|
||||||
_setZoomTransform: function (level, center, zoom) {
|
_setZoomTransform: function(level, center, zoom) {
|
||||||
L.GridLayer.prototype._setZoomTransform.call(this, level, center, zoom);
|
L.GridLayer.prototype._setZoomTransform.call(this, level, center, zoom);
|
||||||
if (this.options.dumpToCanvas) {
|
if (this.options.dumpToCanvas) {
|
||||||
this._setCanvasZoomTransform(level, center, zoom);
|
this._setCanvasZoomTransform(level, center, zoom);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// This will get called twice:
|
// This will get called twice:
|
||||||
// * From _setZoomTransform
|
// * From _setZoomTransform
|
||||||
// * When the canvas has shifted due to a new tile being loaded
|
// * When the canvas has shifted due to a new tile being loaded
|
||||||
_setCanvasZoomTransform: function (level, center, zoom) {
|
_setCanvasZoomTransform: function(level, center, zoom) {
|
||||||
// console.log('_setCanvasZoomTransform', level, center, zoom);
|
// console.log('_setCanvasZoomTransform', level, center, zoom);
|
||||||
if (!level.canvasOrigin) {
|
if (!level.canvasOrigin) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var scale = this._map.getZoomScale(zoom, level.zoom),
|
var scale = this._map.getZoomScale(zoom, level.zoom),
|
||||||
translate = level.canvasOrigin
|
translate = level.canvasOrigin
|
||||||
.multiplyBy(scale)
|
.multiplyBy(scale)
|
||||||
.subtract(this._map._getNewPixelOrigin(center, zoom))
|
.subtract(this._map._getNewPixelOrigin(center, zoom))
|
||||||
.round();
|
.round();
|
||||||
|
|
||||||
if (L.Browser.any3d) {
|
if (L.Browser.any3d) {
|
||||||
L.DomUtil.setTransform(level.canvas, translate, scale);
|
L.DomUtil.setTransform(level.canvas, translate, scale);
|
||||||
} else {
|
} else {
|
||||||
L.DomUtil.setPosition(level.canvas, translate);
|
L.DomUtil.setPosition(level.canvas, translate);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_onOpaqueTile: function (tile) {
|
_onOpaqueTile: function(tile) {
|
||||||
if (!this.options.dumpToCanvas) {
|
if (!this.options.dumpToCanvas) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Guard against an NS_ERROR_NOT_AVAILABLE (or similar) exception
|
// Guard against an NS_ERROR_NOT_AVAILABLE (or similar) exception
|
||||||
// when a non-image-tile has been loaded (e.g. a WMS error).
|
// when a non-image-tile has been loaded (e.g. a WMS error).
|
||||||
// Checking for tile.el.complete is not enough, as it has been
|
// Checking for tile.el.complete is not enough, as it has been
|
||||||
// already marked as loaded and ready somehow.
|
// already marked as loaded and ready somehow.
|
||||||
try {
|
try {
|
||||||
this.dumpPixels(tile.coords, tile.el);
|
this.dumpPixels(tile.coords, tile.el);
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
return this.fire('tileerror', {
|
return this.fire("tileerror", {
|
||||||
error: 'Could not copy tile pixels: ' + ex,
|
error: "Could not copy tile pixels: " + ex,
|
||||||
tile: tile,
|
tile: tile,
|
||||||
coods: tile.coords,
|
coods: tile.coords,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// If dumping the pixels was successful, then hide the tile.
|
// If dumping the pixels was successful, then hide the tile.
|
||||||
// Do not remove the tile itself, as it is needed to check if the whole
|
// Do not remove the tile itself, as it is needed to check if the whole
|
||||||
// level (and its canvas) should be removed (via level.el.children.length)
|
// level (and its canvas) should be removed (via level.el.children.length)
|
||||||
tile.el.style.display = 'none';
|
tile.el.style.display = "none";
|
||||||
},
|
},
|
||||||
|
|
||||||
// @section Extension methods
|
// @section Extension methods
|
||||||
// @uninheritable
|
// @uninheritable
|
||||||
|
|
||||||
// @method dumpPixels(coords: Object, imageSource: CanvasImageSource): this
|
// @method dumpPixels(coords: Object, imageSource: CanvasImageSource): this
|
||||||
// Dumps pixels from the given `CanvasImageSource` into the layer, into
|
// Dumps pixels from the given `CanvasImageSource` into the layer, into
|
||||||
// the space for the tile represented by the `coords` tile coordinates (an object
|
// the space for the tile represented by the `coords` tile coordinates (an object
|
||||||
// like `{x: Number, y: Number, z: Number}`; the image source must have the
|
// like `{x: Number, y: Number, z: Number}`; the image source must have the
|
||||||
// same size as the `tileSize` option for the layer. Has no effect if `dumpToCanvas`
|
// same size as the `tileSize` option for the layer. Has no effect if `dumpToCanvas`
|
||||||
// is `false`.
|
// is `false`.
|
||||||
dumpPixels: function (coords, imageSource) {
|
dumpPixels: function(coords, imageSource) {
|
||||||
var level = this._levels[coords.z],
|
var level = this._levels[coords.z],
|
||||||
tileSize = this.getTileSize();
|
tileSize = this.getTileSize();
|
||||||
|
|
||||||
if (!level.canvasRange || !this.options.dumpToCanvas) {
|
if (!level.canvasRange || !this.options.dumpToCanvas) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the tile is inside the currently visible map bounds
|
// Check if the tile is inside the currently visible map bounds
|
||||||
// There is a possible race condition when tiles are loaded after they
|
// There is a possible race condition when tiles are loaded after they
|
||||||
// have been panned outside of the map.
|
// have been panned outside of the map.
|
||||||
if (!level.canvasRange.contains(coords)) {
|
if (!level.canvasRange.contains(coords)) {
|
||||||
this._resetCanvasSize(level);
|
this._resetCanvasSize(level);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Where in the canvas should this tile go?
|
// Where in the canvas should this tile go?
|
||||||
var offset = L.point(coords.x, coords.y)
|
var offset = L.point(coords.x, coords.y)
|
||||||
.subtract(level.canvasRange.min)
|
.subtract(level.canvasRange.min)
|
||||||
.scaleBy(this.getTileSize());
|
.scaleBy(this.getTileSize());
|
||||||
|
|
||||||
level.ctx.drawImage(
|
level.ctx.drawImage(imageSource, offset.x, offset.y, tileSize.x, tileSize.y);
|
||||||
imageSource,
|
|
||||||
offset.x,
|
|
||||||
offset.y,
|
|
||||||
tileSize.x,
|
|
||||||
tileSize.y,
|
|
||||||
);
|
|
||||||
|
|
||||||
// TODO: Clear the pixels of other levels' canvases where they overlap
|
// TODO: Clear the pixels of other levels' canvases where they overlap
|
||||||
// this newly dumped tile.
|
// this newly dumped tile.
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,162 +1,162 @@
|
||||||
(function (window) {
|
(function(window) {
|
||||||
var HAS_HASHCHANGE = (function () {
|
var HAS_HASHCHANGE = (function() {
|
||||||
var doc_mode = window.documentMode;
|
var doc_mode = window.documentMode;
|
||||||
return 'onhashchange' in window && (doc_mode === undefined || doc_mode > 7);
|
return ('onhashchange' in window) &&
|
||||||
})();
|
(doc_mode === undefined || doc_mode > 7);
|
||||||
|
})();
|
||||||
|
|
||||||
L.Hash = function (map) {
|
L.Hash = function(map) {
|
||||||
this.onHashChange = L.Util.bind(this.onHashChange, this);
|
this.onHashChange = L.Util.bind(this.onHashChange, this);
|
||||||
|
|
||||||
if (map) {
|
if (map) {
|
||||||
this.init(map);
|
this.init(map);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
L.Hash.parseHash = function (hash) {
|
L.Hash.parseHash = function(hash) {
|
||||||
if (hash.indexOf('#') === 0) {
|
if(hash.indexOf('#') === 0) {
|
||||||
hash = hash.substr(1);
|
hash = hash.substr(1);
|
||||||
}
|
}
|
||||||
var args = hash.split('/');
|
var args = hash.split("/");
|
||||||
if (args.length == 3) {
|
if (args.length == 3) {
|
||||||
var zoom = parseInt(args[0], 10),
|
var zoom = parseInt(args[0], 10),
|
||||||
lat = parseFloat(args[1]),
|
lat = parseFloat(args[1]),
|
||||||
lon = parseFloat(args[2]);
|
lon = parseFloat(args[2]);
|
||||||
if (isNaN(zoom) || isNaN(lat) || isNaN(lon)) {
|
if (isNaN(zoom) || isNaN(lat) || isNaN(lon)) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
center: new L.LatLng(lat, lon),
|
center: new L.LatLng(lat, lon),
|
||||||
zoom: zoom,
|
zoom: zoom
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
(L.Hash.formatHash = function (map) {
|
L.Hash.formatHash = function(map) {
|
||||||
var center = map.getCenter(),
|
var center = map.getCenter(),
|
||||||
zoom = map.getZoom(),
|
zoom = map.getZoom(),
|
||||||
precision = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2));
|
precision = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2));
|
||||||
|
|
||||||
return (
|
return "#" + [zoom,
|
||||||
'#' +
|
center.lat.toFixed(precision),
|
||||||
[zoom, center.lat.toFixed(precision), center.lng.toFixed(precision)].join(
|
center.lng.toFixed(precision)
|
||||||
'/',
|
].join("/");
|
||||||
)
|
},
|
||||||
);
|
|
||||||
}),
|
|
||||||
(L.Hash.prototype = {
|
|
||||||
map: null,
|
|
||||||
lastHash: null,
|
|
||||||
|
|
||||||
parseHash: L.Hash.parseHash,
|
L.Hash.prototype = {
|
||||||
formatHash: L.Hash.formatHash,
|
map: null,
|
||||||
|
lastHash: null,
|
||||||
|
|
||||||
init: function (map) {
|
parseHash: L.Hash.parseHash,
|
||||||
this.map = map;
|
formatHash: L.Hash.formatHash,
|
||||||
|
|
||||||
// reset the hash
|
init: function(map) {
|
||||||
this.lastHash = null;
|
this.map = map;
|
||||||
this.onHashChange();
|
|
||||||
|
|
||||||
if (!this.isListening) {
|
// reset the hash
|
||||||
this.startListening();
|
this.lastHash = null;
|
||||||
}
|
this.onHashChange();
|
||||||
},
|
|
||||||
|
|
||||||
removeFrom: function (map) {
|
if (!this.isListening) {
|
||||||
if (this.changeTimeout) {
|
this.startListening();
|
||||||
clearTimeout(this.changeTimeout);
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
if (this.isListening) {
|
removeFrom: function(map) {
|
||||||
this.stopListening();
|
if (this.changeTimeout) {
|
||||||
}
|
clearTimeout(this.changeTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
this.map = null;
|
if (this.isListening) {
|
||||||
},
|
this.stopListening();
|
||||||
|
}
|
||||||
|
|
||||||
onMapMove: function () {
|
this.map = null;
|
||||||
// bail if we're moving the map (updating from a hash),
|
},
|
||||||
// or if the map is not yet loaded
|
|
||||||
|
|
||||||
if (this.movingMap || !this.map._loaded) {
|
onMapMove: function() {
|
||||||
return false;
|
// bail if we're moving the map (updating from a hash),
|
||||||
}
|
// or if the map is not yet loaded
|
||||||
|
|
||||||
var hash = this.formatHash(this.map);
|
if (this.movingMap || !this.map._loaded) {
|
||||||
if (this.lastHash != hash) {
|
return false;
|
||||||
location.replace(hash);
|
}
|
||||||
this.lastHash = hash;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
movingMap: false,
|
var hash = this.formatHash(this.map);
|
||||||
update: function () {
|
if (this.lastHash != hash) {
|
||||||
var hash = location.hash;
|
location.replace(hash);
|
||||||
if (hash === this.lastHash) {
|
this.lastHash = hash;
|
||||||
return;
|
}
|
||||||
}
|
},
|
||||||
var parsed = this.parseHash(hash);
|
|
||||||
if (parsed) {
|
|
||||||
this.movingMap = true;
|
|
||||||
|
|
||||||
this.map.setView(parsed.center, parsed.zoom);
|
movingMap: false,
|
||||||
|
update: function() {
|
||||||
|
var hash = location.hash;
|
||||||
|
if (hash === this.lastHash) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var parsed = this.parseHash(hash);
|
||||||
|
if (parsed) {
|
||||||
|
this.movingMap = true;
|
||||||
|
|
||||||
this.movingMap = false;
|
this.map.setView(parsed.center, parsed.zoom);
|
||||||
} else {
|
|
||||||
this.onMapMove(this.map);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// defer hash change updates every 100ms
|
this.movingMap = false;
|
||||||
changeDefer: 100,
|
} else {
|
||||||
changeTimeout: null,
|
this.onMapMove(this.map);
|
||||||
onHashChange: function () {
|
}
|
||||||
// throttle calls to update() so that they only happen every
|
},
|
||||||
// `changeDefer` ms
|
|
||||||
if (!this.changeTimeout) {
|
|
||||||
var that = this;
|
|
||||||
this.changeTimeout = setTimeout(function () {
|
|
||||||
that.update();
|
|
||||||
that.changeTimeout = null;
|
|
||||||
}, this.changeDefer);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
isListening: false,
|
// defer hash change updates every 100ms
|
||||||
hashChangeInterval: null,
|
changeDefer: 100,
|
||||||
startListening: function () {
|
changeTimeout: null,
|
||||||
this.map.on('moveend', this.onMapMove, this);
|
onHashChange: function() {
|
||||||
|
// throttle calls to update() so that they only happen every
|
||||||
|
// `changeDefer` ms
|
||||||
|
if (!this.changeTimeout) {
|
||||||
|
var that = this;
|
||||||
|
this.changeTimeout = setTimeout(function() {
|
||||||
|
that.update();
|
||||||
|
that.changeTimeout = null;
|
||||||
|
}, this.changeDefer);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
if (HAS_HASHCHANGE) {
|
isListening: false,
|
||||||
L.DomEvent.addListener(window, 'hashchange', this.onHashChange);
|
hashChangeInterval: null,
|
||||||
} else {
|
startListening: function() {
|
||||||
clearInterval(this.hashChangeInterval);
|
this.map.on("moveend", this.onMapMove, this);
|
||||||
this.hashChangeInterval = setInterval(this.onHashChange, 50);
|
|
||||||
}
|
|
||||||
this.isListening = true;
|
|
||||||
},
|
|
||||||
|
|
||||||
stopListening: function () {
|
if (HAS_HASHCHANGE) {
|
||||||
this.map.off('moveend', this.onMapMove, this);
|
L.DomEvent.addListener(window, "hashchange", this.onHashChange);
|
||||||
|
} else {
|
||||||
|
clearInterval(this.hashChangeInterval);
|
||||||
|
this.hashChangeInterval = setInterval(this.onHashChange, 50);
|
||||||
|
}
|
||||||
|
this.isListening = true;
|
||||||
|
},
|
||||||
|
|
||||||
if (HAS_HASHCHANGE) {
|
stopListening: function() {
|
||||||
L.DomEvent.removeListener(window, 'hashchange', this.onHashChange);
|
this.map.off("moveend", this.onMapMove, this);
|
||||||
} else {
|
|
||||||
clearInterval(this.hashChangeInterval);
|
if (HAS_HASHCHANGE) {
|
||||||
}
|
L.DomEvent.removeListener(window, "hashchange", this.onHashChange);
|
||||||
this.isListening = false;
|
} else {
|
||||||
},
|
clearInterval(this.hashChangeInterval);
|
||||||
});
|
}
|
||||||
L.hash = function (map) {
|
this.isListening = false;
|
||||||
return new L.Hash(map);
|
}
|
||||||
};
|
};
|
||||||
L.Map.prototype.addHash = function () {
|
L.hash = function(map) {
|
||||||
this._hash = L.hash(this);
|
return new L.Hash(map);
|
||||||
};
|
};
|
||||||
L.Map.prototype.removeHash = function () {
|
L.Map.prototype.addHash = function() {
|
||||||
this._hash.removeFrom();
|
this._hash = L.hash(this);
|
||||||
};
|
};
|
||||||
|
L.Map.prototype.removeHash = function() {
|
||||||
|
this._hash.removeFrom();
|
||||||
|
};
|
||||||
})(window);
|
})(window);
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1656
public/resources/maplibre-gl-inspect-compat.min.js
vendored
1656
public/resources/maplibre-gl-inspect-compat.min.js
vendored
File diff suppressed because one or more lines are too long
1599
public/resources/maplibre-gl-inspect.min.js
vendored
1599
public/resources/maplibre-gl-inspect.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue