Mapbox Tiling Service
Beta

Populated places

This example uses a global point dataset of populated places from Natural Earth Data to build a label layer. POIs must be visible and not overcrowded to allow users to quickly distinguish each point. They are likely going to be labels on a map, or points or circles with labels. Here’s a recipe suitable for this dataset at low to medium zoom levels.

{
"version": 1,
"layers": {
"city_labels": {
"source": "mapbox://tileset-source/{username}/populated-places",
"minzoom" : 0,
"maxzoom" : 7,
"features" : {
"attributes" : {
"allowed_output" : [
"name_en", "SCALERANK"
]
}
},
"tiles" : {
"limit" : [
[
"lowest_where_in_distance",
true,
50,
"SCALERANK"
]
]
}
}
}
}
FieldDescriptionData type
sourceThe source data to use for this layer. Tileset sources are created with the Create a tileset source endpoint of Mapbox Tiling Service (MTS).String
minzoomSpecify the minimum zoom at which your tileset will be available. A value of 0 here ensures that cities will be visible at a global level.Integer
maxzoomSpecify the maximum zoom at which your tileset will be available. A value of 7 here allows users to zoom in and will show more cities, but we have no need for these labels at higher zoom levels in this particular case.Integer
features.attributes.allowed_outputSpecify which data attributes to carry through to the final tileset. Here we only keep the two attributes name_en and SCALERANK to keep tile sizes low (we don't need other fields for a label tileset). Note that the filter has to preserve SCALERANK as well as name_en, even though only name_en is needed for display. SCALERANK is necessary so that the limit filter can reference it.Array<String>
tiles.limitUse the limit filter to keep the number of cities per tile low. It will only keep points if another point is not already in its place with a higher SCALERANK value.Array<Expression>

Example data

Download the city data used in this recipe from Natural Earth Data.

To transform the data from Natural Earth into a format that is compatible with a Mapbox Tiling Service recipe, use the following Tippecanoe command:

$ tippecanoe-json-tool ../tippecanoe/ne_10m_populated_places.json > cities.json
Was this page helpful?