npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

openlayers-style-editor

v1.1.1

Published

A style editor extension for OpenLayers currently working with WebGL Vector Layers

Readme

Demo

[!NOTE] This package is compatible with SSR.

Contents

Background

This package was created in the context of the LAND IT project, a decision support system to help stakeholders planning a new landscape for the most affected areas by wildfires in Portugal. LAND IT uses OpenLayers as its main GIS dependency, and throughout the project the need to edit layers styles increased.

Presentation

This Style Editor for OpenLayers allows the user to change the style of layers. This editor was inspired in both QGIS and ArcMap editors.

There are three edition modes:

  • Unique Symbol: Allows the user to change the layer's color, opacity, and stroke.
  • Categorized: Allows the user to change the layer's color, opacity, and stroke based on the values of an attribute.
  • Quantitative: Allows the user to change the layer's color, opacity, and stroke based on a numeric attribute and the mode used to group its values. This package has six modes implemented, some of them are implemented using the GeoBuckets package. The implemented modes are:
    • Manual
    • Equal Intervals
    • Defined Intervals
    • Quantile
    • Natural Breaks (Jenks)
    • Standard Deviation

A detailed explanation of each mode can be found here.

  • Based on Rules: Allows the user to change the layer's color, opacity, and stroke based on rules defined by the user. Each rule is composed by a name, a filter, and a renderer. The filter is a logical expression that defines which features will be styled with the renderer of the rule.

License

This project is licensed under the MIT License.

Installation

Depending on the installed package provider, this package can be installed with one of the following commands.

npm install openlayers-style-editor
yarn add openlayers-style-editor

Usage

Firstly it is necessary to import the styles of the package. This can be done by adding the following code snippet to your index/main file.

import 'openlayers-style-editor/dist/openlayers-style-editor.css';

It is possible to enjoy this package by adding the following code snippets to your code.

import { Render, RenderType, StyleEditor } from "openlayers-style-editor";
const [visible, setVisible] = useState<boolean>(false);

const defaultRender: Render = {
    type: RenderType.Unique,
    rendererOL: {
        'fill-color': [255, 255, 50, 1],
        'stroke-color': [0, 0, 0, 1],
        'stroke-width': 1,
    }
}

const [renderer, setRenderer] = useState<Render>(defaultRender);
<StyleEditor visible={visible}
               setVisible={setVisible}
               layerDefaultRenderer={defaultRender}
               layerCurrentRenderer={renderer}
               applyRenderer={(renderer) => setRenderer(renderer)}
               features={features}
               primeReactTheme={"bootstrap4-light-blue"}
               showPreDefinedRamps={true} />

To see a full example click here.

Props Details

| Name | Type | Requirement | Description | Example | |-------------------------|------------------------|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | visible | boolean | mandatory | Defines if the component is visible or not | true | | setVisible | function | mandatory | Function to set the visibility of the component | () => setVisible(!visible) | | layerDefaultRenderer | Render | mandatory | Default renderer of the layer to be edited | { type: RenderType.Unique,  rendererOL: {   'fill-color': [255, 255, 50, 1],   'stroke-color': [0, 0, 0, 1],   'stroke-width': 1 }} | | layerCurrentRenderer | Render | mandatory | Current renderer of the layer | { type: RenderType.Unique,  rendererOL: {   'fill-color': [255, 255, 50, 1],   'stroke-color': [0, 0, 0, 1],   'stroke-width': 1 }} | | applyRenderer | function | mandatory | Function to apply the renderer to the layer, it has as parameter the renderer to be applied | (renderer: Render) => setRenderer(renderer) | | features | Feature[] | mandatory | Features to be rendered on the map | | | showPreDefinedRamps | boolean | mandatory | Show the predefined ramps of the package | true | | moreRamps | ColorRamp[] | optional | An array of color ramps that can be added to the package | [{ id: 28, //id needs to be >=28  name: "GnBu",  palette:   [{   offset: 0.25,    color: fromString("rgb(186,228,188)")  },  {   offset: 0.5,   color: fromString("rgb(123,204,196)")  },   {   offset: 0.75,    color: fromString("rgb(67,162,202)")  }]}] | | predefinedStyles | PredefinedRenderer[] | optional | Predefined styles to be used on the categorized style type | [{ name: "Dangerousness", renderer:   [{   value: "Very High",    color: [255, 0, 0]  },  {   value: "High",    color: [255, 128, 0]  },  {   value: "Medium",    color: [255, 255, 0]  },  {   value: "Low",    color: [139, 209, 0]  },  {   value: "Very Low",    color: [56, 168, 0]  }]}] | | addingToHeader | string | optional | Text to be added to the header | - Dangerousness Layer | | primeReactTheme | string | optional | PrimeReact theme to be used, all option can be found here | bootstrap4-light-blue | | numbersLocale | string | optional | Locale to be used on numbers, represented using BCP 47 language tag. Default is 'en-US' | en-US | | textLocale | string | optional | Locale to be used for text. This package has two options available: 'en' and 'pt'. Default is 'en'. To add a custom locale, use the customLocale prop and in the textLocale prop use 'custom'. | pt | | customLocale | Record<string, any> | optional | Custom locale to be used in case the textLocale is set to 'custom'. This prop must have the same structure as the default locale, that can be found here | {"common": { "style_editor": "Editor de Estilos", "reset_style": "Repor Estilo", ...}} |

TODOs

  • [ ] Add more types of renderers, such as heatmap and icon renderers.

Show your support

Give a ⭐️ if this project helped you!

Author & Maintainer

Márcia Matias