Skip to content
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

Feature to fetch style.json from a url #1460

Open
YoelRidgway opened this issue Feb 6, 2025 · 3 comments · May be fixed by #1462
Open

Feature to fetch style.json from a url #1460

YoelRidgway opened this issue Feb 6, 2025 · 3 comments · May be fixed by #1462

Comments

@YoelRidgway
Copy link

It would be nice to be able to define a stylesheet from a url in the configuration. I imagine it would look something like this in the config:

"styles": {
    "remote": {
      "style": "https://api.maptiler.com/maps/streets-v2/style.json?key=********************",
      "tilejson": {
        "type": "overlay"
      }
    },
}

Would this be possible? I was thinking that the style could be fetched when the app is launched (or if the config is reloaded using SIGHUP). I could probably add this feature myself, but would like to get the opinion of any contributors first in case there is a good reason not to add this.

@acalcutt
Copy link
Collaborator

acalcutt commented Feb 7, 2025

there was some discussion about that before in https://osmus.slack.com/archives/C0436FK28C9/p1698761198318819

I think mainly this code would need to be changed to read from a http url if the file started with http
https://github.com/maptiler/tileserver-gl/blob/master/src/serve_style.js#L215-L221

@YoelRidgway
Copy link
Author

Hey thanks for the response. I don't have access to the osmus slack, so don't know what was discussed there, but I can implement this if no one has anything against it.

That said, I suppose adding a fetch to this part of the code would require quite a bit of refactoring to make the add function async. I see that there is a TODO note mentioning this and it would be good for file reading performance so I suppose it should happen at some point!

@acalcutt
Copy link
Collaborator

acalcutt commented Feb 9, 2025

I think a feature like this would be a good addition.

There would be a few places that might need some check if the path is a http string. I had mentioned in the slack we were using isValidHttpUrl in utils.js in some places for the pmtiles urls.

@YoelRidgway YoelRidgway linked a pull request Feb 10, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants