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

Serve styles #1607

Open
artyomb opened this issue Dec 9, 2024 · 7 comments
Open

Serve styles #1607

artyomb opened this issue Dec 9, 2024 · 7 comments
Labels
cli Related to Command Line Interface config Relates to Martin configuration help wanted serving Related to web serving component

Comments

@artyomb
Copy link

artyomb commented Dec 9, 2024

Is it possible to configure support for serving static files or Mapbox-style JSON files using a configuration file?

static:
 - /path/to/static_dir

or

styles:
 - /path/to/styles_dir

Additionally, when serving Mapbox-style JSON files specifically, could the system automatically add related fonts, sprites, and sources to the file?

@CommanderStorm
Copy link
Collaborator

when serving Mapbox-style JSON files specifically, could the system automatically add related fonts, sprites, and sources to the file?

This part is a bit unclear, what do you mean by this specifically?

And yes, adding styles would defintively be required to implement this feature:

@artyomb
Copy link
Author

artyomb commented Dec 9, 2024

The following sections could be added automatically:

mapbox_style.json:

...
"glyphs": ".../fonts/{fontstack}/{range}.pbf",
"sprite": ".../sprites",
...
"sources": [
    "source_name": {
      "type": "vector",
      "url": "/tiles/.../tiles.json"
    },
]

@CommanderStorm
Copy link
Collaborator

I don't think that this would work as you intended. We would need to

  • (solvable) pick source_name dependent on the stlyes usage
  • decide if the user wants sdf or regular sprites
  • decide which vector/sprite source a user needs to display the map they want

In particular because of the last issue, we would need to do the wrong kind of magic. I.e. the kind which does unintended things easily and is hard to debug our users).
=> I think our users will be much less confused without automatically adding this information

@artyomb
Copy link
Author

artyomb commented Dec 11, 2024

This feature could be optional. Styles are typically served as static files, but they may also support templating, such as:

...
"glyphs": "{{ .Fonts }}",
"sprite": "{{ .SdfSprites.base }}",
...
"sources": [
  {{range .Sources}}
    "{{.Name}}": {
      "type": "vector",
      "url": "{{.TileJson}}"
    },
  {{end}}
]

@CommanderStorm CommanderStorm changed the title Serve static files or Style.json Serve styles Dec 12, 2024
@CommanderStorm CommanderStorm added serving Related to web serving component and removed enhancement labels Feb 1, 2025
@CommanderStorm
Copy link
Collaborator

Lets track the work needed to resolve this issue in #518 instead.

@nyurik
Copy link
Member

nyurik commented Feb 10, 2025

I think we may need to focus on this issue rather than the more generic (and possibly less needed?) #518.

Use cases

  • Martin needs to update URLs in a style to point to other resources served by Martin depending on the requesting server (we already do that for tilejson).
  • Martin needs to know which styles are available to enable server-side rendering
  • Martin should make all available styles show up in Maputnik when we integrate it
  • When running on a localhost, Martin could function as a style editor by integrating with Maputnik, and saving all changes to the disk (TBD)

Config structure

styles:
  paths:
    # scan this whole dir, matching all *.json files
    # Each found file name is published as a style with the same name
    - /dir-path
    # specific json file will be published as a style, using its name
    - /path/to/osmbright.json
  sources:
    # named styles match style name to a single file
     my-osm-bright: /path/to/my-osm-bright.json

CLI

Similar to --font and --sprite, introduce --style <path> . It will work the same as paths: [...] in the config above

API

URL Description
/styles/{styleID} Style JSON
/styles/{styleID}/{z}/{x}/{y}.png Render tile as a PNG for the given location

@nyurik nyurik reopened this Feb 10, 2025
@nyurik nyurik added help wanted config Relates to Martin configuration cli Related to Command Line Interface labels Feb 10, 2025
@sharkAndshark
Copy link
Collaborator

sharkAndshark commented Feb 10, 2025

We could serve the json first and wait for the maplibre native binding released at same time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Related to Command Line Interface config Relates to Martin configuration help wanted serving Related to web serving component
Projects
None yet
Development

No branches or pull requests

4 participants