我正在使用以下代码构建地图
var overlays = {
'Rain': L.tileLayer.provider('OpenWeatherMap.PrecipitationClassic'),
'Wind': L.tileLayer.provider('OpenWeatherMap.Wind')
};
L.control.layers(baseLayers,overlays).addTo(map);
它完美无缺,但现在我需要做同样的事情,但却是恐怖的。我这样做,但只显示最后一个值:
var key1= "Rain";
var value1= "L.tileLayer.provider('OpenWeatherMap.PrecipitationClassic')";
var key2= "Wind";
var value2= "L.tileLayer.provider('OpenWeatherMap.Temperature')";
overlays[key1] = value1;
overlays[key2] = value2;
L.control.layers(baseLayers,overlays).addTo(map);
提前致谢!