maplibre / maplibre-style-spec

MapLibre Style Specification & Utilities
https://maplibre.org/maplibre-style-spec/
Other
93 stars 65 forks source link

Add `vertical-align` in format expression #900

Open stanislawpuda-tomtom opened 2 weeks ago

stanislawpuda-tomtom commented 2 weeks ago

Related issue #832.

This PR introduces vertical align property to format expression. It enables to specify how each section should be positioned in relation to biggest element in line. There are three possible options:

Launch Checklist

codecov-commenter commented 2 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 92.80%. Comparing base (f5afe41) to head (4460a7e). Report is 11 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #900 +/- ## ========================================== + Coverage 92.78% 92.80% +0.01% ========================================== Files 107 107 Lines 4739 4752 +13 Branches 1346 1352 +6 ========================================== + Hits 4397 4410 +13 Misses 342 342 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

stanislawpuda-tomtom commented 14 hours ago

I would like to cover questions from the meeting on Nov 13th:

Using HTML

I did check, and it is possible to use HTML to display vertically aligned labels. This approach works for MapLibre GL JS, however it does not cover multiple platforms. There are more advantages of using format expression over custom HTML layer:

Format expression already gives possibility to create rich labels on the map, easily, without having to implement own custom solution. Having the possibility to align elements vertically in my opinion is good supplement to format expression. In some cases necessary to make full benefit from it.

Sample use case

Our team created a sample mock how the labels look like with and without vertical alignment.

Before: before

After: after

lseelenbinder commented 12 hours ago

Thanks for taking the time to work through these pieces @stanislawpuda-tomtom!

In my opinion, those advantages are sufficient to merit including in the spec—especially for collision detection and performance reasons.