0
有人可以告訴代碼有什麼問題嗎?這個傳說,應該是最容易出現的部分,我不知道爲什麼。也許隱藏在其他層?單張圖例不顯示
繼的getColor和傳說代碼
var legend = L.control({
position: 'bottomleft'
});
legend.onAdd = function(map) {
var div = L.DomUtil.create('div', 'info legend'),
grades = [0.2, 0.26, 0.32, 0.38, 0.44, 0.5, 0.56, 0.62, 0.68, 0.74, 0.8, 0.86, 0.92, 0.98, 1.04, 1.1],
labels = [],
from, to;
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;
};
對不起didnt貼吧。 legend.addTo(地圖);已經是getcolor的代碼的一部分。我複製並粘貼了你的代碼,而現在它不顯示任何東西。這是GeoJSON的所有部分我不知道這是否有區別 – Pre60
順便說一下,您是否使用一些背景顏色來設置您的'div.info.legend'圖例控件容器,以便在地圖上輕鬆查看它?注意我必須在上述演示中應用白色背景色。 – ghybs
https://github.com/Pre60/myTest/commit/f2a522622180c5907d2f2f04fd5dd889e3bc8933 – Pre60