Exclude labels that are outside a designated region in Mapbox Studio

Viewed 822

I'm currently working on a visualization on Mapbox that's focused on a given region, let's say Texas for the sake of this example. I want to make it so this region is emphasized on the map, with everything else faded to the background.

So far I've managed to import Natural Earth's shapefiles into Mapbox Studio in order to make everywhere outside of Texas a shade darker:

map of the southern united states with texas outlined in a lighter shade of gray

This is great, but ideally I'd like to hide all of Mapbox's labels that are outside of Texas. I've been trying to use filters in Mapbox studio to "filter out" all of the items on each layer, but it appears their layer settings don't allow me to filter based on a geospacial attribute (only data attributes).

Does anyone know of a way for me to hide all city labels outside of Texas; either programatically on the js Mapbox GL library, or ideally via Mapbox Studio?

1 Answers

In Mapbox Studio, select the layer. Then click 'select data' and then 'filter'. There should be an option to filter the layer by the ISO/parent. I've done the same with admin-1 labels to restrict to only US enter image description here

Related