openmaptiles icon indicating copy to clipboard operation
openmaptiles copied to clipboard

Display name of city_blocks

Open fzuerker opened this issue 4 years ago • 4 comments
trafficstars

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!

fzuerker avatar Jan 26 '21 13:01 fzuerker

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"
  },

TomPohys avatar Mar 05 '21 09:03 TomPohys

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 maputnik city_block maputnik street

fzuerker avatar Mar 11 '21 13:03 fzuerker

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.

TomPohys avatar Mar 30 '21 16:03 TomPohys

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.

TomPohys avatar May 31 '21 08:05 TomPohys