Jacob Avery
Jacob Avery

Reputation: 21

Mapbox Filtering Multipe Tile Layers at Once

Is it possible to set a filter for multiple tile layers at once? I currently have data stored in vector tile and the filters I am applying are near instantaneous - which is awesome!

That said, I would like to filter two different geometry types (line and circle) at once on the map. Each line will be tied to a circle.

Is this possible to do easily? It would be great if anyone knows of an example.

Thanks!!

Upvotes: 1

Views: 592

Answers (1)

Steve Bennett
Steve Bennett

Reputation: 126205

Using mapbox-gl-js, it's as simple as:

for (const each layer of ['layer1', 'layer2']) {
    map.setFilter(layer, myNewFilter)
}

Or with mapbox-gl-utils:

   map.U.setFilter(['layer1', 'layer2'], myNewFilter);

Upvotes: 1

Related Questions