Mapbox Tiling Service
Beta

Intricate road network

This lengthy example creates a road network tileset from a road's tileset source. It applies 4 filter criteria based on the zoom, highway, and place attributes of the source's features. It then creates new streetrank and labelrank attributes for each filter using the set operator and specifies that the priority attribute should be used to define the zoom_element of the features in the final tileset.

Finally, it limits the output tiles such that:

  • No tile will have more than 20 highway features and will determine which features to keep based on their streetrank (regardless of whether features overlap).
  • No tile will have more than 200 name features and will determine which features to keep based on their labelrank value (and will also drop features that overlap based on their lablerank).
{
"version": 1,
"layers": {
"road_network": {
"source": "mapbox://tileset-source/username/roads",
"minzoom": 0,
"maxzoom": 14,
"features": {
"filter": [
"any",
[
"all",
[ ">=", [ "zoom" ], 0 ],
[ "match", [ "get", "highway" ],
"motorway", true, "trunk", true, "primary", true, false ]
],
[
"all",
[ ">=", [ "zoom" ], 6 ],
[ "match", [ "get", "highway" ],
"secondary", true, "tertiary", true, false ]
],
[
"all",
[ ">=", [ "zoom" ], 11 ],
[ "match", [ "get", "highway" ],
"residential", true, "unclassified", true, false ]
],
[
"all",
[ ">=", [ "zoom" ], 13 ],
[ "match", [ "get", "highway" ], "service", true, false ]
],
[ "has", "place" ]
],
"attributes": {
"set": {
"streetrank": [ "match", [ "get", "highway" ],
"motorway", 0, "trunk", 0, "primary", 0,
"secondary", 1, "tertiary", 1,
"residential", 2, "unclassified", 2,
"service", 3,
4
],
"labelrank": [ "match", [ "get", "place" ],
"country", 0,
"state", 1,
"region", 2, "province", 2,
"district", 3, "county", 3,
"municipality", 4, "city", 4,
5
]
},
"zoom_element": [ "priority" ]
}
},
"tiles": {
"limit": [
[ "lowest_where", [ "has", "highway" ], 20, "streetrank" ],
[ "lowest_where_in_distance", [ "has", "name" ], 200, "labelrank" ]
]
}
}
}
}
Was this page helpful?