Skip to content

Run-time styling options before calling render #26

@charandas

Description

@charandas

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) 
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions