openmaptiles
openmaptiles copied to clipboard
Display name of city_blocks
Hello,
I'm looking for a way to display the names of the element city_block. See this example here: https://overpass-turbo.eu/s/12Od Each city_block has a name, which I want to display on the map.
So far I've tried to include it in the schema and basically copied this commit.
After that I was able to color the areas of the city_block elements via this additional style layer (using "OSM Bright" btw):
{
"id": "place-city-block-fill",
"type": "fill",
"source": "openmaptiles",
"source-layer": "landuse",
"filter": [
"all",
["==", "class", "city_block"]
],
"paint": {
"fill-color": "rgba(255, 0, 0, 1)",
"fill-opacity": 0.5
}
}
But I still couldn't get it to display the city_block name if I added ist to the filter of the "place-other"-Layer.
Any ideas or hints on how I could achieve that?
Thank you!
Hi @fzuerker, did you try to add layout as in e.g. in water-name-ocean with "text-field"?
"layout": {
"text-font": ["Noto Sans Italic"],
"text-size": 14,
"text-field": "{name:latin}",
"symbol-spacing": 350,
"text-max-width": 5,
"symbol-placement": "point",
"text-letter-spacing": 0.2,
"text-rotation-alignment": "map"
},
I can't add the layout to my fill layer, because it doesn't have the text properties:
Layer 'place-city-block-fill': unknown property "text-size"
Layer 'place-city-block-fill': unknown property "text-field"
Layer 'place-city-block-fill': unknown property "symbol-spacing"
Layer 'place-city-block-fill': unknown property "text-max-width"
Layer 'place-city-block-fill': unknown property "symbol-placement"
Layer 'place-city-block-fill': unknown property "text-letter-spacing"
Layer 'place-city-block-fill': unknown property "text-rotation-alignment"
Or did you mean to add it somewhere else?
Anyway I think I am missing something crucial with how I added city_block to the layer definitions. When I inspect my map/style with maputnik I can see that there is a polygon available for the city_blocks, but it doesn't have a name property like a street for example

Ohh, I see. landuse function do not return any name. For display name you need a point with the name. So you should create e.g. a centroid from city_block polygon with the name and add it to the place layer.
Hi @fzuerker, did you successfully managed this? It is a similar situation as for water layer, where water polygon has just geometry and point carry the information about the name.