【发布时间】:2019-12-19 16:50:24
【问题描述】:
我一直在尝试在我的传单地图中添加一个图例。我正在使用本教程https://leafletjs.com/examples/choropleth/ 但是图例没有显示 getColor() 的正确值 这是我项目中显示的图例 this is my project screenshot
已经包含了 css 和 getColor 值。 这是图例代码
var legend = L.control({
position: 'bottomright'
});
legend.onAdd = function(map) {
var div = L.DomUtil.create('div', 'info legend'),
grades = [0, 2.3, 2.4, 2.8],
labels = [];
for (var i = 0; i < grades.length; i++) {
from = grades[i];
to = grades[i + 1];
labels.push(
'<i style="background:' + getColor(from + 1) + '"></i> ' +
from + (to ? '–' + to : '+'));
}
div.innerHTML = labels.join('<br>');
return div;
};
legend.addTo(map);
如何解决这个问题?
【问题讨论】:
标签: javascript leaflet choropleth