You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Labelling an area is a common task when designing maps. However, if you try and use a symbol style on a polygon layer, the results are suboptimal, with labels appearing in multiple random places on the polygon:
I understand this is because one symbol is placed on each tile the polygon appears in.
The usual solution to this problem is to calculate the label placement on the server and include it as a point layer in the tiles. This isn't ideal - it complicates map development, increases tile size and schema complexity, and it also breaks the vector tiles abstraction by having a rendering decision made on the server.
Dissolve all the constituent polygons into one polygon
Clip that polygon to the viewport
Place the symbol at the centroid of the clipped polygon, perhaps with an area cutoff to prevent labels being displayed on a polygon which is only just visible on the edge of the viewport
This is an old problem which is also present in Mapbox GL, so I assume there's a very good reason why it hasn't already been fixed, but it would be a substantial improvement if it could be done.
The text was updated successfully, but these errors were encountered:
Sure - here's the example map with the country labels rendered from the polygon layer rather than the centroid layer.
This does also result in islands being labelled separately, which is not relevant to this issue, but you can see multiple labels rendered on countries, and this worsens as you zoom in.
SomeoneElseOSM
pushed a commit
to SomeoneElseOSM/SomeoneElse-vector-extract
that referenced
this issue
Nov 15, 2024
Labelling an area is a common task when designing maps. However, if you try and use a
symbol
style on a polygon layer, the results are suboptimal, with labels appearing in multiple random places on the polygon:I understand this is because one symbol is placed on each tile the polygon appears in.
The usual solution to this problem is to calculate the label placement on the server and include it as a point layer in the tiles. This isn't ideal - it complicates map development, increases tile size and schema complexity, and it also breaks the vector tiles abstraction by having a rendering decision made on the server.
Someone has tried to fix this in Javascript but this is a fairly hacky solution.
Ideally, a symbol placement algorithm would:
This is an old problem which is also present in Mapbox GL, so I assume there's a very good reason why it hasn't already been fixed, but it would be a substantial improvement if it could be done.
The text was updated successfully, but these errors were encountered: