包详细信息

geostyler-openlayers-parser

geostyler49.4kBSD-2-Clause5.1.2

GeoStyler Style Parser implementation for OpenLayers styles

geostyler, parser, style, openlayers

自述文件

geostyler-openlayers-parser

Coverage Status License npm version

GeoStyler Style Parser implementation for OpenLayers styles

:rocket: GeoStyler Code Sprint 2025

We are happy to announce the next GeoStyler Code Sprint from 02.-06.06.2025 in Switzerland. Be part of it! More infos on https://geostyler.org/.

How to use

The example below shows how to take a raw GeoStyler style, use the OpenLayersParser to parse the style into an OpenLayers style, and then apply it to an OpenLayers vector layer.

ES6:

import OpenLayersParser from "geostyler-openlayers-parser";
import OlLayerVector from "ol/layer/Vector";

const pointSimplePoint = {
  name: "OL Style",
  rules: [
    {
      name: "OL Style Rule 0",
      symbolizers: [
        {
          kind: "Mark",
          wellKnownName: "circle",
          color: "#FF0000",
          radius: 6
        }
      ]
    }
  ]
};

const parser = new OpenLayersParser();
const layer = new OlLayerVector();

parser
  .writeStyle(pointSimplePoint)
  .then(({output: olStyle}) => layer.setStyle(olStyle))
  .catch(error => console.log(error));

Browser:

var pointSimplePoint = {
  name: "OL Style", rules: [{
    name: "OL Style Rule 0",
    symbolizers: [{
      kind: "Mark",
      wellKnownName: "circle",
      color: "#FF0000",
      radius: 6
    }]
  }]
};
var vectorLayer = new ol.layer.Vector();
var parser = new GeoStylerOpenlayersParser.OlStyleParser(ol);
parser.writeStyle(pointSimplePoint)
.then(function(style) {
    if (style.errors) {
      console.log(style.errors);
    } else {
      vectorLayer.setStyle(style.output);
    }
});

Funding & financial sponsorship

Maintenance and further development of this code can be funded through the GeoStyler Open Collective. All contributions and expenses can transparently be reviewed by anyone; you see what we use the donated money for. Thank you for any financial support you give the GeoStyler project 💞

更新日志

5.1.2 (2025-06-11)

Bug Fixes

  • deps: update dependency geostyler-style to v10.1.0 (a0f7517)
  • deps: update dependency geostyler-style to v10.3.0 (0811abc)
  • do not fetch all commits when running commit lint (9f2e98f)
  • update geostyler-style-imports (b4a2980)

5.1.1 (2025-05-16)

Bug Fixes

  • OlFlatStyleParser: properly parse expressions in FlatRule filters (c2399e5)

5.1.0 (2025-05-14)

Features

5.0.2 (2025-03-12)

Bug Fixes

  • deps: update dependency css-font-parser to v2.0.1 (4f0037d)

5.0.1 (2024-12-02)

Bug Fixes

  • add missing "anchor" to unsupportedProperties (d1d9bfe)
  • check if Array instead of number (dc0ebfa)

5.0.0 (2024-06-25)

⚠ BREAKING CHANGES

  • You may need to adapt your imports, your bundler config or other configs when using this module to make sure your tooling knows this is now an esm module.
  • you may need to adjust your imports as some of the paths have been changed

Features

  • switch to esm build (71502fb)
  • use esm build & update geostyler-style (4da7581)

Bug Fixes

  • add module, update node (299acb8)
  • cleanup imports (605ccc7)
  • fix imports & exports (f906dc1)
  • move variable declaration (6837cf8)
  • parsing of property functions in filter args (484bb8c)
  • update geostyler-style & cleanup package.json (48b7386)
  • update node versions [skip ci] (32f4f84)
  • use preserve module strategy (cd83ecc)

5.0.0-next.6 (2024-06-20)

Bug Fixes

  • update geostyler-style & cleanup package.json (48b7386)
  • update node versions [skip ci] (32f4f84)

5.0.0-next.5 (2024-06-19)

Bug Fixes

  • add module, update node (299acb8)

5.0.0-next.4 (2024-06-19)

Bug Fixes

  • use preserve module strategy (cd83ecc)

5.0.0-next.3 (2024-06-19)

Bug Fixes

5.0.0-next.2 (2024-06-19)

Bug Fixes

5.0.0-next.1 (2024-06-19)

⚠ BREAKING CHANGES

  • You may need to adapt your imports, your bundler config or other configs when using this module to make sure your tooling knows this is now an esm module.
  • you may need to adjust your imports as some of the paths have been changed

Features

  • switch to esm build (71502fb)
  • use esm build & update geostyler-style (4da7581)

Bug Fixes

  • move variable declaration (6837cf8)
  • parsing of property functions in filter args (484bb8c)

4.3.0 (2023-12-04)

Features

  • add support for Sprite (785aee9)
  • parse placement of TextSymbolizer (59944a7)

Bug Fixes