1.0.1 • Published 2 years ago

@gnatih/leaflet.legend v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Leaflet.Legend

Leaflet.Legend is a plugin for Leaflet that display legend symbols and toggle overlays.

Check out the demo.

Example

var map = L.map("map", {
        center: [29, 120],
    });
    
L.control.Legend({
    position: "bottomleft",
    legends: [{
        label: "Marker1",
        type: "image",
        url: "marker/marker-red.png",
    }]
}).addTo(map);

Options

OptionTypeDefaultDescription
positionString'topleft'The position of the control.
titleString'Legend'The title of the control.
opacityNumber1.0Opacity of the container.
legendsLegendSymbol[][]Array of legend symbols that will be added to the container.
symbolWidthNumber24Symbol width of the legend, in pixels.
symbolHeightNumber24Symbol width of the legend, in pixels.
columnNumber1The number of columns arranged in the legend.
collapsedBooleanfalseIf true, the control will be collapsed into an icon and expanded on mouse hover or touch.

LegendSymbol

OptionTypeDefaultDescription
labelStringundefinedThe label of the legend symbol.
typeStringundefinedThe type of the legend symbol. Possible values are 'image', 'circle', 'rectangle', 'polygon' or 'polyline'
urlStringundefinedThe url of the symbol image, only used when type is 'image'
radiusNumberundefinedThe radius of the circle, in pixels, only used when type is 'circle'
sidesNumberundefinedThe number of sides of a regular polygon, only used when type is 'polygon'
layersLayer|Layer[]undefinedLegend symbol associated layers. While associating the layers, the display state of the layers can be toggled.
inactiveBooleanundefinedIs the legend symbol inactive
strokeBooleantrueWhether to draw stroke along the path. Set it to false to disable borders on polygons or circles.
colorString'#3388ff'Stroke color
weightNumber3Stroke width in pixels
opacityNumber1.0Stroke opacity
lineCapString'round'A string that defines shape to be used at the end of the stroke.
lineJoinString'round'A string that defines shape to be used at the corners of the stroke.
dashArrayStringnullA string that defines the stroke dash pattern. Doesn't work on Canvas-powered layers in some old browsers.
dashOffsetStringnullA string that defines the distance into the dash pattern to start the dash. Doesn't work on Canvas-powered layers in some old browsers.
fillBooleandependsWhether to fill the path with color. Set it to false to disable filling on polygons or circles.
fillColorString*Fill color. Defaults to the value of the color option
fillOpacityNumber0.2Fill opacity.
fillRuleString'evenodd'A string that defines how the inside of a shape is determined.