Skip to content

Instantly share code, notes, and snippets.

@chrislkeller
Created April 9, 2015 00:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrislkeller/7cbcbcdfd4812fc2cfa0 to your computer and use it in GitHub Desktop.
Save chrislkeller/7cbcbcdfd4812fc2cfa0 to your computer and use it in GitHub Desktop.
L.geoJson(hydrologic_regions, {
style: function(feature){
//console.log(layerData[i].hydrologic_region);
//var thisFeature = _.where(layerData, {hydrologic_region: feature.properties.FIRST_HRNA});
/*
var fillIndex = parseInt(feature.properties.HR - 1);
var thisColor = layerColors[fillIndex];
var calculatedPctChange = window.percentChange(thisFeature[0].region_average_2013, thisFeature[0].region_average_2014);
feature.properties.calculatedPctChange = calculatedPctChange;
if (feature.properties.calculatedPctChange > 0){
feature.properties.comparison = "Increase";
} else {
feature.properties.comparison = "Decrease";
};
console.log(feature.properties);
var thisColor;
if (feature.properties.comparison === "Increase"){
thisColor = "rgba(227, 26, 28, 1.0)";
} else {
thisColor = "rgba(51, 160, 44, 1.0)";
};
*/
return {
color: "#000000",
weight: 2,
fillColor: null,
opacity: 1,
fillOpacity: 1
}
},
/*
onEachFeature: function(feature, layer){
var thisFeature = _.where(layerData, {hydrologic_region: feature.properties.FIRST_HRNA});
var polygonCenter;
if (feature.properties.FIRST_HRNA === "North Coast"){
polygonCenter = layer.getBounds().getCenter();
polygonCenter.lat = 40.9052096972736;
polygonCenter.lng = -123.51379394531249;
} else {
polygonCenter = layer.getBounds().getCenter();
}
var calculatedPctChange = window.percentChange(thisFeature[0].region_average_2013, thisFeature[0].region_average_2014);
var polyLabel =
feature.properties.FIRST_HRNA + "<br />" +
"Feb. 2015: " + thisFeature[0].region_average_2014.toFixed(2) + "<br />" +
"Feb. 2013: " + thisFeature[0].region_average_2013.toFixed(2) + "<br />" +
"Pct Chg.: " + calculatedPctChange;
label = new L.Label();
label.setContent(polyLabel);
label.setLatLng(polygonCenter);
map.showLabel(label);
layer.on('click', function (e) {
alert("Lat, Lon : " + e.latlng.lat + ", " + e.latlng.lng)
console.log("clicked");
});
}
*/
}).addTo(map);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment