This tutorial will walk you through how to use expressions in the Mapbox Studio style editor to customize the label text for a single label.
The final product will show adjusted country label tags as seen below:
Let's create a new style in Mapbox Studio. A style is a set of rules for how Mapbox will draw your map and its data on the page.
A style defines how all your data should be styled and includes references to your data and map images (icons, markers, patterns), fonts. For more about styles, see the Styles section of the Mapbox Studio Manual.
The Mapbox Studio style editor is a visual tool for creating custom map styles, for example adjusting place label components.
For this tutorial, we'll adjust the country labels, so let's start by focusing your style on the country layer of labels:
Now with these adjustments, you should only see country labels on the globe.
You can customize the country labels based on conditions and properties within the data by doing the following:
name_en
to style the label based on the English name for the country.France
and click + use France
at the bottom of the prompt
Text field
, before coalesce
, add "Land in: "
and click on & to combine your two strings.Now you will see the France
label change to Land in: France
on your map.
Spain
and then "First stop: "
in the Text field
box.You've updated your map using expressions to display custom labels for specific labels.
To learn more about using the Mapbox Studio style editor, read the Mapbox Studio Manual.