leaflet legend

Solutions on MaxInterview for leaflet legend by the best coders in the world

showing results for - "leaflet legend"
Leana
11 Apr 2016
1var legend = L.control({position: 'bottomright'});
2
3legend.onAdd = function (map) {
4
5    var div = L.DomUtil.create('div', 'info legend'),
6        grades = [0, 10, 20, 50, 100, 200, 500, 1000],
7        labels = [];
8
9    // loop through our density intervals and generate a label with a colored square for each interval
10    for (var i = 0; i < grades.length; i++) {
11        div.innerHTML +=
12            '<i style="background:' + getColor(grades[i] + 1) + '"></i> ' +
13            grades[i] + (grades[i + 1] ? '–' + grades[i + 1] + '<br>' : '+');
14    }
15
16    return div;
17};
18
19legend.addTo(map);
20