-
-
Notifications
You must be signed in to change notification settings - Fork 691
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
Allow relative URL paths in styles #645
Conversation
Any input to the approach I'm taking or to the open questions in the todos is very welcome. |
Bundle size report: Size Change: +165 B
ℹ️ View Details
|
Thanks a lot for looking into this!! |
I agree about the spread out implementation. I was thinking about having some state in RequestManager instead, but this would make it necessary to have different RequestManagers in different places. The name and also the usage suggests to me at the moment that RequestManager should be a singleton. For instance a call to Is there an accepted/non-hacky pattern so that I can have different RequestManager objects with different included baseUrls but which all refer to the same global _transformRequestFn? Would that be a better solution? |
Hmm... Is there a way to achieve this using transform request only without changing the code? It feels like this should be possible... |
No, because the transform request no longer has the appropriate base url. it would need to guess based on the url itself and its ResourceType from where the url came which can never be completely correct and would be a hack. Also I think this is the more useful behavior so it should imho be the default. |
I think it would be interesting to try and hack it - even if it's not 100% correct all the time it can provide a solution that doesn't require code changes for something that's not "mainstream". |
Just to be clear:
what do you mean by plugin? I don't know of any plugin mechanism which could help here. |
maplibre plugin, for example the mapbox-draw plugin, mapbox-geocoder etc. |
|
The cleanest way to implement this would imho be to replace RequestManager by a RequestContext which has no state of its own but pointers to the map,style and source in the context of which a request is made. The transform request function would be part of the map state and the different RequestContext objects could access it with their reference to the map object. But doing it this way will be a larger diff and touch more places as the minimalistic approach in this pull request. |
I think someone else besides me should review it and decide. I don't think this is a waste of time and I'm sorry you feel this way... |
No hard feelings on my side, the investment so far wasn't that much. Its just that I have a hard time to understand if this approach would make it in if cleaned up a bit (like not abusing setUrl to also set an extra value) or if the changes are too invasive anyway and I should therefore not continue with it. So I'm waiting on more input on the best way forward to get something accepted. |
This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
This should remain open. |
This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
Aha, a stale bot message! @xabbu42 any updates? |
I'd need more input on the open question in the todos as well as on the best approach to pass baseUrl around to continue working on this. I'm still interested to get this in. |
This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
This PR was closed because it has been stalled for 30 days with no activity. |
Really looking forward for this as ArcGIS Pro seems to output relative paths.. To the question auf new URL(url, style).toString() Where
|
This uses the url of the style (or of the tilejson) as base url for relative urls. Before the referrer was used everywhere (that is the the url of the map application itself).
With this patches you can for example directly use
https://basemaps.arcgis.com/arcgis/rest/services/World_Basemap_v2/VectorTileServer/resources/styles/
as style url and everything works.This fixes #182.
Todo
Launch Checklist
maplibre-gl-js
changelog:<changelog>Intepret urls in json files relative to the location of the json itself.</changelog>
.