Usage as NPM bundle
Closed this issue · 4 comments
pke commented
Thanks for the plugin. It would be nice if it would not depend on globals like L
so it could be used when "leaflet" is imported into an ES6 project with different names than L
.
This would then allow us to:
import { GridLayer } from "leaflet"
import { edgeBuffer } from "leaflet-edgebuffer"
edgeBuffer(GridLayer)
TolonUK commented
Hi pke, I've personally not done anything with ES6 projects/modules yet, but would using the loading template at https://github.com/Leaflet/Leaflet/blob/master/PLUGIN-GUIDE.md#module-loaders solve the issue?
pke commented
This version in this repo is not the one published as 1.0.0.
The src
of the published version contains:
(function(previousMethods){
if (typeof previousMethods === 'undefined') {
// Defining previously that object allows you to use that plugin even if you have overridden L.map
previousMethods = {
getTiledPixelBounds: L.GridLayer.prototype._getTiledPixelBounds
};
}
L.GridLayer.include({
_getTiledPixelBounds : function(center, zoom, tileZoom) {
var pixelBounds = previousMethods.getTiledPixelBounds.call(this, center, zoom, tileZoom);
if (this.options.edgeBufferTiles > 0) {
var pixelEdgeBuffer = this.options.edgeBufferTiles * this._getTileSize();
pixelBounds = new L.Bounds(pixelBounds.min.subtract([pixelEdgeBuffer, pixelEdgeBuffer]), pixelBounds.max.add([pixelEdgeBuffer, pixelEdgeBuffer]));
}
return pixelBounds;
}
});
})(window.leafletEdgeBufferPreviousMethods);
What's wrong?
TolonUK commented
Is this really relevant to supporting import for ES6? Surely these are separate issues?
TolonUK commented
Should now be fixed in v1.0.2