t-rex icon indicating copy to clipboard operation
t-rex copied to clipboard

Is it possible to have variables/placeholders in style.json file?

Open dmitrykinakh opened this issue 5 years ago • 3 comments

Hi @pka,

I'm interested if Trex supports passing variables to the style.json file into the filters section.

For example: Right now in the project were we display vector tiles we do that per city so to display Miami and North Miami we need to create two style files. Smth, like:

  • fl-state-place-1245000.style.json
  • fl-state-place-1249450.style.json

Inside each of those files, we specify filter right now: image

We are looking for a way how to optimize that and have only 1 file (in reality we support ~30 cities right now), so there will be like one file called fl-state-place-{placeholder of city id here}.style.json and as a result, {placeholder of city id here} will be applied for the filter in section I've mentioned above. Is this possible?

dmitrykinakh avatar Aug 12 '20 08:08 dmitrykinakh

Back in version 0.7.0 I've added styling in the configuration file which looked like

[tileset.layer.style]
  type = "fill"
  [tileset.layer.style.paint]
  fill-color = "#d8e8c8"
  fill-opacity = 0.5

but I found it too cumbersome to follow the MBGL JSON changes. Therefore I decided to generate a minimal style file which is normally replaced by a custom made style (created with Maputnik e.g.). If you want to serve the style with t-rex you can place it as static file configured in the webserver section.

pka avatar Aug 12 '20 20:08 pka

@pka - I'm not interested in this anymore. Feel free to close this.

dmitrykinakh avatar Oct 28 '21 11:10 dmitrykinakh

I leave that open, since styles with runtime parameters could be interesting for others as well.

pka avatar Oct 28 '21 19:10 pka