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

Run-time styling options before calling render #26

Open
charandas opened this issue Mar 20, 2019 · 1 comment
Open

Run-time styling options before calling render #26

charandas opened this issue Mar 20, 2019 · 1 comment

Comments

@charandas
Copy link

charandas commented Mar 20, 2019

I would love to be able to do map.setPaintProperty before this library calls map.render to give me the png output.

The motivation would be that runtime styling in GL JS actually returns proper errors like:

Could not parse color from value 'FFFFFF' TypeError: [2]: Could not parse color from value 'FFFFFF'
    at /Users/charandas/serve/asurity/RiskExec/static-maps/node_modules/mbgl-renderer/dist/render.js:486:13

Whereas if my style.json has an incorrect color like that, it just fails silently to apply the expression to say, fill-color.

Also, run-time styling would be nice for the calling-user as they won't be interfacing with style.json but instead have access to all map APIs supported by gl-native. Also, for context, runtime styling options for node seem to be mature and have been in support since at least 2017.

render(style, width, height, {
  zoom,
  center,
  token: process.env.MAPBOX_TOKEN,
  tilePath: path.resolve(__dirname, 'styles'),
  preRenderFn: (map) => map.setPaintProperty('my-layer', 'fill-color', myExpr) 
})
@brendan-ward
Copy link
Collaborator

@charandas this is an interesting idea. Definitely makes me wish we got better errors for invalid styles than we do now.

I'm open to your idea of using a preRender function - but I don't have the time at the moment to implement that. Open to PRs, if you want to rough out something along these lines.

meowcoder added a commit to meowcoder/mbgl-renderer that referenced this issue Jun 9, 2020
- see consbio#26 for preRenderFn.
- pngOptions are passed to the sharp.png() method as is.
meowcoder added a commit to meowcoder/mbgl-renderer that referenced this issue Jul 5, 2020
- see consbio#26 for preRenderFn.
- pngOptions are passed to the sharp.png() method as is.
meowcoder added a commit to meowcoder/mbgl-renderer that referenced this issue Jul 5, 2020
- see consbio#26 for preRenderFn.
- pngOptions are passed to the sharp.png() method as is.
meowcoder added a commit to meowcoder/mbgl-renderer that referenced this issue Jul 7, 2020
- see consbio#26 for preRenderFn.
- pngOptions are passed to the sharp.png() method as is.
meowcoder added a commit to meowcoder/mbgl-renderer that referenced this issue Jul 7, 2020
- see consbio#26 for preRenderFn.
- pngOptions are passed to the sharp.png() method as is.
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

2 participants