1.0.0 • Published 4 years ago

leaflet-feature-legend v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

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);

1.0.0

4 years ago