-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resource transforms: alter URLs before requesting #4740
Comments
Will this feature make it possible to have relative URLs for certain properties in the map style JSON? E.g.: {
...
"spritesheet": "my/local/spritesheet"
} A callback could resolve this relative url and return an absolute one. |
@Scarysize - the changes proposed in #4763 do not allow pure relative URLs in the
|
That was my intention. Thanks for confirming that 🙌 |
Will this kinda make the following Possible: To load "local"-Tiles like
on iOS, I have to transform the FileURL from e.g. location.href + "/../germany/14/1111/{2222.pbf" Thanx for any Help |
@volkergraf I believe you are asking for #4917. #5021 will allow transforming the URL as you've mentioned above. Not being familiar with Cordova, I do not know if a blob url from Cordova, returned from |
@asheemmamoowala Well THIS I can definively can confirm (using the cordova-file-plugin and the local-URl-Fix).. to test it I created such an URL form an Object like ./germany/14/8601/5648.pbf -> blob:file:///55e863d2-00d0-4712-b7ad-ab2792505e14
And I see the tile .. but well everywhere =) .. but at least I see that it's beeing loaded =) |
@asheemmamoowala I do not believe this addresses my use case as there are significant limits on the size of blobs and they differ based on browser and version. Cordova provides an SQLLite plugin that allows you to query sqlite databases directly which is how I have implemented my local mbtiles support that I mention in #5021 Having a mechanism to pass the buck back to the main thread where a user supplied object can handle the request and return the data is the approach I have chosen for my implementation in : Take a look at I've replaced every call to ajax.js with calls to my resourceLoader. If the requested resources is a remote resource, it forwards the request to ajax.js business as usual. If, however, the requested resources has a scheme of file:// it forwards the request back to the main thread where a user supplied object handles it and then returns the result. This approach requires minimal changes to the code but opens up the possibility for feeding arbitrary local sources of data into the mapping API programmatically. Also, in my use case, I modify the local mbtiles file depending on what the user wants to download. (Consider the case of downloading minimal detail maps of individual US states for use when one is offline. In my app, users will spend significant time without connectivity.) It's currently an ugly hack, but it works like a champ and at least on my iPhone 6 I don't notice any performance degradation yet, but I am still in the proof of concept phase. Separately, using the blob approach, I'm not sure how one would distribute the blob with a Cordova app? |
Fixed in #5021 |
In Native, we have added "Resource transforms", which allows you to supply a function that is called every time a URL is requested. That function can perform arbitrary operations on the URL string, and the returned URL will be requested. We should implement this in GL JS for API parity.
The text was updated successfully, but these errors were encountered: