https://github.com/perliedman/leaflet-multi-style
Quickly add multiple styles to GeoJSON data
https://github.com/perliedman/leaflet-multi-style
Last synced: over 1 year ago
JSON representation
Quickly add multiple styles to GeoJSON data
- Host: GitHub
- URL: https://github.com/perliedman/leaflet-multi-style
- Owner: perliedman
- License: isc
- Created: 2017-05-15T07:29:35.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-14T23:15:31.000Z (about 9 years ago)
- Last Synced: 2025-03-27T13:46:14.784Z (over 1 year ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 8
- Watchers: 4
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
Leaflet Multi Style
===================
A plugin to quickly add multiple styles to the same GeoJSON data. [Demo](http://www.liedman.net/leaflet-multi-style).
## Using
As an extra option, you can add an array of `styles` instead of just a single `style`.
```js
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`:
```js
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`.