Hi Gianluca,
still need an answer?
You just have to add the title to div.innerHTML in the legend.onAdd function:
legend.onAdd = function (map) {
var div = L.DomUtil.create('div', 'info legend'),
grades = [0, 10, 20, 50, 100, 200, 500, 1000],
labels = [];
div.innerHTML += '<b>Legend Title</b><br>' // don't forget the break tag
// 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 +=
'<i style="background:' + getColor(grades[i] + 1) + '"></i> ' +
grades[i] + (grades[i + 1] ? '–' + grades[i + 1] + '<br>' : '+');
}
return div;
};
Cheers
Stefan
Am Donnerstag, 23. Januar 2014 11:35:46 UTC+1 schrieb
gianlu...@gmail.com:
Hello All,
I am new to Leaflet and I am currently struggling with tutorials. So far I managed to create an
interactive clorophet map, like in the example.
I have a question: is it possible to add a title (simple text, not dynamic) to the legged located on the bottomright of the page? Could anyone tell me how, by just referring to the linked example?
Many thanks,
Gianluca