You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is more of a question than an issue. I would like to have a fallback on local PBF files while offline, so basically instead of retrieving them via HTTP, override the behaviour and load a file from my hard drive. I can do this very easily in leaflet classic TMS layers with some code like:
L.TileLayer.Common = L.TileLayer.extend({
getTileUrl: function (tilePoint, tile) {
... do something clever
}
});
Works very well and I am very happy with that behaviour that allows me to override leaflet function without having to modify leaflet's core.
I would like to do the same with mapbox-gl-js but it seems like the way it is architectured makes it hard to override functions/behaviours because you can only see what's exported publicly, not the inside functions.
I found the part of the code that I need to override:
Which calls "getArrayBuffer", which have been initialized as a local variable with
var getArrayBuffer = require('../util/ajax').getArrayBuffer;
From the outside, here is what the debugger can see:
Very little, only main objects and their prototype. I could modify util.getArrayBuffer but it is too late because Worker already "copied" it locally.
I am not so used to "require" and how it works but it looks like you can't access what's outside of the exports, so I can't "hack" very far.
Only solution I see is to modify the source code for getArrayBuffer and recompile my own version of mapbox-gl-js but i would rather not do that.
If there is some JS wizardry that would allow me to do it, i would be very interested :)
Thanks!
The text was updated successfully, but these errors were encountered:
I think your best bet is to set the source URL to either a remote URL or file:// URL depending on offline status. We'll keep the offline use case in mind but allowing access to private implementation details of gl-js isn't something we're likely to do.
Hello,
This is more of a question than an issue. I would like to have a fallback on local PBF files while offline, so basically instead of retrieving them via HTTP, override the behaviour and load a file from my hard drive. I can do this very easily in leaflet classic TMS layers with some code like:
Works very well and I am very happy with that behaviour that allows me to override leaflet function without having to modify leaflet's core.
I would like to do the same with mapbox-gl-js but it seems like the way it is architectured makes it hard to override functions/behaviours because you can only see what's exported publicly, not the inside functions.
I found the part of the code that I need to override:
mapbox-gl-js/js/source/worker_tile.js
Line 32 in 0eb16da
Which calls "getArrayBuffer", which have been initialized as a local variable with
From the outside, here is what the debugger can see:
Very little, only main objects and their prototype. I could modify util.getArrayBuffer but it is too late because Worker already "copied" it locally.
I am not so used to "require" and how it works but it looks like you can't access what's outside of the exports, so I can't "hack" very far.
Only solution I see is to modify the source code for getArrayBuffer and recompile my own version of mapbox-gl-js but i would rather not do that.
If there is some JS wizardry that would allow me to do it, i would be very interested :)
Thanks!
The text was updated successfully, but these errors were encountered: