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
338 stars 119 forks source link

text-variable-anchor not support #220

Open ZachTRice opened 5 years ago

ZachTRice commented 5 years ago

It appears that there is no support for an array of text-anchor via the text-variable-anchor mapbox style property. i.e.:

 {
      "id": "default_style",
      "source": "OrbitTracks_CloudSat_Ascending",
      "source-layer": "OrbitTracks_CloudSat_Ascending",
      "type": "symbol",
      "layout": {
        "symbol-placement": "point",
        "symbol-avoid-edges": true,
        "text-field": ["get", "label"],
        "text-font": ["Open Sans Bold", "Arial Unicode MS Bold"],
        "text-size": 10,
        "text-letter-spacing": 0.05,
        "text-variable-anchor": ["left", "right", "top", "bottom"],
        "text-radial-offset": 0.5,
        "text-justify": "auto"
      },
      "paint": {
        "text-color": "#fff",
        "text-halo-color": "#999",
        "text-halo-width": 1
      }
    },

Current behavior: Screenshot_66

Expected behavior (shown using text-anchor: "left"): Screenshot_67

text-anchor is currently supported but it will only always offset in 1 direction whereas text-variable-anchor, will try the first anchor direction in an array, then, if there is a collision, it will try the next anchor direction, and so on.

xycarto commented 3 months ago

I wanted to check in and see if there was any chance the text-varible-anchor would be supported i the future. I suspect this is a tricky issue due to it's relationship with declutter. It's be a pretty awesome feature if it were added.