Customize label text for a single label
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.
Log into your Mapbox account and navigate to your Styles page. This is where all your styles are listed. A style is a set of rules for how Mapbox will draw your map on the page. It 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.
Go to your Styles page. Click the New style button. Find the Basic Template style and click Customize Basic Template. The style editor will automatically open with the Basic template style ready for editing.
The Mapbox Studio style editor is a visual tool for creating custom map styles to your exact specifications. Take a look at the layers on the left side of the style editor screen. Each layer can be customized in a variety of ways including (but not limited to) changing labels.
Click on the country-label layer to see all the options available to style this layer. To customize the country labels based on conditions and properties within the data, select Style with data conditions and choose
name_en to style the label based on the English name for the country.
In the new panel, you are prompted to fill in the details of your data condition. In the first text field, enter
France since this is the label you will be customizing. In the
Text field, add
"Land in: " and click on & to combine your two strings. As you do this, you will see the
France label change to
Land in: France on your map.
To edit another data condition, click Done in the bottom right hand corner and then Add another condition. This time, continue the travel journey by choosing the first stop on the trip. In the first text field, enter
Spain and then
"First stop: " in the
Text field box.
Repeat the previous step to continue to add more data conditions and stops on the trip. Once you are finished your map will look something like the one below.