-
Notifications
You must be signed in to change notification settings - Fork 0
/
us-renewable.js
103 lines (83 loc) · 2.52 KB
/
us-renewable.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// ----------------------- State Renewable ------------------------------
var geojsonRnwEng;
var infoRnwEng = L.control({position: 'bottomleft'});
var legendRnwEng = L.control({position: 'bottomright'});
var rnwengAttrib = 'Energy Policy Data © <a href="http://www.ncsl.org/research/energy/renewable-portfolio-standards.aspx">State Renewable Standards & Goals</a>';
function resetHighlightRnwEng(e) {
geojsonRnwEng.resetStyle(e.target);
infoRnwEng.update();
}
function zoomToFeature(e) {
map.fitBounds(e.target.getBounds());
}
function onEachFeatureRnwEng(feature, layer) {
layer.on({
mouseover: highlightFeatureRnwEng,
mouseout: resetHighlightRnwEng,
click: zoomToFeature
});
}
geojsonRnwEng = L.geoJson(statesData, {
style: styleRnwEng,
onEachFeature: onEachFeatureRnwEng
});
//}).addTo(popdns);
//}).addTo(map);
infoRnwEng.onAdd = function () {
this._div = L.DomUtil.create('div', 'info');
this.update();
return this._div;
};
infoRnwEng.update = function (props) {
this._div.innerHTML = '<h4>Renewable Energy Goals</h4>' + (props ?
'<b>' + props.name + '</b><br />' + props.policy + '</b><br />' + props.goals
: 'Hover over a state');
};
// function getColorRnwEng(d) {
// return d == 3 ? '#FFFFFF' :
// d == 2 ? '#bdbdbd' :
// d == 1 ? '#636363' :
// '#FFEDA0';
// }
function getColorRnwEng(d) {
return d == 3 ? '#FED976' :
d == 2 ? '#FC4E2A' :
d == 1 ? '#800026' :
'#FFEDA0';
}
function styleRnwEng(feature) {
return {
weight: 2,
opacity: 1,
color: 'white',
dashArray: '3',
fillOpacity: 0.7,
fillColor: getColorRnwEng(feature.properties.category)
};
}
function highlightFeatureRnwEng(e) {
var layer = e.target;
layer.setStyle({
weight: 5,
color: '#666',
dashArray: '',
fillOpacity: 0.7
});
if (!L.Browser.ie && !L.Browser.opera && !L.Browser.edge) {
layer.bringToFront();
}
infoRnwEng.update(layer.feature.properties);
}
legendRnwEng.onAdd = function (map) {
var div = L.DomUtil.create('div', 'info legend'),
grades = [1, 2, 3],
labels = [],
lbls = ['Requirement', 'Optional', 'None'];
for (var i = 0; i < grades.length; i++) {
labels.push(
'<i style="background:' + getColorRnwEng(i+1) + '"></i> ' +
lbls[i]);
}
div.innerHTML = labels.join('<br>');
return div;
};