Unique styling for Admin Level 4 boundaries per country

410 views Asked by At

MapBox data places United States states' admin level on the same level as the division of countries within Europe and elsewhere (level 4). For my purposes, it is useful to display distinct boundaries for states in the US, while it is not useful at all to display them in Europe.

Is there a way to style these admin_level: 4 boundaries uniquely for each of these locations?

1

There are 1 answers

0
ajashton On

It is possible to apply unique per-country styles to administrative boundary lines if you are using the mapbox.mapbox-streets-v6 vector tile source. (You can check and adjust this in the Layers panel of Mapbox Studio Classic.)

In the #admin layer there is a field called iso_3166_1 that you can use to create a filter in CartoCSS. All of the admin level 4 boundaries in the US will have a iso_3166_1 code of US, so create a style like this:

#admin[admin_level=2] {
  // styles for country boundaries go here
}

#admin[admin_level=4][iso_3166_1='US'] {
  // styles for US state boundaries go here
}

Values of the iso_3166_1 field will match the ISO 3166-1 alpha-2 standard. For boundaries that separate two countries, the code for each country will be included in alphabetical order and separated by a dash. Eg the US-Mexico border would be MX-US.