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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@polar/plugin-layer-chooser

v1.2.1

Published

LayerChooser plugin for POLAR that adds a layer selection and configuration UI element for both backgrounds and overlays.

Downloads

67

Readme

LayerChooser

The tool offers layer selection to the user.

Scope

The LayerChooser offers an additive (usually Overlays, technically named with type: 'mask') and an exclusive (usually background maps, type: 'background') selection of layers to the users.

Order of layers within a layer is currently always as initially configured.

Configuration

The tool does not require any configuration for itself, but is based on the mapConfiguration.layers. It will infer id and name from that configuration.

This plugin requires the configuration of mapConfiguration.layer.type. Also, this plugin also supports the optional configuration parameters mapConfiguration.layer.hideInMenu, mapConfiguration.layer.minZoom, mapConfiguration.layer.maxZoom, mapConfiguration.layer.options and mapConfiguration.layer.visibility which are described in more depth in the following table.

| fieldName | type | description | | - | - | - | | type | enum["background", "mask"] | Layer handling. Backgrounds are mutually exclusive, masks ("overlays") can be stacked. | | hideInMenu | boolean? | Can be set for layers of type 'mask' to hide them in the selection menu. | | maxZoom | number? | If set, layer only available (and selectable) up to this zoom level. | | minZoom | number? | If set, layer only available (and selectable) from this zoom level on. | | options | options? | Shows a layer-specific sub-menu; its contents are configurable. | | visibility | boolean? | Initial visibility. Defaults to false. |

For details on the displayComponent attribute, refer to the Global Plugin Parameters section of @polar/core.

Example configuration:

layers: [
  {
    id: backgroundmap,
    visibility: true,
    type: 'background',
    name: 'Basemap Grayscale',
  },
  {
    id: memorialsWFS,
    visibility: false,
    hideInMenu: true,
    type: 'mask',
    name: 'Memorial (WFS)',
    minZoom: 7,
  },
]

layer.options

An option wheel will appear in the layer chooser that allows opening a sub-menu with configured configuration options for the end user.

| fieldName | type | description | | - | - | - | | layers | layer.options.layers | If configured, all configured layers of the layer can be turned off and on by the user. ⚠️ Only implemented for WMS. Only implemented for top layers; that is, only first level of nesting is considered. |

Example configuration:

options: {
  layers: {
    order: '6,24,25,4,3,2,1,0',
    title: {
      '6': 'Monument area',
      '24': 'Majority of structures',
      '25': 'Material group',
      '4': 'Architectural monument',
      '3': 'Natural monument',
      '2': 'Water bodies',
      '1': 'Architectural monument (area)',
      '0': 'Natural monument (area)',
    },
    legend: true,
  },
},

layer.options.layers

This field is named like this to match the OGC specification for their name; that is, layers have layers that may have layers that may have layers, and so on. However, only the first level (a layer's layers) is currently implemented.

| fieldName | type | description | | - | - | - | | legend | boolean | Record<name, legendUrl>? | Legend image to be used for sub-layer. If false, no image is displayed. If true, it is assumed an image exists in the layer's GetCapabilities, and that will be used. If Record, it maps the layer name to a linked image. The legendUrl can be any valid reachable image URL. | | order | string? | Optional. If not given, field layers from service description will be used, and defines order of options. If layer defined in service description's layers and order, it's initially on. If only in order, it's initially off. If only in layers, it's always-on. If in neither, it's always-off. | | title | boolean | Record<name, layerName>? | Title to be displayed for sub-layer. If false, layer name itself will be used as given in service description 'layers' field. If true, it is assumed a name exists in the layer's GetCapabilities, and that will be used. If Record, it maps the layer name to an arbitrary display name given by the configuration. The layerName can be any string. |

Example configuration:

layers: {
  order: '6,24,25,4,3,2,1,0',
  title: {
    '6': 'Monument area',
    '24': 'Majority of structures',
    '25': 'Material group',
    '4': 'Architectural monument',
    '3': 'Natural monument',
    '2': 'Water bodies',
    '1': 'Architectural monument (area)',
    '0': 'Natural monument (area)',
  },
  legend: true,
},