silicakes
silicakes

Reputation: 6902

mapbox gl-js: how to get the styles of points/polygons from mapbox studio and position it programmatically?

I have a map with an abundance of dynamically generated data.

I'd wish to keep the styling for this data inside mapbox studio itself - but would like to position it manually (programmatically).

The best example I've found is this: https://www.mapbox.com/mapbox-gl-js/example/data-driven-circle-colors/ however the positioning stems from mapbox studio as well.

Upvotes: 0

Views: 144

Answers (1)

silicakes
silicakes

Reputation: 6902

I've manage to achieve the above by using getPaintProperty and setPaintProperty where you can get a property from a hidden layer with something like

mapInstance.getPaintProperty("hidden layer name", "fill-color");

and set it with

setPaintProperty("visible layer id", "fill-color", valueFromTheGetMethod);

It's only good for a single property, so you need to 'manually' collect everything you need.

Upvotes: 1

Related Questions