openlayers / ol-mapbox-style

Use Mapbox Style objects with OpenLayers
https://unpkg.com/ol-mapbox-style/dist/examples/index.html
BSD 2-Clause "Simplified" License
350 stars 121 forks source link

missing icon-text-fit property #1175

Open joostschouppe opened 4 months ago

joostschouppe commented 4 months ago

I used Maputnik to make labels where a white block is stretched to fit the label of some objects

"icon-image": "a_white_block",
"icon-text-fit": "both",
"icon-text-fit-padding"

If I understand https://github.com/openlayers/ol-mapbox-style/issues/10#issuecomment-1856124293 correctly, it's normal that this does not render properly in our OpenLayers project, since those two last properties are not supported. Is there a workaround for this? Is there a plan to implement more properties? Would you welcome pull requests to fix this (and if so, can you point us in the right direction as to where to start with a fix)?

And the same questions for symbol-placement, which we use to put labels along a line

ahocevar commented 4 months ago

First of all for the easy part of the answer: symbol-placement has been implemented in the meantime.

icon-text-fit and icon-text-fit-padding are still not implemented, but pull requests are welcome! A good approach would be to measure the text with the wrapText function provided in src/text.js (by adding an optional last argument and returning text and box measurements, if provided), and use that measurement to scale the icon.

joostschouppe commented 4 months ago

Thanks for the info! This is few skyscrapers above my own level, but I'll try to push for some time in our team, though it's likely it's not for this year