leaflet legend code example
Example: leaflet legend
var legend = L.control({position: 'bottomright'});
legend.onAdd = function (map) {
var div = L.DomUtil.create('div', 'info legend'),
grades = [0, 10, 20, 50, 100, 200, 500, 1000],
labels = [];
// loop through our density intervals and generate a label with a colored square for each interval
for (var i = 0; i < grades.length; i++) {
div.innerHTML +=
' ' +
grades[i] + (grades[i + 1] ? '–' + grades[i + 1] + '
' : '+');
}
return div;
};
legend.addTo(map);