Note: The default ITS GitLab runner is a shared resource and is subject to slowdowns during heavy usage.
You can run your own GitLab runner that is dedicated just to your group if you need to avoid processing delays.

Commit f03660fc authored by Abbey Joy Roelofs's avatar Abbey Joy Roelofs
Browse files

Merge branch 'ajr-checkbox'

parents c187b07a 4c80ad78
......@@ -24,11 +24,14 @@
<span id="sign-out" class="action">Sign Out</span>
</div>
<div id="parameter-picker" class="esri-widget">
<label for="parameter-1">NWS Parameter:</label>
<label for="parameter-1-select">NWS Parameter:</label>
<select id="parameter-1-select"></select>
<br>
<label for="parameter-2-">Yale Parameter:</label>
<label for="parameter-2-select">Yale Parameter:</label>
<select id="parameter-2-select"></select>
<br>
<label for="normalize-check">Normalize occurrences by area?</label>
<input type="checkbox" id="normalize-check" />
</div>
<div id="akViewDiv" class="esri-widget"></div>
<div id="hiViewDiv" class="esri-widget"></div>
......
......@@ -108,6 +108,12 @@ require([
// Add username and sign out link.
mainView.ui.add('title-view', 'top-right');
const outlineLayer = new FeatureLayer({
url: 'https://services1.arcgis.com/4ezfu5dIwH83BUNL/arcgis/rest/services/USA_States_Generalized_share_air/FeatureServer/0',
legendEnabled: false,
popupEnabled: false
});
// Create a layer from Perry's alert and Yale's opinion data at the level of Congressional Districts (115th).
const layer = new FeatureLayer({
//url: 'https://services1.arcgis.com/4ezfu5dIwH83BUNL/arcgis/rest/services/Yale_Congressional_District_115_Level/FeatureServer/0',
......@@ -115,12 +121,41 @@ require([
//popupTemplate: popupTemplate,
//outFields: ['NAME', 'TotalPop', 'happening', 'happeningOppose'],
outFields: ['*'],
title: 'U.S. 115th Congressional Districts'
title: 'U.S. 115th Congressional Districts',
renderer: {
type: "simple",
symbol: {
type: "simple-fill",
color: [200, 200, 200, 0], // Draw everything transparent first (or change the 0 to .5 to draw it all grey first)
// Note that in spite of this, the opacity of the relationship renderer seems to default to what's set in the layer's default visualization
outline: {
width: 0
}
}
}
});
// Define initial set of parameters to display.
var parameter1 = 'FL';
var parameter2 = 'happening';
var chkNormalize = false;
var normFieldName = 'SQMI'; // TODO: Check to see if this is the correct field to use.
const parameter2options = {
'happening' : 'Estimated percentage who think that global warming is happening',
'happeningOppose' : 'Estimated percentage who do not think that global warming is happening',
'congress' : 'Estimated percentage who think Congress should be doing more/much more to address global warming',
'congressOppose' : 'Estimated percentage who think Congress should be doing less/much less to address global warming',
'worried' : 'Estimated percentage who are somewhat/very worried about global warming',
'worriedOppose' : 'Estimated percentage who are not very/not at all worried about global warming'
};
const parameter1options = {
// 'HT' : 'Heat Advisory', // Not enough data...
'FL' : 'Flood Advisory',
//'HU' : 'Hurricane Warning', // Not enough data...
//'RP' : 'Rip Current', // Not enough data...
'SV' : 'Severe Thunderstorm'
//'WS' : 'Winter Storm' // Not enough data...
};
// Populate selection lists for parameters.
setParameterSelectionLists();
......@@ -135,7 +170,7 @@ require([
layer.popupTemplate = popupTemplate;
const map = new Map({
layers: [layer]
layers: [outlineLayer, layer]
});
// Add map to mainView.
......@@ -213,15 +248,18 @@ require([
.then(disablePopupOnClick)
.then(enableHighlightOnPointerMove)
.then(enableParameter1Selection)
.then(enableParameter2Selection);
.then(enableParameter2Selection)
.then(enableNormalization);
akView
.when(disableNavigation)
.then(disablePopupOnClick)
.then(enableHighlightOnPointerMove);
.then(enableHighlightOnPointerMove)
.then(enableNormalization);
hiView
.when(disableNavigation)
.then(disablePopupOnClick)
.then(enableHighlightOnPointerMove);
.then(enableHighlightOnPointerMove)
.then(enableNormalization);
function maintainFixedExtent(view) {
......@@ -343,7 +381,6 @@ require([
console.log('Parameter 1 new selection:', parameter1 );
setRelationshipRenderer();
setPopupTemplate();
layer.popupTemplate = popupTemplate;
});
}
......@@ -355,17 +392,28 @@ require([
console.log('Parameter 2 new selection:', parameter2 );
setRelationshipRenderer();
setPopupTemplate();
layer.popupTemplate = popupTemplate;
});
}
function enableNormalization(view) {
var checkBox = document.getElementById('normalize-check');
checkBox.addEventListener("change", function(event) {
console.log(event.target);
chkNormalize = event.target.checked;
setRelationshipRenderer();
setPopupTemplate();
});
}
// Create relationship (or bivariate) renderer.
//$feature.SV/$feature.SQMI
function setRelationshipRenderer() {
let normField = chkNormalize ? normFieldName : null;
const params = {
layer: layer,
view: mainView,
field1: {
field: parameter1
field: parameter1,
normalizationField: normField
},
field2: {
field: parameter2
......@@ -383,9 +431,12 @@ require([
// Set the popup template
function setPopupTemplate() {
// This part could possibly be done just by setting fieldname aliases, but I don't have access to that.
let eventLabel = parameter1options[parameter1];
let pctLabel = parameter2options[parameter2];
popupTemplate = {
title:'{CD_Code}',
content: [
/*content: [
{
type:'fields',
fieldInfos: [
......@@ -403,12 +454,36 @@ require([
}
]
}
]
}
};
] */
fieldInfos: [
{
fieldName: "expression/expr0",
format: {
places: 4,
digitSeparator: true
}
}
],
expressionInfos: [
{
name: "expr0",
title: "normalizedSV",
expression: "$feature." + parameter1 + "/$feature.SQMI",
returnType: "number"
}
],
content: "Total Population: {TotalPop}<br /> <br />" +
eventLabel + ": {" + parameter1 + "} <br /> " +
" Per Square Mile: {expression/expr0} <br /> <br />" +
pctLabel + ": {" + parameter2 + "}%",
};
layer.popupTemplate = popupTemplate;
}
// Set the options for the parameter select lists.
function setParameterSelectionLists() {
/* Moving this out of the function to make it accessible to other functions as well
var parameter1options = {
// 'HT' : 'Heat Advisory', // Not enough data...
'FL' : 'Flood Advisory',
......@@ -416,13 +491,14 @@ require([
//'RP' : 'Rip Current', // Not enough data...
'SV' : 'Severe Thunderstorm'
//'WS' : 'Winter Storm' // Not enough data...
};
};*/
var select = document.getElementById('parameter-1-select');
select.options.length = 0
for(index in parameter1options) {
select.options[select.options.length] = new Option(parameter1options[index], index);
}
/* Moving this out of the function to make it accessible to other functions as well
var parameter2options = {
'happening' : 'Estimated percentage who think that global warming is happening',
'happeningOppose' : 'Estimated percentage who do not think that global warming is happening',
......@@ -430,7 +506,7 @@ require([
'congressOppose' : 'Estimated percentage who think Congress should be doing less/much less to address global warming',
'worried' : 'Estimated percentage who are somewhat/very worried about global warming',
'worriedOppose' : 'Estimated percentage who are not very/not at all worried about global warming'
};
};*/
var select = document.getElementById('parameter-2-select');
select.options.length = 0
for(index in parameter2options) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment