ismyrnow / leaflet.functionaltilelayer Goto Github PK
View Code? Open in Web Editor NEWLeaflet tile layer with functionally defined URL and support for promises.
License: MIT License
Leaflet tile layer with functionally defined URL and support for promises.
License: MIT License
You mention IndexedDB. Can one return a createObjectUrl to a blob that was stored in an IndexedDB? (I figured out how to download a full slippy PNG map via XHR2 and store it as blobs in an IndexedDB. Now I want to create a custom tile layer for displaying it.
see: https://developer.mozilla.org/en-US/docs/DOM/window.URL.createObjectURL
and see my stack overflow: http://stackoverflow.com/questions/14113278/storing-image-data-for-offline-web-application-client-side-storage-database
A great plugin! But _tileFunction is made global in initialize, limiting the number of layers of this type to just one.
I replaced it with this._tileFunction = tileFunction;
idem on line 33 return this._tileFunction(view);
It seems that some refactoring is going on in the latest beta that breaks the FunctionalTileLayer.
Hi, I've benefitted from this plugin in a project when I had started out mapping. Just revisited it with an idea in mind and saw the callout for maintainers. Would like to apply for the same. Please feel free to get in touch, ask questions etc. I'll see if I can find the exact page where I'd applied this plugin.
When I try to use your layer with promises I get an error saying:
Uncaught TypeError: Object #<Object> has no method 'fire' leaflet.functional.tilelayer.js:55
(anonymous function) leaflet.functional.tilelayer.js:55
(anonymous function) jquery.js:3069
fire jquery.js:2913
self.fireWith jquery.js:3025
deferred.(anonymous function) jquery.js:3114
Where should fire
come from and what should it exactly do?
Thanks!
Adding a second functional tile layers seems to conflict with the first.
I dynamically add a second functional tile layer, but after I remove it, the first functional tile layer return tile URLs with paths to tiles from the second layer I just removed.
I seem to have some security issues with issuing pull requests, but here is my fixed up source:
L.TileLayer.Functional = L.TileLayer.extend({
_tileFunction: null,
initialize: function (tileFunction, options) {
this._tileFunction = tileFunction;
L.Util.setOptions(this, options);
},
getTileUrl: function (tilePoint) {
// Note: bbox code untested; pulled from TileLayer.WMS
var map = this._map,
crs = map.options.crs,
tileSize = this.options.tileSize,
//zoom = this._map.getZoom(), // remove
zoom = tilePoint.z, // add
nwPoint = tilePoint.multiplyBy(tileSize),
sePoint = nwPoint.add(new L.Point(tileSize, tileSize)),
nw = crs.project(map.unproject(nwPoint, zoom)),
se = crs.project(map.unproject(sePoint, zoom)),
bbox = [nw.x, se.y, se.x, nw.y].join(','),
view = {
bbox: bbox,
width: tileSize,
height: tileSize,
zoom: zoom,
tile: {
row: tilePoint.y,
column: tilePoint.x
},
subdomain: this._getSubdomain(tilePoint)
};
return this._tileFunction(view);
},
_loadTile: function (tile, tilePoint) {
tile._layer = this;
tile.onload = this._tileOnLoad;
tile.onerror = this._tileOnError;
this._adjustTilePoint(tilePoint);
var tileUrl = this.getTileUrl(tilePoint);
if (typeof tileUrl === "string") {
tile.src = tileUrl;
} else if (tileUrl) {
// assume jQuery.Deferred
tileUrl.done(function (tileUrl) {
tile.src = tileUrl;
});
}
}
});
L.tileLayer.functional = function (tileFunction, options) {
return new L.TileLayer.Functional(tileFunction, options);
};
It seems I can pass minZoom and maxZoom as options into the functional tile layer, but passing in maxNativeZoom doesn't behave like it does in TileLayer
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.