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

Add support for easy custom layer generation in generate-layers #261

Open
benjaminpreiss opened this issue Jun 20, 2024 · 6 comments
Open

Comments

@benjaminpreiss
Copy link

Description
It should be easily possible to generate custom style layers with generate-layers.
I will create a pull request that allows the following syntax: npx protomaps-themes-base protomaps.

Notice the missing theme key at the end!
The pull request will then look for a file named protomapsStyles.ts in the current directory and then generate the layers based on the specs from this file.

@benjaminpreiss
Copy link
Author

Somehow I can't link the pull request I created :(

@nvkelso
Copy link
Collaborator

nvkelso commented Jun 20, 2024

Weird that it won't auto link.

Alternatively, can you paste a link to the PR url here?

@nvkelso
Copy link
Collaborator

nvkelso commented Jun 20, 2024

Found it! #262

@bdon
Copy link
Member

bdon commented Jun 22, 2024

look for a file named protomapsStyles.ts

Is your feature request simply to call generate_layers on a .ts file with a defined theme (instead of one of the pre-built ones), and output a JSON style on stdout?

We should be able to accomplish this without any additional dependency.

@benjaminpreiss
Copy link
Author

benjaminpreiss commented Jun 23, 2024

Yes, that is correct - more specifically, I want to execute generate_layers from NPM and not by cloning the whole repo...
Do you know a better way how a .ts file can be executed from within JS?

@bdon
Copy link
Member

bdon commented Sep 3, 2024

We removed generate-layers in favor of generate-style, which creates a full MapLibre style object with sensible defaults for glyphs, sprite etc instead of requiring you to construct these yourself.

The 4.x version of the protomaps-themes-base package also requires passing a language code like en or de when generating a style. This isn't released in NPM yet.

For generating a custom style on the command line here is a proposal of what it would look like:

83bfb9b

We can use the existing dependency tsx for importing a .ts module so don't need jiti

However I'm not sure if a command like npm run generate-style https://example.com/tiles.json myStyle.ts en out.json is the most intuitive compared to storing a custom theme as a JSON object.

For a custom theme to be a .ts it requires a default export, it is more convenient to have type-checking but it really depends on what TypeScript environment the .ts lives in. Any suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants