leaflet-feature-legend

1.0.0 • Public • Published

leaflet-feature-legend

A Leaflet plugin for creating legends of features.

Example

// Leaflet icons are used to create the legend
const blueIcon = L.icon({ iconUrl: 'icons/blue_circle.png', iconSize: [15, 15] });
const redIcon = L.icon({ iconUrl: 'icons/red_triangle.png', iconSize: [15, 15] });
const yellowIcon = L.icon({ iconUrl: 'icons/yellow_square.png', iconSize: [15, 15] });

L.marker([51.5, -0.09], { icon: blueIcon }).addTo(myMap);
L.marker([51.52, -0.091], { icon: redIcon }).addTo(myMap);
L.marker([51.505, -0.115], { icon: yellowIcon }).addTo(myMap);

// Create your custom legend here
const legend = L.control.featureLegend({
    position: "bottomleft",
    title: "Shapes",
    items: {
        "Blue circle": { icon: blueIcon, width: 18 },
        "Red triangle": { icon: redIcon },
        "Yellow square": { icon: yellowIcon, width: 18 },
    }
}).addTo(myMap);

Readme

Keywords

none

Package Sidebar

Install

npm i leaflet-feature-legend

Weekly Downloads

18

Version

1.0.0

License

MIT

Unpacked Size

5.15 kB

Total Files

5

Last publish

Collaborators

  • aazuspan