tanc
tanc

Reputation: 321

Mapbox - what determines at which zoom level a country label is displayed?

This question is about Mapbox Studio. My use case is showing a map of tax treaties between various countries where some very small countries are important due to being tax havens, for example Mauritius. The label for the island of Mauritius is only displayed at map zoom level 2 or higher whereas it would be useful to show this label at the same prominence as other larger countries. Are the labels baked into the Mapbox tiles or is there a way of controlling when they appear?

I've discovered that you can further filter which countries are shown, but not control this initial setting of which zoom level they appear at.

Upvotes: 2

Views: 2958

Answers (2)

Mateus Ferreira
Mateus Ferreira

Reputation: 529

You can customize this by ejecting the component that the label belongs to. Then, by selecting the layer and navigating to the "Select data" tab, you can then customize the "zoom extend" and "filters", which control this.

Upvotes: 0

Adriana Babakanian
Adriana Babakanian

Reputation: 1299

Most times, when wanting to change the styling of a particular label, the best approach would be to follow this guide on customizing label text for a single label. However, as you mentioned, the island of Mauritius is only displayed at map zoom level 2. We can determine that this is a limitation of how the source data is being included in the Mapbox Streets tileset by following the steps outlined below. Sometimes, data does not appear in a map style because of the way it is styled (i.e. how the properties are specified for the relevant layer), whereas other times it does not appear because it is simply not included in the underlying tileset at that particular zoom level. Tilesets conditionally include data at different zoom levels for performance enhancements.

  1. Navigate to the relevant layer of the style (in this case, the country-label symbol layer).
  2. Switch to the Select data tab. This view allows you to see which labels are visible at a particular zoom level.
  3. Explore different zoom levels to see the green features which are included at that zoom level. Here, we see that Mauritius is not present at z1.99 but is at z2.

Zoom 1.99 Zoom 2

Fortunately, much of the data behind Mapbox Streets comes from OpenStreetMap and you can download the data you need using a number of different methods, to then be included in your map style:

  1. Download the data you would like to work with using Overpass Turbo.
  2. From here, you have two options to tile your data - you can either use the Mapbox Tilesets API or the Mapbox-created open source tool Tippecanoe. You can learn how to adjust the zoom extent of your data using either tool in this guide.
  3. Upload the tileset created in the previous step to your Mapbox account.
  4. Add a new layer in your style that references this tileset. You can then specify this layer to show at zoom levels lower than z2.

If there are only a few country labels that you'd like to add, it might be easier to manually create a GeoJSON file with the labels and coordinates, and then tile this data with the Tilesets API, rather than downloading the data with Overpass Turbo.

Upvotes: 5

Related Questions