https://github.com/geostyler/geostyler-openlayers-parser
GeoStyler Style Parser implementation for OpenLayers styles
https://github.com/geostyler/geostyler-openlayers-parser
geostyler openlayers parser style
Last synced: 2 months ago
JSON representation
GeoStyler Style Parser implementation for OpenLayers styles
- Host: GitHub
- URL: https://github.com/geostyler/geostyler-openlayers-parser
- Owner: geostyler
- License: bsd-2-clause
- Created: 2018-05-24T14:18:21.000Z (about 8 years ago)
- Default Branch: main
- Last Pushed: 2026-04-12T09:50:57.000Z (3 months ago)
- Last Synced: 2026-04-12T11:22:24.608Z (3 months ago)
- Topics: geostyler, openlayers, parser, style
- Language: TypeScript
- Size: 5.9 MB
- Stars: 42
- Watchers: 18
- Forks: 30
- Open Issues: 30
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# geostyler-openlayers-parser
[](https://coveralls.io/github/geostyler/geostyler-openlayers-parser?branch=main)
[](https://github.com/geostyler/geostyler-openlayers-parser/blob/main/LICENSE)
[](https://www.npmjs.com/package/geostyler-openlayers-parser)
[GeoStyler Style](https://github.com/geostyler/geostyler) Parser implementation for OpenLayers styles
### 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:
```js
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:
```js
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](https://opencollective.com/geostyler). 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 💞