Socket
Socket
Sign inDemoInstall

leaflet-multi-style

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    leaflet-multi-style

quickly add multiple styles to GeoJSON data


Version published
Weekly downloads
1
Maintainers
1
Install size
4.87 kB
Created
Weekly downloads
 

Readme

Source

Leaflet Multi Style

A plugin to quickly add multiple styles to the same GeoJSON data. Demo.

Using

As an extra option, you can add an array of styles instead of just a single style.

var vectorLayer = L.geoJson.multiStyle(geojson, {
    styles: [
        {color: 'black', opacity: 0.15, weight: 10},
        {color: 'white', opacity: 0.8, weight: 8},
        {color: 'red', opacity: 1, weight: 4}
    ],
}).addTo(map);

For point features, the array pointToLayers replaces pointToLayer:

var vectorLayer = L.geoJson.multiStyle(geojson, {
    pointToLayers: [
        function (feature, latlng) {
            return L.circleMarker(latlng, {
                radius: 8.0,
                fillColor: 'yellow'
            })
        },
        function (feature, latlng) {
            return L.circleMarker(latlng, {
                radius: 4.0,
                fillColor: 'red'
            })
        }
    ]
}).addTo(map);

Similarily, there is also an option filters that works just like the original option filter, but is called for each style in styles.

Keywords

FAQs

Last updated on 14 Jun 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc