wegue-oss / wegue

Template and components for webmapping applications with OpenLayers and Vue.js
BSD 2-Clause "Simplified" License
97 stars 42 forks source link

Labeling of text-based icons not possible #228

Open JakobMiksch opened 3 years ago

JakobMiksch commented 3 years ago

There is already the possibility to add a text based label to an existing style.

This does not work when the layer style is text-based itself. See this example:

    {
      "type": "WFS",
      "lid": "gas-wfs",
      "name": "Gas Stations WFS",
      "url": "https://ows-demo.terrestris.de/geoserver/osm/wfs",
      "typeName": "osm:osm-fuel",
      "version": "2.0.0",
      "maxFeatures": 50,
      "formatConfig": {},
      "format": "GML3",
      "loadOnlyVisible": true,
      "visible": true,
      "selectable": true,
      "style": {
        "textIcon": "local_gas_station",
        "font": "normal 30px Material Icons",
        "fillColor": "blue",
        "label": {
          "attribute": "name",
          "outlineColor": "white",
          "outlineWidth": 2,
          "fillColor": "black",
          "offsetX": 0,
          "offsetY": 15,
          "align": "center"
        }
      },
      "attributions": "© <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors.",
      "columnMapping": {
        "name": "Name"
      },
      "doAppendSelectStyle": true
    },

The label style replaces the icon which causes the layer to look like this:

(The points are the labels "Aral", "Mr Wash", "Shell", "Agip")

image

fschmenger commented 2 years ago

I'm recently running into some limitations with the StyleFactory, which has also confirmed by my dear colleague J.Kaeflein. I was searching, how we could make the app-conf layer style declarations a little more generic. Writing your own customized style language and then translating it to OpenLayers is apparently a long and stony process, so we should look for something existing / simplistic. The obvious choice would be to pick a kind of JSON serialization format of ol/style/Style. I found this little github project. From looking at the code its fairly similar to what we're doing but allows some more nested constructs (Disclaimer: I had not time to test it yet). Maybe there are some other project as well that follow a similiar pattern.

chrismayer commented 2 years ago

Some general words up in front: First of all the limitations of the StyleFactory rely on the fact the Wegue was initially designed as little shiny app template and not an all-signing-all-dancing :notes: :dancers: configurable webmapping application framework (I'll give a more detailed public statement on that within the next time). Therefore it was merely thought to implement project specific things - also styles - on your own. The StyleFactory was a little convenience layer to have simple styles out of the box. It was never intended to be a fully fledged OL Style libs.

Writing your own customized style language and then translating it to OpenLayers is apparently a long and stony process, so we should look for something existing / simplistic.

True, if we want to support generic style configs.

The obvious choice would be to pick a kind of JSON serialization format of ol/style/Style.

That's what its all about

I found this little github project.

This seems very old and nor more maintained. Apart from that there are more sustainable approaches to solve the problem of having a serializable style format for OpenLayers layers: