Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Idaho 2014-18 Prototype</title>
- <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
- <script src='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v2.2.0/mapbox-gl-geocoder.min.js'></script>
- <link rel='stylesheet' href='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v2.2.0/mapbox-gl-geocoder.css' type='text/css' />
- <script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.45.0/mapbox-gl.js'></script>
- <link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.45.0/mapbox-gl.css' rel='stylesheet' />
- </script>
- <style>
- body {
- margin: 0;
- padding: 0;}
- h1 {
- margin-left: 2px;
- margin-right: 2px;
- margin-bottom: 4px;
- margin-top: 4px;
- font-size: .75em;
- background-color: #c0c0c0;}
- h2 {
- margin-left: 10px;
- margin-right: 10px;
- margin-bottom: 4px;
- margin-top: 4px;
- font-size: 1.2em;
- text-align: center;}
- h3 {
- margin-left: 10px;
- margin-right: 10px;
- margin-bottom: 4px;
- margin-top: 4px;
- font-size: 1.2em;
- background-color: #c0c0c0;
- text-align: center;}
- p {
- font-size: 1em;
- line-height: 100%;
- margin-left: 10px;
- margin-right: 10px;
- margin-bottom: 2px;
- margin-top: 0px;
- text-align: left;
- }
- p1 { font-size: 1em;
- line-height: 100%;
- margin-left: 10px;
- margin-right: 10px;
- margin-bottom: 2px;
- margin-top: 0px;
- text-align: left;
- background-color: #ff7171;
- }
- p2 { font-size: 1em;
- line-height: 100%;
- margin-left: 10px;
- margin-right: 10px;
- margin-bottom: 2px;
- margin-top: 0px;
- text-align: left;
- background-color: #8282e5;
- }
- p3 { font-size: 1em;
- line-height: 100%;
- margin-left: 10px;
- margin-right: 10px;
- margin-bottom: 2px;
- margin-top: 0px;
- text-align: left;
- background-color: #42c041;
- }
- p4 { font-size: 1em;
- line-height: 100%;
- margin-left: 10px;
- margin-right: 10px;
- margin-bottom: 2px;
- margin-top: 0px;
- text-align: left;
- background-color: #c0c057;
- }
- p6 { font-size: .6em;
- line-height: 100%;
- margin-left: 2px;
- margin-right: 2px;
- margin-bottom: 2px;
- margin-top: 0px;
- text-align: left;
- }
- /**
- * Create a position for the map
- * on the page */
- #map {
- position: absolute;
- top: 0;
- bottom: 0;
- width: 100%;
- }
- #console {
- position: absolute;
- width: 120px;
- height: 95px;
- bottom: 40px;
- left: : 20px;
- margin: 5px;
- padding: 5px;
- background-color: white;
- opacity: .6;
- }
- .session {
- margin-left: 0px;
- margin-bottom: 5px;
- }
- .row {
- margin-left: 0px;
- height: 12px;
- width: 120px;
- margin-top: 10px;
- }
- .label {
- display: inline-block;
- text-align: left;
- }
- #map-overlay {
- font:bold 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif;
- position: relative;
- width: 50%;
- left: 0;
- padding: 0px;
- }
- .map-overlay .map-overlay-inner {
- background-color: #fff;
- box-shadow:0 1px 2px rgba(0, 0, 0, 0.20);
- border-radius: 3px;
- padding: 5px;
- margin-bottom: 2px;
- }
- .map-overlay label {
- display: block;
- margin: 0 0 5px;
- }
- .map-overlay input {
- background-color: transparent;
- display: inline-block;
- width: 100%;
- position: relative;
- margin: 0;
- cursor: ew-resize;
- }
- #csmap-overlay {
- font:bold 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif;
- position: relative;
- width: 50%;
- left: 0;
- top: 80px;
- padding: 0px;
- }
- .csmap-overlay .csmap-overlay-inner {
- background-color: #fff;
- box-shadow:0 1px 2px rgba(0, 0, 0, 0.20);
- border-radius: 3px;
- padding: 5px;
- margin-bottom: 2px;
- }
- .csmap-overlay label {
- display: block;
- margin: 0 0 5px;
- }
- .csmap-overlay input {
- background-color: transparent;
- display: inline-block;
- width: 100%;
- position: relative;
- margin: 0;
- cursor: ew-resize;
- }
- .csmap-year {
- position: relative;
- width: 100%;
- bottom: 5px;
- padding: 0px;
- }
- .csmap-year row {
- margin-left: 10px;
- padding: 0px;
- float: left;
- text-align: left;
- list-style: none;
- margin-bottom: 0px;
- margin-top: 0px;
- }
- .csmap-overlay .csmap-overlay-radio {
- background-color: #fff;
- border-radius: 3px;
- padding: 5px;
- margin-top: 2px;
- margin-bottom: 2px;
- }
- .csmap-overlay .csmap-overlay-radio ro {
- display: block;
- float: left;
- margin-left: 25%;
- margin-bottom: 10px;
- text-align: left;
- font-size: 100%;
- }
- .my-legend {
- font:bold 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif;
- position: absolute;
- width: 275px;
- top: 10px;
- left: 10px;
- padding: 0px;
- margin-bottom: 0px;
- margin-top: 0px;
- background-color: #ffffff;
- opacity: 0.8;
- }
- .my-legend .legend-title {
- text-align: left;
- margin-left: 2px;
- margin-bottom: 0px;
- font-weight: bold;
- font-size: 90%;
- }
- .my-legend .legend-scale ul {
- margin-left: 10px;
- padding: 0px;
- float: left;
- text-align: left;
- list-style: none;
- margin-bottom: 0px;
- margin-top: 0px;
- }
- .my-legend .legend-candidates cn {
- text-align: left;
- width: 100px;
- font-size: 10px;
- padding: 0px;
- margin-top: 0px;
- margin-bottom: 0px;
- }
- .my-legend .legend-scale ul li {
- display: block;
- float: left;
- width: 12px;
- margin-bottom: 0px;
- text-align: center;
- font-size: 80%;
- list-style: none;
- }
- .my-legend ul.legend-labels li span {
- display: block;
- float: left;
- height: 15px;
- width: 15px;
- margin-bottom: 0px;
- margin-top: 0px;
- }
- .my-legend .legend-source {
- font-size: 70%;
- color: #999;
- clear: both;
- }
- .my-legend a {
- color: #777;
- }
- .span {
- margin-top: 0px
- margin-bottom: 0px;
- }
- .menu {
- padding: 0;
- margin: 0;
- right: 300px;
- position: absolute;
- }
- .menu .menu {
- display: none;
- position: absolute;
- left: 0;
- width: 200px;
- }
- .menu .menu .menu {
- left: 100%;
- top: 0;
- }
- .menu li {
- position: relative;
- float: left;
- list-style: none;
- }
- .menu .menu li {
- float: none;
- }
- .menu li:hover > .menu {
- display: block;
- }
- .menu a {
- display: block;
- border: 1px solid #fff;
- padding: 10px;
- background: lightgray;
- }
- #menu {
- background: #fff;
- position: absolute;
- z-index: 1;
- bottom: 30px;
- left: 10px;
- border-radius: 3px;
- width: 80px;
- border: 1px solid rgba(0,0,0,0.4);
- font-family: 'Open Sans', sans-serif;
- }
- #menu a {
- font-size: 13px;
- color: #404040;
- display: block;
- margin: 0;
- padding: 0;
- padding: 10px;
- text-decoration: none;
- border-bottom: 1px solid rgba(0,0,0,0.25);
- text-align: center;
- }
- #menu a:last-child {
- border: none;
- }
- #menu a:hover {
- background-color: #f8f8f8;
- color: #404040;
- }
- #menu a.active {
- background-color: #3887be;
- color: #ffffff;
- }
- #menu a.active:hover {
- background: #3074a4;
- }
- #menu a.county {
- background-color: #3887be;
- color: #ffffff;
- }
- #menu a.county:hover {
- background: #3074a4;
- }
- #menu a.header {
- background-color: #707070;
- color: #ffffff;
- }
- #menu1 {
- background: #fff;
- position: absolute;
- z-index: 1;
- bottom: 30px;
- left: 140px;
- border-radius: 3px;
- width: 90px;
- border: 1px solid rgba(0,0,0,0.4);
- font-family: 'Open Sans', sans-serif;
- }
- #menu1 a {
- font-size: 13px;
- color: #404040;
- display: block;
- margin: 0;
- padding: 0;
- padding: 10px;
- text-decoration: none;
- border-bottom: 1px solid rgba(0,0,0,0.25);
- text-align: center;
- }
- #menu1 a:last-child {
- border: none;
- }
- #menu1 a:hover {
- background-color: #f8f8f8;
- color: #404040;
- }
- #menu1 a.active1 {
- background-color: #3887be;
- color: #ffffff;
- }
- #menu1 a.active1:hover {
- background: #3074a4;
- }
- #menu1 a.header {
- background-color: #707070;
- color: #ffffff;
- }
- #menu2 {
- background: #fff;
- position: absolute;
- z-index: 1;
- bottom: 30px;
- left: 140px;
- border-radius: 3px;
- width: 90px;
- border: 1px solid rgba(0,0,0,0.4);
- font-family: 'Open Sans', sans-serif;
- }
- #menu2 a {
- font-size: 13px;
- color: #404040;
- display: block;
- margin: 0;
- padding: 0;
- padding: 10px;
- text-decoration: none;
- border-bottom: 1px solid rgba(0,0,0,0.25);
- text-align: center;
- }
- #menu2 a:last-child {
- border: none;
- }
- #menu2 a:hover {
- background-color: #f8f8f8;
- color: #404040;
- }
- #menu2 a.active2 {
- background-color: #3887be;
- color: #ffffff;
- }
- #menu2 a.active2:hover {
- background: #3074a4;
- }
- #menu2 a.header {
- background-color: #707070;
- color: #ffffff;
- }
- #menu3 {
- background: #fff;
- position: absolute;
- z-index: 1;
- bottom: 30px;
- left: 140px;
- border-radius: 3px;
- width: 90px;
- border: 1px solid rgba(0,0,0,0.4);
- font-family: 'Open Sans', sans-serif;
- }
- #menu3 a {
- font-size: 13px;
- color: #404040;
- display: block;
- margin: 0;
- padding: 0;
- padding: 10px;
- text-decoration: none;
- border-bottom: 1px solid rgba(0,0,0,0.25);
- text-align: center;
- }
- #menu3 a:last-child {
- border: none;
- }
- #menu3 a:hover {
- background-color: #f8f8f8;
- color: #404040;
- }
- #menu3 a.active3 {
- background-color: #3887be;
- color: #ffffff;
- }
- #menu3 a.active3:hover {
- background: #3074a4;
- }
- #menu3 a.header {
- background-color: #707070;
- color: #ffffff;
- }
- #menu4 {
- background: #fff;
- position: absolute;
- z-index: 1;
- bottom: 30px;
- left: 140px;
- border-radius: 3px;
- width: 90px;
- border: 1px solid rgba(0,0,0,0.4);
- font-family: 'Open Sans', sans-serif;
- }
- #menu4 a {
- font-size: 13px;
- color: #404040;
- display: block;
- margin: 0;
- padding: 0;
- padding: 10px;
- text-decoration: none;
- border-bottom: 1px solid rgba(0,0,0,0.25);
- text-align: center;
- }
- #menu4 a:last-child {
- border: none;
- }
- #menu4 a:hover {
- background-color: #f8f8f8;
- color: #404040;
- }
- #menu4 a.active4 {
- background-color: #3887be;
- color: #ffffff;
- }
- #menu4 a.active4:hover {
- background: #3074a4;
- }
- #menu2014 {
- background: #fff;
- position: absolute;
- z-index: 1;
- bottom: 30px;
- left: 90px;
- border-radius: 3px;
- width: 50px;
- border: 1px solid rgba(0,0,0,0.4);
- font-family: 'Open Sans', sans-serif;
- }
- #menu4 a.header {
- background-color: #707070;
- color: #ffffff;
- }
- #menu2014 a {
- font-size: 13px;
- color: #404040;
- display: block;
- margin: 0;
- padding: 0;
- padding: 10px;
- text-decoration: none;
- border-bottom: 1px solid rgba(0,0,0,0.25);
- text-align: center;
- }
- #menu2014 a:last-child {
- border: none;
- }
- #menu2014 a:hover {
- background-color: #f8f8f8;
- color: #404040;
- }
- #menu2014 a.active2014 {
- background-color: #3887be;
- color: #ffffff;
- }
- #menu2014 a.active2014:hover {
- background: #3074a4;
- }
- #menu2014 a.header {
- background-color: #707070;
- color: #ffffff;
- }
- #menu2018 {
- background: #fff;
- position: absolute;
- z-index: 1;
- bottom: 30px;
- left: 90px;
- border-radius: 3px;
- width: 50px;
- border: 1px solid rgba(0,0,0,0.4);
- font-family: 'Open Sans', sans-serif;
- }
- #menu2018 a {
- font-size: 13px;
- color: #404040;
- display: block;
- margin: 0;
- padding: 0;
- padding: 10px;
- text-decoration: none;
- border-bottom: 1px solid rgba(0,0,0,0.25);
- text-align: center;
- }
- #menu2018 a:last-child {
- border: none;
- }
- #menu2018 a:hover {
- background-color: #f8f8f8;
- color: #404040;
- }
- #menu2018 a.active2018 {
- background-color: #3887be;
- color: #ffffff;
- }
- #menu2018 a.active2018:hover {
- background: #3074a4;
- }
- #menu2018 a.header {
- background-color: #707070;
- color: #ffffff;
- }
- worker-src blob: ;
- child-src blob: ;
- img-src data: blob: ;
- connect-src https://*.tiles.mapbox.com https://api.mapbox.com
- /**
- </style>
- <div id='map'></div>
- <nav id ='menu'></nav>
- <nav id = 'menu2014'></nav>
- <nav id = 'menu2018'></nav>
- <nav id = 'menu1'></nav>
- <nav id = 'menu2'></nav>
- <nav id = 'menu3'></nav>
- <nav id = 'menu4'></nav>
- <nav id ='menu.menu2018'></nav>
- <div class='my-legend'>
- <div class='legend-title'><span id='legend-title'></span></div>
- <div class='legend-scale'>
- <tr><ul class='legend-labels'>
- <li><span id = 'color-value-2-0' style=''></span></li>
- <li><span id = 'color-value-210' style=''></span></li>
- <li><span id = 'color-value-220' style=''></span></li>
- <li><span id = 'color-value-230' style=''></span></li>
- <li><span id = 'color-value-240' style=''></span></li>
- <li><span id = 'color-value-250' style=''></span></li>
- <li><span id = 'color-value-260' style=''></span></li>
- <li><span id = 'color-value-270' style=''></span></li>
- <li><span id = 'color-value-280' style=''></span></li>
- <li><span id = 'color-value-290' style=''></span></li>
- <li><span id = 'color-value-300'style=''></span></li>
- <li><span id = 'color-value-3-10'style=''></span></li>
- </ul><ul class ='legend-candidates'><cn id='legend-CandidateC'></cn><cn id = 'legend-C-pct'></cn></ul></tr>
- <tr><ul class='legend-labels'>
- <li><span id = 'color-value-3-0' style=''></span></li>
- <li><span id = 'color-value-310' style=''></span></li>
- <li><span id = 'color-value-320' style=''></span></li>
- <li><span id = 'color-value-330' style=''></span></li>
- <li><span id = 'color-value-340' style=''></span></li>
- <li><span id = 'color-value-350' style=''></span></li>
- <li><span id = 'color-value-360' style=''></span></li>
- <li><span id = 'color-value-370' style=''></span></li>
- <li><span id = 'color-value-380' style=''></span></li>
- <li><span id = 'color-value-390' style=''></span></li>
- <li><span id = 'color-value-400'style=''></span></li>
- <li><span id = 'color-value-4-10'style=''></span></li>
- </ul><ul class ='legend-candidates'><cn id='legend-CandidateD'></cn><cn id = 'legend-D-pct'></cn></ul></tr>
- <tr><ul class='legend-labels'>
- <li><span id = 'color-value-4-0' style=''></span></li>
- <li><span id = 'color-value-410' style=''></span></li>
- <li><span id = 'color-value-420' style=''></span></li>
- <li><span id = 'color-value-430' style=''></span></li>
- <li><span id = 'color-value-440' style=''></span></li>
- <li><span id = 'color-value-450' style=''></span></li>
- <li><span id = 'color-value-460' style=''></span></li>
- <li><span id = 'color-value-470' style=''></span></li>
- <li><span id = 'color-value-480' style=''></span></li>
- <li><span id = 'color-value-490' style=''></span></li>
- <li><span id = 'color-value-500'style=''></span></li>
- <li><span id = 'color-value-5-10'style=''></span></li>
- </ul> <ul class ='legend-candidates'><cn id='legend-CandidateE'></cn><cn id = 'legend-E-pct'></cn></ul></tr>
- <tr><ul class ='legend-labels'>
- <li><span id='color-value-5-0' style=''></span><span = id = 'color-pct-0'>0%</span></li>
- <li><span id = 'color-value-510' style=''></span><span = id = 'color-pct-10'>10</span></li>
- <li><span id = 'color-value-520' style=''></span><span = id = 'color-pct-20'>20</span></li>
- <li><span id = 'color-value-530' style=''></span><span = id = 'color-pct-30'>30</span></li>
- <li><span id = 'color-value-540' style=''></span><span = id = 'color-pct-40'>40</span></li>
- <li><span id = 'color-value-550' style=''></span><span = id = 'color-pct-50'>50</span></li>
- <li><span id = 'color-value-560' style=''></span><span = id = 'color-pct-60'>60</span></li>
- <li><span id = 'color-value-570'style=''></span><span = id = 'color-pct-70'>70</span></li>
- <li><span id = 'color-value-580'style=''></span><span = id = 'color-pct-80'>80</span></li>
- <li><span id = 'color-value-590'style=''></span><span = id = 'color-pct-90'>90</span></li>
- <li><span id = 'color-value-600'style=''></span><span = id = 'color-pct-100'>99</span></li>
- <li><span id = 'color-value-6-10'style=''></span><span = id = 'color-pct-110'> 100%</span></li></ul>
- <ul class ='legend-candidates'><cn id='legend-CandidateF'>' '</cn><cn id = 'legend-F-pct'></cn></ul></tr>
- </div>
- <div class='legend-source'>Source: Idaho Secretary of State & Various Counties</div>
- <div class='map-overlay top'>
- <div class='map-overlay-inner'>
- <label>Layer opacity: <span id='slider-value'>75%</span></label>
- <input id='slider' type='range' min='0' max='100' step='0' value='75' />
- </div>
- </div>
- <div class='csmap-overlay top'>
- <div class='csmap-overlay-inner'>
- <label>Color Step: <span id='csslider-value'>10 points</span></label>
- <input id='csslider' type='range' min='1' max='100' step='0' value='100' />
- </div>
- </div>
- </head>
- <script>
- mapboxgl.accessToken = 'pk.eyJ1IjoiY2lueWMiLCJhIjoiY2plcDc5c2x1MnlhNDJ4bWVkODVqOWo1bCJ9.6ASroxRY3cWjadWnJz4fXA';
- var map = new mapboxgl.Map({
- container: 'map', // container id
- style: 'mapbox://styles/cinyc/cjic6stwl03q72sp76lddrh8p', // stylesheet location
- center: [-114.32, 43.50], // starting position [lng, lat]
- zoom: 7.0 // starting zoom
- });
- //must change for different races
- var layer1 = 'ID_Precinct-County_for_Websit-5ovw6t';
- var layerCounty = 'Idaho_County_2017-1dyjc1';
- var layer2 = 'ID_Precinct_2014_Final_Data_M-dyrpv7';
- var Wincode = "G_SPEWinco";
- var Wincode2 = 'G_14SupEdG';
- var Wincode3 = 'G_14GovGEW';
- var Wincode4 = 'G_Gwincode';
- var Red = "G_PCTYbarr";
- var Blue = "G_PCTWilso";
- var Green = '';
- var Yellow = "";
- var Orange = '';
- var Purple = '';
- var Red2 = "G_PCTWasde";
- var Blue2 = "G_PCTJones";
- var Green2 = '';
- var Yellow2 = "";
- var Orange2 = '';
- var Purple2 = '';
- var Red3 = "G_PCTOtter";
- var Blue3 = "G_PCTBaluk";
- var Green3 = 'G_PCTHumbl';
- var Yellow3 = "G_PCTBujak";
- var Orange3 = 'G_PCTPanke';
- var Purple3 = 'G_PCTPro-L';
- var Red4 = "G_PCTLittl";
- var Blue4 = "G_PCTJorda";
- var Green4 = '';
- var Yellow4 = "G_PCTBoek";
- var Orange4 = 'G_PCTBayes';
- var Purple4 = '';
- var RedCandidate = "Ybarra";
- var BlueCandidate = "Wilson";
- var GreenCandidate = '';
- var YellowCandidate = "";
- var OrangeCandidate = '';
- var PurpleCandidate = '';
- var RedCandidate2 = "Ybarra";
- var BlueCandidate2 = "Jones";
- var GreenCandidate2 = '';
- var YellowCandidate2 = "";
- var OrangeCandidate2 = '';
- var PurpleCandidate2 = '';
- var RedCandidate3 = "Otter";
- var BlueCandidate3 = "Balukoff";
- var GreenCandidate3 = 'Humble';
- var YellowCandidate3 = "Bujak";
- var OrangeCandidate3 = 'Pankey';
- var PurpleCandidate3 = 'Pro-Life';
- var RedCandidate4 = "Little";
- var BlueCandidate4 = "Jordan";
- var GreenCandidate4 = '';
- var YellowCandidate4 = "Boeck";
- var OrangeCandidate4 = 'Bayes';
- var PurpleCandidate4 = '';
- var RedStatewidePCT = '51.4';
- var BlueStatewidePCT = '48.6';
- var GreenStatewidePCT = '';
- var YellowStatewidePCT = '';
- var OrangeStatewidePCT = '';
- var PurpleStatewidePCT = '';
- var RedStatewidePCT2 = '50.9';
- var BlueStatewidePCT2 = '49.1';
- var GreenStatewidePCT2 = '';
- var YellowStatewidePCT2 = '';
- var OrangeStatewidePCT2 = '';
- var PurpleStatewidePCT2 = '';
- var RedStatewidePCT3 = '50.9';
- var BlueStatewidePCT3 = '49.1';
- var GreenStatewidePCT3 = '2.0';
- var YellowStatewidePCT3 = '4.3';
- var OrangeStatewidePCT3 = '1.2';
- var PurpleStatewidePCT3 = '0.7';
- var RedStatewidePCT4 = '59.8';
- var BlueStatewidePCT4 = '38.2';
- var GreenStatewidePCT4 = '';
- var YellowStatewidePCT4 = '1.1';
- var OrangeStatewidePCT4 = '1.0';
- var PurpleStatewidePCT4 = '';
- var StatewideVotes = '594,459';
- var StatewideVotes2 = '381,874';
- var StatewideVotes3 = '391,992';
- var StatewideVotes4 = ' 605,176';
- var TotalVotes = 'G_SPETotal';
- var TotalVotes2 = 'G_SupEdTot';
- var TotalVotes3 = 'G_GovTotal';
- var TotalVotes4 = 'G_Gtotal';
- var precname1 = 'G_NAME18';
- var precname2 = 'PRECINCT14';
- var precname3 = 'PRECINCT14';
- var precname4 = 'G_NAME18';
- var County = 'G_County';
- var County2 = '';
- var County3 = '';
- var County4 = 'G_County';
- //define default color scale (1=10 points)
- var colorscale = 1;
- //define slider values
- var slider = document.getElementById('slider');
- var sliderValue = document.getElementById('slider-value');
- var csslider = document.getElementById('csslider');
- var cssliderValue = document.getElementById('csslider-value');
- //define legend values
- var colorpct500b = document.getElementById('color-pct5-0');
- var colorpct510 = document.getElementById('color-pct-10');
- var colorpct520 = document.getElementById('color-pct-20');
- var colorpct530 = document.getElementById('color-pct-30');
- var colorpct540 = document.getElementById('color-pct-40');
- var colorpct550 = document.getElementById('color-pct-50');
- var colorpct560 = document.getElementById('color-pct-60');
- var colorpct570 = document.getElementById('color-pct-70');
- var colorpct580 = document.getElementById('color-pct-80');
- var colorpct590 = document.getElementById('color-pct-90');
- var colorpct600 = document.getElementById('color-pct-100');
- var colorpct600a = document.getElementById('color-pct-110');
- var colorvalue200b = document.getElementById('color-value-2-0');
- var colorvalue210 = document.getElementById('color-value-210');
- var colorvalue220 = document.getElementById('color-value-220');
- var colorvalue230 = document.getElementById('color-value-230');
- var colorvalue240 = document.getElementById('color-value-240');
- var colorvalue250 = document.getElementById('color-value-250');
- var colorvalue260 = document.getElementById('color-value-260');
- var colorvalue270 = document.getElementById('color-value-270');
- var colorvalue280 = document.getElementById('color-value-280');
- var colorvalue290 = document.getElementById('color-value-290');
- var colorvalue300 = document.getElementById('color-value-300');
- var colorvalue300a = document.getElementById('color-value-3-10');
- var colorvalue300b = document.getElementById('color-value-3-0');
- var colorvalue310 = document.getElementById('color-value-310');
- var colorvalue320 = document.getElementById('color-value-320');
- var colorvalue330 = document.getElementById('color-value-330');
- var colorvalue340 = document.getElementById('color-value-340');
- var colorvalue350 = document.getElementById('color-value-350');
- var colorvalue360 = document.getElementById('color-value-360');
- var colorvalue370 = document.getElementById('color-value-370');
- var colorvalue380 = document.getElementById('color-value-380');
- var colorvalue390 = document.getElementById('color-value-390');
- var colorvalue400 = document.getElementById('color-value-400');
- var colorvalue400a = document.getElementById('color-value-4-10');
- var colorvalue400b = document.getElementById('color-value-4-0');
- var colorvalue410 = document.getElementById('color-value-410');
- var colorvalue420 = document.getElementById('color-value-420');
- var colorvalue430 = document.getElementById('color-value-430');
- var colorvalue440 = document.getElementById('color-value-440');
- var colorvalue450 = document.getElementById('color-value-450');
- var colorvalue460 = document.getElementById('color-value-460');
- var colorvalue470 = document.getElementById('color-value-470');
- var colorvalue480 = document.getElementById('color-value-480');
- var colorvalue490 = document.getElementById('color-value-490');
- var colorvalue500 = document.getElementById('color-value-500');
- var colorvalue500a = document.getElementById('color-value-5-10');
- var colorvalue500b = document.getElementById('color-value-5-0');
- var colorvalue510 = document.getElementById('color-value-510');
- var colorvalue520 = document.getElementById('color-value-520');
- var colorvalue530 = document.getElementById('color-value-530');
- var colorvalue540 = document.getElementById('color-value-540');
- var colorvalue550 = document.getElementById('color-value-550');
- var colorvalue560 = document.getElementById('color-value-560');
- var colorvalue570 = document.getElementById('color-value-570');
- var colorvalue580 = document.getElementById('color-value-580');
- var colorvalue590 = document.getElementById('color-value-590');
- var colorvalue600 = document.getElementById('color-value-600');
- var colorvalue600a = document.getElementById('color-value-6-10');
- var background = 'background:';
- var candidateC = document.getElementById('legend-CandidateC');
- var candidateD = document.getElementById('legend-CandidateD');
- var candidateE = document.getElementById('legend-CandidateE');
- var candidateF = document.getElementById('legend-CandidateF');
- var cpct = document.getElementById('legend-C-pct');
- var dpct = document.getElementById('legend-D-pct');
- var epct = document.getElementById('legend-E-pct');
- var fpct = document.getElementById('legend-F-pct');
- var legendtitle = document.getElementById('legend-title');
- //define colors
- var red0 = '#909090';
- var red10 = '#ffbfbf';
- var red20 =' #ffacac';
- var red30 = '#ff9898';
- var red40 = '#ff8585';
- var red50 = '#ff7171';
- var red60 = '#ff5d5d';
- var red70 = '#ff4a4a';
- var red80 = '#ff3636';
- var red90 = '#ff2323';
- var red100 = '#ff0f0f';
- var red100a = '#ff0000';
- var blue0 = '#909090';
- var blue10 = '#bbbbfe';
- var blue20 = '#a8a8f5';
- var blue30 = '#9595ed';
- var blue40 = '#8282e5';
- var blue50 = '#6f6fdc';
- var blue60 = '#5c5cd4';
- var blue70 = '#4848cb';
- var blue80 = '#3535c3';
- var blue90 = '#2222bb';
- var blue100 = '#0f0fb2';
- var blue100a = '#0909aa'
- var green0 = '#909090';
- var green10 = '#abe6ab';
- var green20 = '#9ae099';
- var green30 = '#88d988';
- var green40 = '#77d376';
- var green50 = '#65cc64';
- var green60 = '#54c653';
- var green70 = '#42c041';
- var green80 = '#31b92f';
- var green90 = '#1fb31e';
- var green100 = '#0ead0c';
- var green100a = '#00a500';
- var yellow0 = '#909090';
- var yellow10 = '#fcfcb9';
- var yellow20 = '#f0f0a6';
- var yellow30 = '#e4e492';
- var yellow40 = '#d8d87e';
- var yellow50 = '#cccc6b';
- var yellow60 = '#c0c057';
- var yellow70 = '#b4b443';
- var yellow80 = '#a8a830';
- var yellow90 = '#9c9c1c';
- var yellow100 = '#909008';
- var yellow100a = '#7a7a00';
- var orange0 = '#909090';
- var orange10 = '#ffdbb7';
- var orange20 = '#ffd1a4';
- var orange30 = '#ffc790';
- var orange40 = '#ffbc7d';
- var orange50 = '#ffb269';
- var orange60 = '#ffa855';
- var orange70 = '#ff9e42';
- var orange80 = '#ff932e';
- var orange90 = '#ff891b';
- var orange100 = '#ff7f07';
- var orange100a = '#ff6e02';
- var purple0 = '#909090';
- var purple10 = '#e2a4e2';
- var purple20 = '#da92da';
- var purple30 = '#d280d2';
- var purple40 = '#ca6fca';
- var purple50 = '#c25dc2';
- var purple60 = '#b94bb9';
- var purple70 = '#b13ab1';
- var purple80 = '#a928a9';
- var purple90 = '#a116a1';
- var purple100 = '#990599';
- var purple100a = '#860081';
- var tie = '#c0c0c0';
- var novotes = '#707070';
- var white = '#ffffff';
- //define color schemes
- var Multi = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Wincode]
- ],
- 0, red0,
- 0.0000001, red10,
- 0.1*colorscale, red20,
- 0.2*colorscale, red30,
- 0.3*colorscale, red40,
- 0.4*colorscale, red50,
- 0.5*colorscale, red60,
- 0.6*colorscale, red70,
- 0.7*colorscale, red80,
- 0.8*colorscale, red90,
- 0.9*colorscale, red100,
- 1, red100a,
- 1.00000001, green10,
- 1+(.1*colorscale), green20,
- 1+(.2*colorscale), green30,
- 1+(.3*colorscale), green40,
- 1+(.4*colorscale), green50,
- 1+(.5*colorscale), green60,
- 1+(.6*colorscale), green70,
- 1+(.7*colorscale), green80,
- 1+(.8*colorscale), green90,
- 1+(.9*colorscale), green100,
- 2, green100a,
- 2.00000001, blue10,
- 2+(.1*colorscale), blue20,
- 2+(.2*colorscale), blue30,
- 2+(.3*colorscale), blue40,
- 2+(.4*colorscale), blue50,
- 2+(.5*colorscale), blue60,
- 2+(.6*colorscale), blue70,
- 2+(.7*colorscale), blue80,
- 2+(.8*colorscale), blue90,
- 2+(.9*colorscale), blue100,
- 3, blue100a,
- 3.00000001, yellow10,
- 3+(.1*colorscale), yellow20,
- 3+(.2*colorscale), yellow30,
- 3+(.3*colorscale), yellow40,
- 3+(.4*colorscale), yellow50,
- 3+(.5*colorscale), yellow60,
- 3+(.6*colorscale), yellow70,
- 3+(.7*colorscale), yellow80,
- 3+(.8*colorscale), yellow90,
- 3+(.9*colorscale), yellow100,
- 4, yellow100a,
- 4.00000001, orange10,
- 4+(.1*colorscale), orange20,
- 4+(.2*colorscale), orange30,
- 4+(.3*colorscale), orange40,
- 4+(.4*colorscale), orange50,
- 4+(.5*colorscale), orange60,
- 4+(.6*colorscale), orange70,
- 4+(.7*colorscale), orange80,
- 4+(.8*colorscale), orange90,
- 4+(.9*colorscale), orange100,
- 5, orange100a,
- 5.00000001, purple10,
- 5+(.1*colorscale), purple20,
- 5+(.2*colorscale), purple30,
- 5+(.3*colorscale), purple40,
- 5+(.4*colorscale), purple50,
- 5+(.5*colorscale), purple60,
- 5+(.6*colorscale), purple70,
- 5+(.7*colorscale), purple80,
- 5+(.8*colorscale), purple90,
- 5+(.9*colorscale), purple100,
- 6, purple100a,
- 9, tie,
- 10, novotes,
- ];
- var ColorRed =
- ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Red]
- ],
- 0, red0,
- 0.0001, red10,
- 0.1*colorscale, red20,
- 0.2*colorscale, red30,
- 0.3*colorscale, red40,
- 0.4*colorscale, red50,
- 0.5*colorscale, red60,
- 0.6*colorscale, red70,
- 0.7*colorscale, red80,
- 0.8*colorscale, red90,
- 0.9*colorscale, red100,
- 1*colorscale, red100a
- ]
- var ColorBlue = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Blue]
- ],
- 0, blue0,
- 0.001, blue10,
- 0.1*colorscale,blue20,
- 0.2*colorscale, blue30,
- 0.3*colorscale, blue40,
- 0.4*colorscale, blue50,
- 0.5*colorscale, blue60,
- 0.6*colorscale, blue70,
- 0.7*colorscale, blue80,
- 0.8*colorscale, blue90,
- 0.9*colorscale, blue100,
- 1*colorscale, blue100a
- ]
- var ColorGreen = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Green]
- ],
- 0, green0,
- 0.001, green10,
- 0.1*colorscale, green20,
- 0.2*colorscale, green30,
- 0.3*colorscale, green40,
- 0.4*colorscale, green50,
- 0.5*colorscale, green60,
- 0.6*colorscale, green70,
- 0.7*colorscale, green80,
- 0.8*colorscale, green90,
- 0.9*colorscale, green100,
- 1*colorscale, green100a
- ]
- var ColorYellow = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Yellow]
- ],
- 0, yellow0,
- 0.001, yellow10,
- 0.1*colorscale, yellow20,
- 0.2*colorscale, yellow30,
- 0.3*colorscale, yellow40,
- 0.4*colorscale, yellow50,
- 0.5*colorscale, yellow60,
- 0.6*colorscale, yellow70,
- 0.7*colorscale, yellow80,
- 0.8*colorscale, yellow90,
- 0.9*colorscale, yellow100,
- 1.0*colorscale, yellow100a,
- ]
- var ColorOrange = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Orange]
- ],
- 0, orange0,
- 0.001, orange10,
- 0.1*colorscale, orange20,
- 0.2*colorscale, orange30,
- 0.3*colorscale, orange40,
- 0.4*colorscale, orange50,
- 0.5*colorscale, orange60,
- 0.6*colorscale, orange70,
- 0.7*colorscale, orange80,
- 0.8*colorscale, orange90,
- 0.9*colorscale, orange100,
- 1.0*colorscale, orange100a,
- ]
- var ColorPurple = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Purple]
- ],
- 0,purple0,
- 0.001,purple10,
- 0.1*colorscale, purple20,
- 0.2*colorscale, purple30,
- 0.3*colorscale, purple40,
- 0.4*colorscale, purple50,
- 0.5*colorscale, purple60,
- 0.6*colorscale, purple70,
- 0.7*colorscale, purple80,
- 0.8*colorscale, purple90,
- 0.9*colorscale, purple100,
- 1.0*colorscale, purple100a
- ]
- var Multi2 = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Wincode2]
- ],
- 0, red0,
- 0.0000001, red10,
- 0.1*colorscale, red20,
- 0.2*colorscale, red30,
- 0.3*colorscale, red40,
- 0.4*colorscale, red50,
- 0.5*colorscale, red60,
- 0.6*colorscale, red70,
- 0.7*colorscale, red80,
- 0.8*colorscale, red90,
- 0.9*colorscale, red100,
- 1, red100a,
- 1.00000001, green10,
- 1+(.1*colorscale), green20,
- 1+(.2*colorscale), green30,
- 1+(.3*colorscale), green40,
- 1+(.4*colorscale), green50,
- 1+(.5*colorscale), green60,
- 1+(.6*colorscale), green70,
- 1+(.7*colorscale), green80,
- 1+(.8*colorscale), green90,
- 1+(.9*colorscale), green100,
- 2, green100a,
- 2.00000001, blue10,
- 2+(.1*colorscale), blue20,
- 2+(.2*colorscale), blue30,
- 2+(.3*colorscale), blue40,
- 2+(.4*colorscale), blue50,
- 2+(.5*colorscale), blue60,
- 2+(.6*colorscale), blue70,
- 2+(.7*colorscale), blue80,
- 2+(.8*colorscale), blue90,
- 2+(.9*colorscale), blue100,
- 3, blue100a,
- 3.00000001, yellow10,
- 3+(.1*colorscale), yellow20,
- 3+(.2*colorscale), yellow30,
- 3+(.3*colorscale), yellow40,
- 3+(.4*colorscale), yellow50,
- 3+(.5*colorscale), yellow60,
- 3+(.6*colorscale), yellow70,
- 3+(.7*colorscale), yellow80,
- 3+(.8*colorscale), yellow90,
- 3+(.9*colorscale), yellow100,
- 4, yellow100a,
- 4.00000001, orange10,
- 4+(.1*colorscale), orange20,
- 4+(.2*colorscale), orange30,
- 4+(.3*colorscale), orange40,
- 4+(.4*colorscale), orange50,
- 4+(.5*colorscale), orange60,
- 4+(.6*colorscale), orange70,
- 4+(.7*colorscale), orange80,
- 4+(.8*colorscale), orange90,
- 4+(.9*colorscale), orange100,
- 5, orange100a,
- 5.00000001, purple10,
- 5+(.1*colorscale), purple20,
- 5+(.2*colorscale), purple30,
- 5+(.3*colorscale), purple40,
- 5+(.4*colorscale), purple50,
- 5+(.5*colorscale), purple60,
- 5+(.6*colorscale), purple70,
- 5+(.7*colorscale), purple80,
- 5+(.8*colorscale), purple90,
- 5+(.9*colorscale), purple100,
- 6, purple100a,
- 9, tie,
- 10, novotes,
- ];
- var ColorRed2 =
- ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Red2]
- ],
- 0, red0,
- 0.0001, red10,
- 0.1*colorscale, red20,
- 0.2*colorscale, red30,
- 0.3*colorscale, red40,
- 0.4*colorscale, red50,
- 0.5*colorscale, red60,
- 0.6*colorscale, red70,
- 0.7*colorscale, red80,
- 0.8*colorscale, red90,
- 0.9*colorscale, red100,
- 1*colorscale, red100a
- ]
- var ColorBlue2 = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Blue2]
- ],
- 0, blue0,
- 0.001, blue10,
- 0.1*colorscale,blue20,
- 0.2*colorscale, blue30,
- 0.3*colorscale, blue40,
- 0.4*colorscale, blue50,
- 0.5*colorscale, blue60,
- 0.6*colorscale, blue70,
- 0.7*colorscale, blue80,
- 0.8*colorscale, blue90,
- 0.9*colorscale, blue100,
- 1*colorscale, blue100a
- ]
- var ColorGreen2 = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Green2]
- ],
- 0, green0,
- 0.001, green10,
- 0.1*colorscale, green20,
- 0.2*colorscale, green30,
- 0.3*colorscale, green40,
- 0.4*colorscale, green50,
- 0.5*colorscale, green60,
- 0.6*colorscale, green70,
- 0.7*colorscale, green80,
- 0.8*colorscale, green90,
- 0.9*colorscale, green100,
- 1*colorscale, green100a
- ]
- var ColorYellow2 = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Yellow2]
- ],
- 0, yellow0,
- 0.001, yellow10,
- 0.1*colorscale, yellow20,
- 0.2*colorscale, yellow30,
- 0.3*colorscale, yellow40,
- 0.4*colorscale, yellow50,
- 0.5*colorscale, yellow60,
- 0.6*colorscale, yellow70,
- 0.7*colorscale, yellow80,
- 0.8*colorscale, yellow90,
- 0.9*colorscale, yellow100,
- 1.0*colorscale, yellow100a,
- ]
- var ColorOrange2 = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Orange2]
- ],
- 0, orange0,
- 0.001, orange10,
- 0.1*colorscale, orange20,
- 0.2*colorscale, orange30,
- 0.3*colorscale, orange40,
- 0.4*colorscale, orange50,
- 0.5*colorscale, orange60,
- 0.6*colorscale, orange70,
- 0.7*colorscale, orange80,
- 0.8*colorscale, orange90,
- 0.9*colorscale, orange100,
- 1.0*colorscale, orange100a,
- ]
- var ColorPurple2 = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Purple2]
- ],
- 0,purple0,
- 0.001,purple10,
- 0.1*colorscale, purple20,
- 0.2*colorscale, purple30,
- 0.3*colorscale, purple40,
- 0.4*colorscale, purple50,
- 0.5*colorscale, purple60,
- 0.6*colorscale, purple70,
- 0.7*colorscale, purple80,
- 0.8*colorscale, purple90,
- 0.9*colorscale, purple100,
- 1.0*colorscale, purple100a
- ]
- var Multi3 = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Wincode3]
- ],
- 0, red0,
- 0.0000001, red10,
- 0.1*colorscale, red20,
- 0.2*colorscale, red30,
- 0.3*colorscale, red40,
- 0.4*colorscale, red50,
- 0.5*colorscale, red60,
- 0.6*colorscale, red70,
- 0.7*colorscale, red80,
- 0.8*colorscale, red90,
- 0.9*colorscale, red100,
- 1, red100a,
- 1.00000001, green10,
- 1+(.1*colorscale), green20,
- 1+(.2*colorscale), green30,
- 1+(.3*colorscale), green40,
- 1+(.4*colorscale), green50,
- 1+(.5*colorscale), green60,
- 1+(.6*colorscale), green70,
- 1+(.7*colorscale), green80,
- 1+(.8*colorscale), green90,
- 1+(.9*colorscale), green100,
- 2, green100a,
- 2.00000001, blue10,
- 2+(.1*colorscale), blue20,
- 2+(.2*colorscale), blue30,
- 2+(.3*colorscale), blue40,
- 2+(.4*colorscale), blue50,
- 2+(.5*colorscale), blue60,
- 2+(.6*colorscale), blue70,
- 2+(.7*colorscale), blue80,
- 2+(.8*colorscale), blue90,
- 2+(.9*colorscale), blue100,
- 3, blue100a,
- 3.00000001, yellow10,
- 3+(.1*colorscale), yellow20,
- 3+(.2*colorscale), yellow30,
- 3+(.3*colorscale), yellow40,
- 3+(.4*colorscale), yellow50,
- 3+(.5*colorscale), yellow60,
- 3+(.6*colorscale), yellow70,
- 3+(.7*colorscale), yellow80,
- 3+(.8*colorscale), yellow90,
- 3+(.9*colorscale), yellow100,
- 4, yellow100a,
- 4.00000001, orange10,
- 4+(.1*colorscale), orange20,
- 4+(.2*colorscale), orange30,
- 4+(.3*colorscale), orange40,
- 4+(.4*colorscale), orange50,
- 4+(.5*colorscale), orange60,
- 4+(.6*colorscale), orange70,
- 4+(.7*colorscale), orange80,
- 4+(.8*colorscale), orange90,
- 4+(.9*colorscale), orange100,
- 5, orange100a,
- 5.00000001, purple10,
- 5+(.1*colorscale), purple20,
- 5+(.2*colorscale), purple30,
- 5+(.3*colorscale), purple40,
- 5+(.4*colorscale), purple50,
- 5+(.5*colorscale), purple60,
- 5+(.6*colorscale), purple70,
- 5+(.7*colorscale), purple80,
- 5+(.8*colorscale), purple90,
- 5+(.9*colorscale), purple100,
- 6, purple100a,
- 9, tie,
- 10, novotes,
- ];
- var ColorRed3 =
- ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Red3]
- ],
- 0, red0,
- 0.0001, red10,
- 0.1*colorscale, red20,
- 0.2*colorscale, red30,
- 0.3*colorscale, red40,
- 0.4*colorscale, red50,
- 0.5*colorscale, red60,
- 0.6*colorscale, red70,
- 0.7*colorscale, red80,
- 0.8*colorscale, red90,
- 0.9*colorscale, red100,
- 1*colorscale, red100a
- ]
- var ColorBlue3 = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Blue3]
- ],
- 0, blue0,
- 0.001, blue10,
- 0.1*colorscale,blue20,
- 0.2*colorscale, blue30,
- 0.3*colorscale, blue40,
- 0.4*colorscale, blue50,
- 0.5*colorscale, blue60,
- 0.6*colorscale, blue70,
- 0.7*colorscale, blue80,
- 0.8*colorscale, blue90,
- 0.9*colorscale, blue100,
- 1*colorscale, blue100a
- ]
- var ColorGreen3 = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Green3]
- ],
- 0, green0,
- 0.001, green10,
- 0.1*colorscale, green20,
- 0.2*colorscale, green30,
- 0.3*colorscale, green40,
- 0.4*colorscale, green50,
- 0.5*colorscale, green60,
- 0.6*colorscale, green70,
- 0.7*colorscale, green80,
- 0.8*colorscale, green90,
- 0.9*colorscale, green100,
- 1*colorscale, green100a
- ]
- var ColorYellow3 = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Yellow3]
- ],
- 0, yellow0,
- 0.001, yellow10,
- 0.1*colorscale, yellow20,
- 0.2*colorscale, yellow30,
- 0.3*colorscale, yellow40,
- 0.4*colorscale, yellow50,
- 0.5*colorscale, yellow60,
- 0.6*colorscale, yellow70,
- 0.7*colorscale, yellow80,
- 0.8*colorscale, yellow90,
- 0.9*colorscale, yellow100,
- 1.0*colorscale, yellow100a,
- ]
- var ColorOrange3 = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Orange3]
- ],
- 0, orange0,
- 0.001, orange10,
- 0.1*colorscale, orange20,
- 0.2*colorscale, orange30,
- 0.3*colorscale, orange40,
- 0.4*colorscale, orange50,
- 0.5*colorscale, orange60,
- 0.6*colorscale, orange70,
- 0.7*colorscale, orange80,
- 0.8*colorscale, orange90,
- 0.9*colorscale, orange100,
- 1.0*colorscale, orange100a,
- ]
- var ColorPurple3 = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Purple3]
- ],
- 0,purple0,
- 0.001,purple10,
- 0.1*colorscale, purple20,
- 0.2*colorscale, purple30,
- 0.3*colorscale, purple40,
- 0.4*colorscale, purple50,
- 0.5*colorscale, purple60,
- 0.6*colorscale, purple70,
- 0.7*colorscale, purple80,
- 0.8*colorscale, purple90,
- 0.9*colorscale, purple100,
- 1.0*colorscale, purple100a
- ]
- var Multi4 = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Wincode4]
- ],
- 0, red0,
- 0.0000001, red10,
- 0.1*colorscale, red20,
- 0.2*colorscale, red30,
- 0.3*colorscale, red40,
- 0.4*colorscale, red50,
- 0.5*colorscale, red60,
- 0.6*colorscale, red70,
- 0.7*colorscale, red80,
- 0.8*colorscale, red90,
- 0.9*colorscale, red100,
- 1, red100a,
- 1.00000001, green10,
- 1+(.1*colorscale), green20,
- 1+(.2*colorscale), green30,
- 1+(.3*colorscale), green40,
- 1+(.4*colorscale), green50,
- 1+(.5*colorscale), green60,
- 1+(.6*colorscale), green70,
- 1+(.7*colorscale), green80,
- 1+(.8*colorscale), green90,
- 1+(.9*colorscale), green100,
- 2, green100a,
- 2.00000001, blue10,
- 2+(.1*colorscale), blue20,
- 2+(.2*colorscale), blue30,
- 2+(.3*colorscale), blue40,
- 2+(.4*colorscale), blue50,
- 2+(.5*colorscale), blue60,
- 2+(.6*colorscale), blue70,
- 2+(.7*colorscale), blue80,
- 2+(.8*colorscale), blue90,
- 2+(.9*colorscale), blue100,
- 3, blue100a,
- 3.00000001, yellow10,
- 3+(.1*colorscale), yellow20,
- 3+(.2*colorscale), yellow30,
- 3+(.3*colorscale), yellow40,
- 3+(.4*colorscale), yellow50,
- 3+(.5*colorscale), yellow60,
- 3+(.6*colorscale), yellow70,
- 3+(.7*colorscale), yellow80,
- 3+(.8*colorscale), yellow90,
- 3+(.9*colorscale), yellow100,
- 4, yellow100a,
- 4.00000001, orange10,
- 4+(.1*colorscale), orange20,
- 4+(.2*colorscale), orange30,
- 4+(.3*colorscale), orange40,
- 4+(.4*colorscale), orange50,
- 4+(.5*colorscale), orange60,
- 4+(.6*colorscale), orange70,
- 4+(.7*colorscale), orange80,
- 4+(.8*colorscale), orange90,
- 4+(.9*colorscale), orange100,
- 5, orange100a,
- 5.00000001, purple10,
- 5+(.1*colorscale), purple20,
- 5+(.2*colorscale), purple30,
- 5+(.3*colorscale), purple40,
- 5+(.4*colorscale), purple50,
- 5+(.5*colorscale), purple60,
- 5+(.6*colorscale), purple70,
- 5+(.7*colorscale), purple80,
- 5+(.8*colorscale), purple90,
- 5+(.9*colorscale), purple100,
- 6, purple100a,
- 9, tie,
- 10, novotes,
- ];
- var ColorRed4 =
- ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Red4]
- ],
- 0, red0,
- 0.0001, red10,
- 0.1*colorscale, red20,
- 0.2*colorscale, red30,
- 0.3*colorscale, red40,
- 0.4*colorscale, red50,
- 0.5*colorscale, red60,
- 0.6*colorscale, red70,
- 0.7*colorscale, red80,
- 0.8*colorscale, red90,
- 0.9*colorscale, red100,
- 1*colorscale, red100a
- ]
- var ColorBlue4 = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Blue4]
- ],
- 0, blue0,
- 0.001, blue10,
- 0.1*colorscale,blue20,
- 0.2*colorscale, blue30,
- 0.3*colorscale, blue40,
- 0.4*colorscale, blue50,
- 0.5*colorscale, blue60,
- 0.6*colorscale, blue70,
- 0.7*colorscale, blue80,
- 0.8*colorscale, blue90,
- 0.9*colorscale, blue100,
- 1*colorscale, blue100a
- ]
- var ColorGreen4 = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Green4]
- ],
- 0, green0,
- 0.001, green10,
- 0.1*colorscale, green20,
- 0.2*colorscale, green30,
- 0.3*colorscale, green40,
- 0.4*colorscale, green50,
- 0.5*colorscale, green60,
- 0.6*colorscale, green70,
- 0.7*colorscale, green80,
- 0.8*colorscale, green90,
- 0.9*colorscale, green100,
- 1*colorscale, green100a
- ]
- var ColorYellow4 = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Yellow4]
- ],
- 0, yellow0,
- 0.001, yellow10,
- 0.1*colorscale, yellow20,
- 0.2*colorscale, yellow30,
- 0.3*colorscale, yellow40,
- 0.4*colorscale, yellow50,
- 0.5*colorscale, yellow60,
- 0.6*colorscale, yellow70,
- 0.7*colorscale, yellow80,
- 0.8*colorscale, yellow90,
- 0.9*colorscale, yellow100,
- 1.0*colorscale, yellow100a,
- ]
- var ColorOrange4 = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Orange4]
- ],
- 0, orange0,
- 0.001, orange10,
- 0.1*colorscale, orange20,
- 0.2*colorscale, orange30,
- 0.3*colorscale, orange40,
- 0.4*colorscale, orange50,
- 0.5*colorscale, orange60,
- 0.6*colorscale, orange70,
- 0.7*colorscale, orange80,
- 0.8*colorscale, orange90,
- 0.9*colorscale, orange100,
- 1.0*colorscale, orange100a,
- ]
- var ColorPurple4 = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Purple4]
- ],
- 0,purple0,
- 0.001,purple10,
- 0.1*colorscale, purple20,
- 0.2*colorscale, purple30,
- 0.3*colorscale, purple40,
- 0.4*colorscale, purple50,
- 0.5*colorscale, purple60,
- 0.6*colorscale, purple70,
- 0.7*colorscale, purple80,
- 0.8*colorscale, purple90,
- 0.9*colorscale, purple100,
- 1.0*colorscale, purple100a
- ]
- //choose default color scheme
- var color = Multi
- var color2 = Multi2;
- var color3 = Multi3;
- var color4 = Multi4;
- legendtitle.innerHTML = '<h2>Idaho 2018 Gov GE Results by Precinct/County</h2><h3>Hover over a Precinct!</h3>'
- //load map
- map.on('load',
- function () {map.addLayer({
- id: layer1,
- type: 'fill',
- source: {
- type: 'vector',
- // Mapbox tileset Map ID - must edit
- url: 'mapbox://cinyc.6nkivfkc'
- },
- 'source-layer': layer1,
- paint: {
- 'fill-color': Multi4,
- 'fill-opacity': 0.75,
- 'fill-outline-color': '#f0f0f0'},
- layout: {'visibility': 'visible'}
- })
- map.addLayer({
- id: layer2,
- type: 'fill',
- source: {
- type: 'vector',
- // Mapbox tileset Map ID - must edit
- url: 'mapbox://cinyc.c3ok1cpz'
- },
- 'source-layer': layer2,
- paint: {
- 'fill-color': Multi2,
- 'fill-opacity': 0.75,
- 'fill-outline-color': '#f0f0f0'},
- layout: {'visibility': 'none'}
- })
- var clickedLayer = layerCounty
- var clickedLayer2014 = 'Gov'
- var clickedLayer2018 = 'Gov'
- var clickedLayer1 = 'W'
- var clickedLayer2 = 'W'
- var clickedLayer3 = 'W'
- var clickedLayer4 = 'W'
- var x1status = 0
- var x2status = 0
- var x3status = 0
- var x4status = 0
- var x2014status = 0
- var x2018status = 0
- var x1 = document.getElementById("menu1")
- var x2 = document.getElementById("menu2")
- var x3 = document.getElementById("menu3")
- var x4 = document.getElementById("menu4")
- var x2014 = document.getElementById("menu2014")
- var x2018 = document.getElementById("menu2018")
- //default map - must edit
- {var color4 = Multi4;
- // reset color slider & text
- cssliderValue.textContent = '10 points';
- csslider.value = '100'
- colorpct510.textContent = '10'
- colorpct520.textContent = '20'
- colorpct530.textContent = '30'
- colorpct540.textContent = '40'
- colorpct550.textContent = '50'
- colorpct560.textContent = '60'
- colorpct570.textContent = '70'
- colorpct580.textContent = '80'
- colorpct590.textContent = '90'
- colorpct600.textContent = '99'
- colorpct600a.textContent = '100'
- //set labels - must edit - copy and paste from default
- candidateC.textContent = RedCandidate4
- colorvalue200b.style = background + red0
- colorvalue210.style = background + red10
- colorvalue220.style = background + red20
- colorvalue230.style = background + red30
- colorvalue240.style = background + red40
- colorvalue250.style = background + red50
- colorvalue260.style = background + red60
- colorvalue270.style = background + red70
- colorvalue280.style = background + red80
- colorvalue290.style = background + red90
- colorvalue300.style = background + red100
- colorvalue300a.style = background + red100a
- candidateD.textContent = BlueCandidate4
- colorvalue300b.style = background + blue0
- colorvalue310.style = background + blue10
- colorvalue320.style = background + blue20
- colorvalue330.style = background + blue30
- colorvalue340.style = background + blue40
- colorvalue350.style = background + blue50
- colorvalue360.style = background + blue60
- colorvalue370.style = background + blue70
- colorvalue380.style = background + blue80
- colorvalue390.style = background + blue90
- colorvalue400.style = background + blue100
- colorvalue400a.style = background + blue100a
- candidateE.textContent = YellowCandidate4
- colorvalue400b.style = background + yellow0
- colorvalue410.style = background + yellow10
- colorvalue420.style = background + yellow20
- colorvalue430.style = background + yellow30
- colorvalue440.style = background + yellow40
- colorvalue450.style = background + yellow50
- colorvalue460.style = background + yellow60
- colorvalue470.style = background + yellow70
- colorvalue480.style = background + yellow80
- colorvalue490.style = background + yellow90
- colorvalue500.style = background + yellow100
- colorvalue500a.style = background + yellow100a
- candidateF.textContent = OrangeCandidate4
- colorvalue500b.style = background + orange0
- colorvalue510.style = background + orange10
- colorvalue520.style = background + orange20
- colorvalue530.style = background + orange30
- colorvalue540.style = background + orange40
- colorvalue550.style = background + orange50
- colorvalue560.style = background + orange60
- colorvalue570.style = background + orange70
- colorvalue580.style = background + orange80
- colorvalue590.style = background + orange90
- colorvalue600.style = background + orange100
- colorvalue600a.style = background + orange100a
- map.setPaintProperty(layer1, 'fill-color', color4)
- csslider.addEventListener('input', function(y) {
- // Adjust the colorscale. layer here is arbitrary - this could
- // be another layer name found in your style or a custom layer
- // added on the fly using `addSource`.
- var colorscale = (y.target.value) / 100;
- // Value indicator
- cssliderValue.textContent = y.target.value/10 + ' points';
- if(y.target.value>10) {colorpct510.textContent = Math.round(10*y.target.value/100)} else colorpct510.textContent = Math.round(10*y.target.value/10)/10
- if(y.target.value>10) {colorpct520.textContent = Math.round(20*y.target.value/100)} else colorpct520.textContent = Math.round(20*y.target.value/10)/10
- if(y.target.value>10) {colorpct530.textContent = Math.round(30*y.target.value/100)} else colorpct530.textContent = Math.round(30*y.target.value/10)/10
- if(y.target.value>10) {colorpct540.textContent = Math.round(40*y.target.value/100)} else colorpct540.textContent = Math.round(40*y.target.value/10)/10
- if(y.target.value>10) {colorpct550.textContent = Math.round(50*y.target.value/100)} else colorpct550.textContent = Math.round(50*y.target.value/10)/10
- if(y.target.value>10) {colorpct560.textContent = Math.round(60*y.target.value/100)} else colorpct560.textContent = Math.round(60*y.target.value/10)/10
- if(y.target.value>10) {colorpct570.textContent = Math.round(70*y.target.value/100)} else colorpct570.textContent = Math.round(70*y.target.value/10)/10
- if(y.target.value>10) {colorpct580.textContent = Math.round(80*y.target.value/100)} else colorpct580.textContent = Math.round(80*y.target.value/10)/10
- if(y.target.value>10) {colorpct590.textContent = Math.round(90*y.target.value/100)} else colorpct590.textContent = Math.round(90*y.target.value/10)/10
- if(y.target.value>10) {colorpct600.textContent = Math.round(100*y.target.value/100)} else colorpct600.textContent = Math.round(100*y.target.value/10)/10
- if(y.target.value>10) {colorpct600a.textContent = Math.round(100*y.target.value/100) + '%+'} else colorpct600a.textContent = Math.round(100*y.target.value/10)/10 + '%+'
- var color4 = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Wincode4]
- ],
- 0, red0,
- 0.0000001, red10,
- 0.1*colorscale, red20,
- 0.2*colorscale, red30,
- 0.3*colorscale, red40,
- 0.4*colorscale, red50,
- 0.5*colorscale, red60,
- 0.6*colorscale, red70,
- 0.7*colorscale, red80,
- 0.8*colorscale, red90,
- 0.9*colorscale, red100,
- 1, red100a,
- 1.00000001, green10,
- 1+(.1*colorscale), green20,
- 1+(.2*colorscale), green30,
- 1+(.3*colorscale), green40,
- 1+(.4*colorscale), green50,
- 1+(.5*colorscale), green60,
- 1+(.6*colorscale), green70,
- 1+(.7*colorscale), green80,
- 1+(.8*colorscale), green90,
- 1+(.9*colorscale), green100,
- 2, green100a,
- 2.00000001, blue10,
- 2+(.1*colorscale), blue20,
- 2+(.2*colorscale), blue30,
- 2+(.3*colorscale), blue40,
- 2+(.4*colorscale), blue50,
- 2+(.5*colorscale), blue60,
- 2+(.6*colorscale), blue70,
- 2+(.7*colorscale), blue80,
- 2+(.8*colorscale), blue90,
- 2+(.9*colorscale), blue100,
- 3, blue100a,
- 3.00000001, yellow10,
- 3+(.1*colorscale), yellow20,
- 3+(.2*colorscale), yellow30,
- 3+(.3*colorscale), yellow40,
- 3+(.4*colorscale), yellow50,
- 3+(.5*colorscale), yellow60,
- 3+(.6*colorscale), yellow70,
- 3+(.7*colorscale), yellow80,
- 3+(.8*colorscale), yellow90,
- 3+(.9*colorscale), yellow100,
- 4, yellow100a,
- 4.00000001, orange10,
- 4+(.1*colorscale), orange20,
- 4+(.2*colorscale), orange30,
- 4+(.3*colorscale), orange40,
- 4+(.4*colorscale), orange50,
- 4+(.5*colorscale), orange60,
- 4+(.6*colorscale), orange70,
- 4+(.7*colorscale), orange80,
- 4+(.8*colorscale), orange90,
- 4+(.9*colorscale), orange100,
- 5, orange100a,
- 5.00000001, purple10,
- 5+(.1*colorscale), purple20,
- 5+(.2*colorscale), purple30,
- 5+(.3*colorscale), purple40,
- 5+(.4*colorscale), purple50,
- 5+(.5*colorscale), purple60,
- 5+(.6*colorscale), purple70,
- 5+(.7*colorscale), purple80,
- 5+(.8*colorscale), purple90,
- 5+(.9*colorscale), purple100,
- 6, purple100a,
- 9, tie,
- 10, novotes,
- ];
- map.setPaintProperty(layer1, 'fill-color', color4);
- ;})
- //Multi mouseover
- map.on('mousemove', function(e) {
- var states = map.queryRenderedFeatures(e.point, {
- layer: [layer1]
- });
- // Must edit states.properties for candidate
- if (states.length > 0) {
- legendtitle.innerHTML = '<h2>Idaho 2018 Governor GE Results by Precinct/County</h2><h3>'+ states[0].properties.G_NAME18 + '</h3><h3>' +states[0].properties.G_County + ' County</h3>' + '</h3><h3>Total Votes: ' + Math.round(states[0].properties.G_Gtotal) + '</h3>'
- cpct.innerHTML = ' <strong>' + Math.round(states[0].properties.G_PCTLittl*10000)/100 + '%</strong>'
- dpct.innerHTML = ' <strong>' + Math.round(states[0].properties.G_PCTJorda*10000)/100 + '%</strong>'
- epct.innerHTML = ' <strong>' + Math.round(states[0].properties.G_PCTBoek*10000)/100 + '%</strong>'
- fpct.innerHTML = ' <strong>' + Math.round(states[0].properties.G_PCTBayes*10000)/100 + '%</strong>'
- } else {
- legendtitle.innerHTML = '<h2>Idaho 2018 Governor GE Results by Precinct/County</h2><h3>Statewide Overall Result</h3><h3>Statewide Votes: ' + StatewideVotes + '</h3>'
- cpct.innerHTML = ' <strong>' + RedStatewidePCT4 + '%</strong>'
- dpct.innerHTML = ' <strong>' + BlueStatewidePCT4 + '%</strong>'
- epct.innerHTML = ' <strong>' + YellowStatewidePCT4 + '%</strong>'
- fpct.innerHTML = ' <strong>' + OrangeStatewidePCT4 + '%</strong>'
- }
- });
- }
- var toggleableLayerIds = ['Layer',layer1,layer2,layerCounty];
- toggleableLayerNames = ['Layer','2018','2014','County'];
- for (var i = 0; i < toggleableLayerIds.length; i++) {
- var id = toggleableLayerIds[i];
- var Names = toggleableLayerNames[i];
- var link = document.createElement('a');
- link.href = '#';
- link.className = 'active';
- if(id === 'Layer') {link.className = 'header'}
- if(id === layer2) {link.className = ''}
- if(id === layerCounty) {link.className = 'county'}
- link.shortcut = id;
- link.textContent = Names
- link.onclick = function (e) {
- var clickedLayer = this.shortcut;
- var clickedName = this.textContent
- if(clickedLayer === layer1) {var current = document.getElementsByClassName('active');
- if(current[0].className === 'active') {current[0].className = current[0].className.replace("active","")}; this.className = 'active'; }
- if(clickedLayer === layer2) {var current = document.getElementsByClassName('active');
- if(current[0].className === 'active') {current[0].className = current[0].className.replace("active","")}; this.className = 'active'; }
- e.preventDefault();
- e.stopPropagation();
- if (clickedLayer === "Layer"){}
- if (clickedLayer === layerCounty)
- {var visibility = map.getLayoutProperty(layerCounty, 'visibility');
- if (visibility === 'visible') {
- map.setLayoutProperty(layerCounty, 'visibility', 'none');
- this.className = '';
- } else {
- this.className = 'county';
- map.setLayoutProperty(layerCounty, 'visibility', 'visible')}
- }
- else if (clickedLayer === layer1)
- {map.setLayoutProperty(layer1,'visibility','visible')
- map.setLayoutProperty(layer2,'visibility','none')
- x2018status ++;
- x1.style.display = 'none'
- x2.style.display = 'none'
- x3.style.display = 'none'
- x4.style.display = 'none'
- x2014.style.display = 'none'
- x2018.style.display = 'block'
- var toggleableLayerIds2018 = ['2018','Gov','SPI'];
- toggleableLayerNames2018 = ['2018','Gov','SPI'];
- for (var i = 0; i < toggleableLayerIds2018.length; i++) {
- var id2018 = toggleableLayerIds2018[i];
- var Names2018 = toggleableLayerNames2018[i];
- var link2018 = document.createElement('a');
- link2018.href = '#';
- link2018.className = 'active2018';
- if(id2018 === '2018') {link2018.className = 'header'}
- if(id2018 === 'SPI') {link2018.className = ''}
- link2018.shortcut = id2018;
- link2018.textContent = Names2018
- link2018.onclick = function (f) {
- var clickedLayer2018 = this.shortcut;
- var clickedName2018 = this.textContent
- var current2018 = document.getElementsByClassName('active2018');
- if(current2018[0].className === 'active2018') {current2018[0].className = current2018[0].className.replace("active2018","")}
- this.className = 'active2018';
- f.preventDefault();
- f.stopPropagation();
- {
- if (clickedLayer2018 === "2018"){}
- else if (clickedLayer2018 === 'Gov')
- {x4status ++;
- x1.style.display = 'none'
- x2.style.display = 'none'
- x3.style.display = 'none'
- x4.style.display = 'block'
- var toggleableLayerIds4 = ['Gov','W','R','B','Y','O'];
- toggleableLayerNames4 = ['Gov','Winner','Little (R)','Jordan (D)','Boeck (L)','Bayes (C)'];
- for (var i = 0; i < toggleableLayerIds4.length; i++) {
- var id4 = toggleableLayerIds4[i];
- var Names4 = toggleableLayerNames4[i];
- var link4 = document.createElement('a');
- link4.href = '#';
- link4.className = 'none';
- if(id4 === "Gov") {link4.className = 'header'}
- if(id4 === "W") {link4.className = 'active4'}
- link4.shortcut = id4
- link4.textContent = Names4
- link4.onclick = function (g) {
- var clickedLayer4 = this.shortcut;
- var clickedName4 = this.textContent;
- var current4 = document.getElementsByClassName('active4');
- if(current4[0].className === 'active4') {current4[0].className = current4[0].className.replace("active4","")}
- this.className = 'active4';
- // build a reference to the existing node to be replaced
- g.preventDefault();
- g.stopPropagation();
- if (clickedLayer4 === '2018'){}
- if (clickedLayer4 === 'W')
- {var color4 = Multi4;
- // reset color slider & text
- cssliderValue.textContent = '10 points';
- csslider.value = '100'
- colorpct510.textContent = '10'
- colorpct520.textContent = '20'
- colorpct530.textContent = '30'
- colorpct540.textContent = '40'
- colorpct550.textContent = '50'
- colorpct560.textContent = '60'
- colorpct570.textContent = '70'
- colorpct580.textContent = '80'
- colorpct590.textContent = '90'
- colorpct600.textContent = '99'
- colorpct600a.textContent = '100'
- //set labels - must edit - copy and paste from default
- candidateC.textContent = RedCandidate4
- colorvalue200b.style = background + red0
- colorvalue210.style = background + red10
- colorvalue220.style = background + red20
- colorvalue230.style = background + red30
- colorvalue240.style = background + red40
- colorvalue250.style = background + red50
- colorvalue260.style = background + red60
- colorvalue270.style = background + red70
- colorvalue280.style = background + red80
- colorvalue290.style = background + red90
- colorvalue300.style = background + red100
- colorvalue300a.style = background + red100a
- candidateD.textContent = BlueCandidate4
- colorvalue300b.style = background + blue0
- colorvalue310.style = background + blue10
- colorvalue320.style = background + blue20
- colorvalue330.style = background + blue30
- colorvalue340.style = background + blue40
- colorvalue350.style = background + blue50
- colorvalue360.style = background + blue60
- colorvalue370.style = background + blue70
- colorvalue380.style = background + blue80
- colorvalue390.style = background + blue90
- colorvalue400.style = background + blue100
- colorvalue400a.style = background + blue100a
- candidateE.textContent = YellowCandidate4
- colorvalue400b.style = background + yellow0
- colorvalue410.style = background + yellow10
- colorvalue420.style = background + yellow20
- colorvalue430.style = background + yellow30
- colorvalue440.style = background + yellow40
- colorvalue450.style = background + yellow50
- colorvalue460.style = background + yellow60
- colorvalue470.style = background + yellow70
- colorvalue480.style = background + yellow80
- colorvalue490.style = background + yellow90
- colorvalue500.style = background + yellow100
- colorvalue500a.style = background + yellow100a
- candidateF.textContent = OrangeCandidate4
- colorvalue500b.style = background + orange0
- colorvalue510.style = background + orange10
- colorvalue520.style = background + orange20
- colorvalue530.style = background + orange30
- colorvalue540.style = background + orange40
- colorvalue550.style = background + orange50
- colorvalue560.style = background + orange60
- colorvalue570.style = background + orange70
- colorvalue580.style = background + orange80
- colorvalue590.style = background + orange90
- colorvalue600.style = background + orange100
- colorvalue600a.style = background + orange100a
- map.setPaintProperty(layer1, 'fill-color', color4)
- csslider.addEventListener('input', function(y) {
- // Adjust the colorscale. layer here is arbitrary - this could
- // be another layer name found in your style or a custom layer
- // added on the fly using `addSource`.
- var colorscale = (y.target.value) / 100;
- // Value indicator
- cssliderValue.textContent = y.target.value/10 + ' points';
- if(y.target.value>10) {colorpct510.textContent = Math.round(10*y.target.value/100)} else colorpct510.textContent = Math.round(10*y.target.value/10)/10
- if(y.target.value>10) {colorpct520.textContent = Math.round(20*y.target.value/100)} else colorpct520.textContent = Math.round(20*y.target.value/10)/10
- if(y.target.value>10) {colorpct530.textContent = Math.round(30*y.target.value/100)} else colorpct530.textContent = Math.round(30*y.target.value/10)/10
- if(y.target.value>10) {colorpct540.textContent = Math.round(40*y.target.value/100)} else colorpct540.textContent = Math.round(40*y.target.value/10)/10
- if(y.target.value>10) {colorpct550.textContent = Math.round(50*y.target.value/100)} else colorpct550.textContent = Math.round(50*y.target.value/10)/10
- if(y.target.value>10) {colorpct560.textContent = Math.round(60*y.target.value/100)} else colorpct560.textContent = Math.round(60*y.target.value/10)/10
- if(y.target.value>10) {colorpct570.textContent = Math.round(70*y.target.value/100)} else colorpct570.textContent = Math.round(70*y.target.value/10)/10
- if(y.target.value>10) {colorpct580.textContent = Math.round(80*y.target.value/100)} else colorpct580.textContent = Math.round(80*y.target.value/10)/10
- if(y.target.value>10) {colorpct590.textContent = Math.round(90*y.target.value/100)} else colorpct590.textContent = Math.round(90*y.target.value/10)/10
- if(y.target.value>10) {colorpct600.textContent = Math.round(100*y.target.value/100)} else colorpct600.textContent = Math.round(100*y.target.value/10)/10
- if(y.target.value>10) {colorpct600a.textContent = Math.round(100*y.target.value/100) + '%+'} else colorpct600a.textContent = Math.round(100*y.target.value/10)/10 + '%+'
- var color4 = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Wincode4]
- ],
- 0, red0,
- 0.0000001, red10,
- 0.1*colorscale, red20,
- 0.2*colorscale, red30,
- 0.3*colorscale, red40,
- 0.4*colorscale, red50,
- 0.5*colorscale, red60,
- 0.6*colorscale, red70,
- 0.7*colorscale, red80,
- 0.8*colorscale, red90,
- 0.9*colorscale, red100,
- 1, red100a,
- 1.00000001, green10,
- 1+(.1*colorscale), green20,
- 1+(.2*colorscale), green30,
- 1+(.3*colorscale), green40,
- 1+(.4*colorscale), green50,
- 1+(.5*colorscale), green60,
- 1+(.6*colorscale), green70,
- 1+(.7*colorscale), green80,
- 1+(.8*colorscale), green90,
- 1+(.9*colorscale), green100,
- 2, green100a,
- 2.00000001, blue10,
- 2+(.1*colorscale), blue20,
- 2+(.2*colorscale), blue30,
- 2+(.3*colorscale), blue40,
- 2+(.4*colorscale), blue50,
- 2+(.5*colorscale), blue60,
- 2+(.6*colorscale), blue70,
- 2+(.7*colorscale), blue80,
- 2+(.8*colorscale), blue90,
- 2+(.9*colorscale), blue100,
- 3, blue100a,
- 3.00000001, yellow10,
- 3+(.1*colorscale), yellow20,
- 3+(.2*colorscale), yellow30,
- 3+(.3*colorscale), yellow40,
- 3+(.4*colorscale), yellow50,
- 3+(.5*colorscale), yellow60,
- 3+(.6*colorscale), yellow70,
- 3+(.7*colorscale), yellow80,
- 3+(.8*colorscale), yellow90,
- 3+(.9*colorscale), yellow100,
- 4, yellow100a,
- 4.00000001, orange10,
- 4+(.1*colorscale), orange20,
- 4+(.2*colorscale), orange30,
- 4+(.3*colorscale), orange40,
- 4+(.4*colorscale), orange50,
- 4+(.5*colorscale), orange60,
- 4+(.6*colorscale), orange70,
- 4+(.7*colorscale), orange80,
- 4+(.8*colorscale), orange90,
- 4+(.9*colorscale), orange100,
- 5, orange100a,
- 5.00000001, purple10,
- 5+(.1*colorscale), purple20,
- 5+(.2*colorscale), purple30,
- 5+(.3*colorscale), purple40,
- 5+(.4*colorscale), purple50,
- 5+(.5*colorscale), purple60,
- 5+(.6*colorscale), purple70,
- 5+(.7*colorscale), purple80,
- 5+(.8*colorscale), purple90,
- 5+(.9*colorscale), purple100,
- 6, purple100a,
- 9, tie,
- 10, novotes,
- ];
- map.setPaintProperty(layer1, 'fill-color', color4);
- ;})
- //Multi mouseover
- map.on('mousemove', function(e) {
- var states = map.queryRenderedFeatures(e.point, {
- layer: [layer1]
- });
- // Must edit states.properties for candidate
- if (states.length > 0) {
- legendtitle.innerHTML = '<h2>Idaho 2018 Governor GE Results by Precinct/County</h2><h3>'+ states[0].properties.G_NAME18 + '</h3><h3>' +states[0].properties.G_County + ' County</h3>' + '</h3><h3>Total Votes: ' + Math.round(states[0].properties.G_Gtotal) + '</h3>'
- cpct.innerHTML = ' <strong>' + Math.round(states[0].properties.G_PCTLittl*10000)/100 + '%</strong>'
- dpct.innerHTML = ' <strong>' + Math.round(states[0].properties.G_PCTJorda*10000)/100 + '%</strong>'
- epct.innerHTML = ' <strong>' + Math.round(states[0].properties.G_PCTBoek*10000)/100 + '%</strong>'
- fpct.innerHTML = ' <strong>' + Math.round(states[0].properties.G_PCTBayes*10000)/100 + '%</strong>'
- } else {
- legendtitle.innerHTML = '<h2>Idaho 2018 Governor GE Results by Precinct/County</h2><h3>Statewide Overall Result</h3><h3>Statewide Votes: ' + StatewideVotes + '</h3>'
- cpct.innerHTML = ' <strong>' + RedStatewidePCT4 + '%</strong>'
- dpct.innerHTML = ' <strong>' + BlueStatewidePCT4 + '%</strong>'
- epct.innerHTML = ' <strong>' + YellowStatewidePCT4 + '%</strong>'
- fpct.innerHTML = ' <strong>' + OrangeStatewidePCT4 + '%</strong>'
- }
- });
- }
- else if (clickedLayer4 === 'R')
- {
- var color4 = ColorRed4
- // reset color slider & text
- cssliderValue.textContent = '10 points';
- csslider.value = '100'
- colorpct510.textContent = '10'
- colorpct520.textContent = '20'
- colorpct530.textContent = '30'
- colorpct540.textContent = '40'
- colorpct550.textContent = '50'
- colorpct560.textContent = '60'
- colorpct570.textContent = '70'
- colorpct580.textContent = '80'
- colorpct590.textContent = '90'
- colorpct600.textContent = '99'
- colorpct600a.textContent = '100'
- //set labels
- candidateC.textContent = ''
- colorvalue200b.style = background + white
- colorvalue210.style = background + white
- colorvalue220.style = background + white
- colorvalue230.style = background + white
- colorvalue240.style = background + white
- colorvalue250.style = background + white
- colorvalue260.style = background + white
- colorvalue270.style = background + white
- colorvalue280.style = background + white
- colorvalue290.style = background + white
- colorvalue300.style = background + white
- colorvalue300a.style = background + white
- candidateD.textContent = ''
- colorvalue300b.style = background + white
- colorvalue310.style = background + white
- colorvalue320.style = background + white
- colorvalue330.style = background + white
- colorvalue340.style = background + white
- colorvalue350.style = background + white
- colorvalue360.style = background + white
- colorvalue370.style = background + white
- colorvalue380.style = background + white
- colorvalue390.style = background + white
- colorvalue400.style = background + white
- colorvalue400a.style = background + white
- candidateE.textContent = ''
- colorvalue400b.style = background + white
- colorvalue410.style = background + white
- colorvalue420.style = background + white
- colorvalue430.style = background + white
- colorvalue440.style = background + white
- colorvalue450.style = background + white
- colorvalue460.style = background + white
- colorvalue470.style = background + white
- colorvalue480.style = background + white
- colorvalue490.style = background + white
- colorvalue500.style = background + white
- colorvalue500a.style = background + white
- candidateF.textContent = RedCandidate4
- colorvalue500b.style = background + red0
- colorvalue510.style = background + red10
- colorvalue520.style = background + red20
- colorvalue530.style = background + red30
- colorvalue540.style = background + red40
- colorvalue550.style = background + red50
- colorvalue560.style = background + red60
- colorvalue570.style = background + red70
- colorvalue580.style = background + red80
- colorvalue590.style = background + red90
- colorvalue600.style = background + red100
- colorvalue600a.style = background + red100a
- map.setPaintProperty(layer1, 'fill-color', color4)
- csslider.addEventListener('input', function(y) {
- // Adjust the colorscale. layer here is arbitrary - this could
- // be another layer name found in your style or a custom layer
- // added on the fly using `addSource`.
- var colorscale = (y.target.value) / 100;
- // Value indicator
- cssliderValue.textContent = y.target.value/10 + ' points';
- if(y.target.value>10) {colorpct510.textContent = Math.round(10*y.target.value/100)} else colorpct510.textContent = Math.round(10*y.target.value/10)/10
- if(y.target.value>10) {colorpct520.textContent = Math.round(20*y.target.value/100)} else colorpct520.textContent = Math.round(20*y.target.value/10)/10
- if(y.target.value>10) {colorpct530.textContent = Math.round(30*y.target.value/100)} else colorpct530.textContent = Math.round(30*y.target.value/10)/10
- if(y.target.value>10) {colorpct540.textContent = Math.round(40*y.target.value/100)} else colorpct540.textContent = Math.round(40*y.target.value/10)/10
- if(y.target.value>10) {colorpct550.textContent = Math.round(50*y.target.value/100)} else colorpct550.textContent = Math.round(50*y.target.value/10)/10
- if(y.target.value>10) {colorpct560.textContent = Math.round(60*y.target.value/100)} else colorpct560.textContent = Math.round(60*y.target.value/10)/10
- if(y.target.value>10) {colorpct570.textContent = Math.round(70*y.target.value/100)} else colorpct570.textContent = Math.round(70*y.target.value/10)/10
- if(y.target.value>10) {colorpct580.textContent = Math.round(80*y.target.value/100)} else colorpct580.textContent = Math.round(80*y.target.value/10)/10
- if(y.target.value>10) {colorpct590.textContent = Math.round(90*y.target.value/100)} else colorpct590.textContent = Math.round(90*y.target.value/10)/10
- if(y.target.value>10) {colorpct600.textContent = Math.round(100*y.target.value/100)} else colorpct600.textContent = Math.round(100*y.target.value/10)/10
- if(y.target.value>10) {colorpct600a.textContent = Math.round(100*y.target.value/100) + '%+'} else colorpct600a.textContent = Math.round(100*y.target.value/10)/10 + '%+'
- var color4 = ["interpolate",
- ["exponential", 0.1*colorscale],
- ["number",
- ["get", Red4]
- ],
- 0, red0,
- 0.0001, red10,
- 0.1*colorscale, red20,
- 0.2*colorscale, red30,
- 0.3*colorscale, red40,
- 0.4*colorscale, red50,
- 0.5*colorscale, red60,
- 0.6*colorscale, red70,
- 0.7*colorscale, red80,
- 0.8*colorscale, red90,
- 0.9*colorscale, red100,
- 1*colorscale, red100a
- ]
- map.setPaintProperty(layer1, 'fill-color', color4)
- });
- //red mouseover
- map.on('mousemove', function(h) {
- var states = map.queryRenderedFeatures(h.point, {
- layer: [layer1]
- });
- // Must edit states.properties for candidate
- if (states.length > 0) {
- legendtitle.innerHTML = '<h2>Idaho 2018 Governor GE Results by Precinct/County</h2><h3>'+ states[0].properties.G_NAME18 + '</h3><h3>' +states[0].properties.G_County + ' County</h3>><h3>Total Votes: ' + Math.round(states[0].properties.G_Gtotal) + '</h3>'
- cpct.innerHTML = ' '
- dpct.innerHTML = ' '
- epct.innerHTML = ' '
- fpct.innerHTML = ' <strong>' + Math.round(states[0].properties.G_PCTLittl*10000)/100 + '% </strong>'
- } else {
- legendtitle.innerHTML = '<h2>Idaho 2018 Governor GE Results by Precinct/County</h2><h3>Statewide Overall Result</h3><h3>Statewide Votes: ' + StatewideVotes + '</h3>'
- cpct.innerHTML = ' '
- dpct.innerHTML = ' '
- epct.innerHTML = ' '
- fpct.innerHTML = ' <strong>' + RedStatewidePCT4 + '%</strong>'
- }
- });
- }
- else if (clickedLayer4 === 'B')
- {var color4 = ColorBlue4
- // reset color slider & text
- cssliderValue.textContent = '10 points';
- csslider.value = '100'
- colorpct510.textContent = '10'
- colorpct520.textContent = '20'
- colorpct530.textContent = '30'
- colorpct540.textContent = '40'
- colorpct550.textContent = '50'
- colorpct560.textContent = '60'
- colorpct570.textContent = '70'
- colorpct580.textContent = '80'
- colorpct590.textContent = '90'
- colorpct600.textContent = '99'
- colorpct600a.textContent = '100'
- //set labels
- candidateC.textContent = ''
- colorvalue200b.style = background + white
- colorvalue210.style = background + white
- colorvalue220.style = background + white
- colorvalue230.style = background + white
- colorvalue240.style = background + white
- colorvalue250.style = background + white
- colorvalue260.style = background + white
- colorvalue270.style = background + white
- colorvalue280.style = background + white
- colorvalue290.style = background + white
- colorvalue300.style = background + white
- colorvalue300a.style = background + white
- candidateD.textContent = ''
- colorvalue300b.style = background + white
- colorvalue310.style = background + white
- colorvalue320.style = background + white
- colorvalue330.style = background + white
- colorvalue340.style = background + white
- colorvalue350.style = background + white
- colorvalue360.style = background + white
- colorvalue370.style = background + white
- colorvalue380.style = background + white
- colorvalue390.style = background + white
- colorvalue400.style = background + white
- colorvalue400a.style = background + white
- candidateE.textContent = ''
- colorvalue400b.style = background + white
- colorvalue410.style = background + white
- colorvalue420.style = background + white
- colorvalue430.style = background + white
- colorvalue440.style = background + white
- colorvalue450.style = background + white
- colorvalue460.style = background + white
- colorvalue470.style = background + white
- colorvalue480.style = background + white
- colorvalue490.style = background + white
- colorvalue500.style = background + white
- colorvalue500a.style = background + white
- candidateF.textContent = BlueCandidate4
- colorvalue500b.style = background + blue0
- colorvalue510.style = background + blue10
- colorvalue520.style = background + blue20
- colorvalue530.style = background + blue30
- colorvalue540.style = background + blue40
- colorvalue550.style = background + blue50
- colorvalue560.style = background + blue60
- colorvalue570.style = background + blue70
- colorvalue580.style = background + blue80
- colorvalue590.style = background + blue90
- colorvalue600.style = background + blue100
- colorvalue600a.style = background + blue100a
- map.setPaintProperty(layer1, 'fill-color', color4)
- csslider.addEventListener('input', function(y) {
- // Adjust the colorscale. layer here is arbitrary - this could
- // be another layer name found in your style or a custom layer
- // added on the fly using `addSource`.
- var colorscale = (y.target.value) / 100;
- // Value indicator
- cssliderValue.textContent = y.target.value/10 + ' points';
- if(y.target.value>10) {colorpct510.textContent = Math.round(10*y.target.value/100)} else colorpct510.textContent = Math.round(10*y.target.value/10)/10
- if(y.target.value>10) {colorpct520.textContent = Math.round(20*y.target.value/100)} else colorpct520.textContent = Math.round(20*y.target.value/10)/10
- if(y.target.value>10) {colorpct530.textContent = Math.round(30*y.target.value/100)} else colorpct530.textContent = Math.round(30*y.target.value/10)/10
- if(y.target.value>10) {colorpct540.textContent = Math.round(40*y.target.value/100)} else colorpct540.textContent = Math.round(40*y.target.value/10)/10
- if(y.target.value>10) {colorpct550.textContent = Math.round(50*y.target.value/100)} else colorpct550.textContent = Math.round(50*y.target.value/10)/10
- if(y.target.value>10) {colorpct560.textContent = Math.round(60*y.target.value/100)} else colorpct560.textContent = Math.round(60*y.target.value/10)/10
- if(y.target.value>10) {colorpct570.textContent = Math.round(70*y.target.value/100)} else colorpct570.textContent = Math.round(70*y.target.value/10)/10
- if(y.target.value>10) {colorpct580.textContent = Math.round(80*y.target.value/100)} else colorpct580.textContent = Math.round(80*y.target.value/10)/10
- if(y.target.value>10) {colorpct590.textContent = Math.round(90*y.target.value/100)} else colorpct590.textContent = Math.round(90*y.target.value/10)/10
- if(y.target.value>10) {colorpct600.textContent = Math.round(100*y.target.value/100)} else colorpct600.textContent = Math.round(100*y.target.value/10)/10
- if(y.target.value>10) {colorpct600a.textContent = Math.round(100*y.target.value/100) + '%+'} else colorpct600a.textContent = Math.round(100*y.target.value/10)/10 + '%+'
- var color4 = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Blue4]
- ],
- 0, blue0,
- 0.0001, blue10,
- 0.1*colorscale, blue20,
- 0.2*colorscale, blue30,
- 0.3*colorscale, blue40,
- 0.4*colorscale, blue50,
- 0.5*colorscale, blue60,
- 0.6*colorscale, blue70,
- 0.7*colorscale, blue80,
- 0.8*colorscale, blue90,
- 0.9*colorscale, blue100,
- 1*colorscale, blue100a,
- ]
- map.setPaintProperty(layer1, 'fill-color', color4)
- });
- //Blue Mouseover
- map.on('mousemove', function(i) {
- var states = map.queryRenderedFeatures(i.point, {
- layer: [layer1]
- });
- // Must edit states.properties for candidate
- if (states.length > 0) {
- legendtitle.innerHTML = '<h2>Idaho 2018 Governor GE Results by Precinct/County</h2><h3>'+ states[0].properties.G_NAME18 + '</h3><h3>' +states[0].properties.G_County + ' County</h3>Total Votes: ' + Math.round(states[0].properties.G_Gtotal) + '</h3>'
- cpct.innerHTML = ' '
- dpct.innerHTML = ' '
- epct.innerHTML = ' '
- fpct.innerHTML = ' <strong>' + Math.round(states[0].properties.G_PCTJorda*10000)/100 + '%</strong>';
- } else {
- legendtitle.innerHTML = '<h2>Idaho 2018 Governor GE Results by Precinct/County</h2><h3>Statewide Overall Result</h3><h3>Statewide Votes: ' + StatewideVotes + '</h3>'
- cpct.innerHTML = ' '
- dpct.innerHTML = ' '
- epct.innerHTML = ' '
- fpct.innerHTML = ' <strong>' + BlueStatewidePCT4 + '%</strong>'
- }
- });
- }
- else if (clickedLayer4 ==='Y')
- {var color4 = ColorYellow4
- // reset color slider
- cssliderValue.textContent = '10 points';
- csslider.value = '100'
- colorpct510.textContent = '10'
- colorpct520.textContent = '20'
- colorpct530.textContent = '30'
- colorpct540.textContent = '40'
- colorpct550.textContent = '50'
- colorpct560.textContent = '60'
- colorpct570.textContentx = '70'
- colorpct580.textContent = '80'
- colorpct590.textContent = '90'
- colorpct600.textContent = '99'
- colorpct600a.textContent = '100'
- //set labels
- candidateC.textContent = ''
- colorvalue200b.style = background + white
- colorvalue210.style = background + white
- colorvalue220.style = background + white
- colorvalue230.style = background + white
- colorvalue240.style = background + white
- colorvalue250.style = background + white
- colorvalue260.style = background + white
- colorvalue270.style = background + white
- colorvalue280.style = background + white
- colorvalue290.style = background + white
- colorvalue300.style = background + white
- colorvalue300a.style = background + white
- candidateD.textContent = ''
- colorvalue300b.style = background + white
- colorvalue310.style = background + white
- colorvalue320.style = background + white
- colorvalue330.style = background + white
- colorvalue340.style = background + white
- colorvalue350.style = background + white
- colorvalue360.style = background + white
- colorvalue370.style = background + white
- colorvalue380.style = background + white
- colorvalue390.style = background + white
- colorvalue400.style = background + white
- colorvalue400a.style = background + white
- candidateE.textContent = ''
- colorvalue400b.style = background + white
- colorvalue410.style = background + white
- colorvalue420.style = background + white
- colorvalue430.style = background + white
- colorvalue440.style = background + white
- colorvalue450.style = background + white
- colorvalue460.style = background + white
- colorvalue470.style = background + white
- colorvalue480.style = background + white
- colorvalue490.style = background + white
- colorvalue500.style = background + white
- colorvalue500a.style = background + white
- candidateF.textContent = YellowCandidate4
- colorvalue500b.style = background + yellow0
- colorvalue510.style = background + yellow10
- colorvalue520.style = background + yellow20
- colorvalue530.style = background + yellow30
- colorvalue540.style = background + yellow40
- colorvalue550.style = background + yellow50
- colorvalue560.style = background + yellow60
- colorvalue570.style = background + yellow70
- colorvalue580.style = background + yellow80
- colorvalue590.style = background + yellow90
- colorvalue600.style = background + yellow100
- colorvalue600a.style = background + yellow100a
- map.setPaintProperty(layer1, 'fill-color', color4)
- csslider.addEventListener('input', function(y) {
- // Adjust the colorscale. layer here is arbitrary - this could
- // be another layer name found in your style or a custom layer
- // added on the fly using `addSource`.
- var colorscale = (y.target.value) / 100;
- // Value indicator
- cssliderValue.textContent = y.target.value/10 + ' points';
- cssliderValue.textContent = y.target.value/10 + ' points';
- if(y.target.value>10) {colorpct510.textContent = Math.round(10*y.target.value/100)} else colorpct510.textContent = Math.round(10*y.target.value/10)/10
- if(y.target.value>10) {colorpct520.textContent = Math.round(20*y.target.value/100)} else colorpct520.textContent = Math.round(20*y.target.value/10)/10
- if(y.target.value>10) {colorpct530.textContent = Math.round(30*y.target.value/100)} else colorpct530.textContent = Math.round(30*y.target.value/10)/10
- if(y.target.value>10) {colorpct540.textContent = Math.round(40*y.target.value/100)} else colorpct540.textContent = Math.round(40*y.target.value/10)/10
- if(y.target.value>10) {colorpct550.textContent = Math.round(50*y.target.value/100)} else colorpct550.textContent = Math.round(50*y.target.value/10)/10
- if(y.target.value>10) {colorpct560.textContent = Math.round(60*y.target.value/100)} else colorpct560.textContent = Math.round(60*y.target.value/10)/10
- if(y.target.value>10) {colorpct570.textContent = Math.round(70*y.target.value/100)} else colorpct570.textContent = Math.round(70*y.target.value/10)/10
- if(y.target.value>10) {colorpct580.textContent = Math.round(80*y.target.value/100)} else colorpct580.textContent = Math.round(80*y.target.value/10)/10
- if(y.target.value>10) {colorpct590.textContent = Math.round(90*y.target.value/100)} else colorpct590.textContent = Math.round(90*y.target.value/10)/10
- if(y.target.value>10) {colorpct600.textContent = Math.round(100*y.target.value/100)} else colorpct600.textContent = Math.round(100*y.target.value/10)/10
- if(y.target.value>10) {colorpct600a.textContent = Math.round(100*y.target.value/100) + '%+'} else colorpct600a.textContent = Math.round(100*y.target.value/10)/10 + '%+'
- var color4 = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Yellow4]
- ],
- 0, yellow0,
- 0.0001, yellow10,
- 0.1*colorscale, yellow20,
- 0.2*colorscale, yellow30,
- 0.3*colorscale, yellow40,
- 0.4*colorscale, yellow50,
- 0.5*colorscale, yellow60,
- 0.6*colorscale, yellow70,
- 0.7*colorscale, yellow80,
- 0.8*colorscale, yellow90,
- 0.9*colorscale, yellow100,
- 1.0*colorscale, yellow100a
- ]
- map.setPaintProperty(layer1, 'fill-color', color4)
- });
- //yellow mouseover
- map.on('mousemove', function(k) {
- var states = map.queryRenderedFeatures(k.point, {
- layer: [layer1]
- });
- // Must edit states.properties for candidate
- if (states.length > 0) {
- legendtitle.innerHTML = '<h2>Idaho 2018 Governor GE Results by Precinct/County</h2><h3>'+ states[0].properties.G_NAME18 + '</h3><h3>' +states[0].properties.G_County + ' County</h3>Total Votes: ' + Math.round(states[0].properties.G_Gtotal) + '</h3>'
- cpct.innerHTML = ' '
- dpct.innerHTML = ' '
- epct.innerHTML = ' '
- fpct.innerHTML = ' <strong>' + Math.round(states[0].properties.G_PCTBoek*10000)/100 + '%</strong>'
- } else {
- legendtitle.innerHTML = '<h2>Idaho 2018 Governor GE Results by Precinct/County</h2><h3>Statewide Overall Result</h3><h3>Statewide Votes: ' + StatewideVotes + '</h3>'
- cpct.innerHTML = ' '
- dpct.innerHTML = ' '
- epct.innerHTML = ' '
- fpct.innerHTML = ' <strong>' + YellowStatewidePCT4 + '%</strong>'
- }
- });
- }
- else if (clickedLayer4 === 'O')
- {var color4 = ColorOrange4;
- // reset color slider
- cssliderValue.textContent = '10 points';
- csslider.value = '100'
- colorpct510.textContent = '10'
- colorpct520.textContent = '20'
- colorpct530.textContent = '30'
- colorpct540.textContent = '40'
- colorpct550.textContent = '50'
- colorpct560.textContent = '60'
- colorpct570.textContent = '70'
- colorpct580.textContent = '80'
- colorpct590.textContent = '90'
- colorpct600.textContent = '99'
- colorpct600a.textContent = '100'
- //set labels
- candidateC.textContent = ''
- colorvalue200b.style = background + white
- colorvalue210.style = background + white
- colorvalue220.style = background + white
- colorvalue230.style = background + white
- colorvalue240.style = background + white
- colorvalue250.style = background + white
- colorvalue260.style = background + white
- colorvalue270.style = background + white
- colorvalue280.style = background + white
- colorvalue290.style = background + white
- colorvalue300.style = background + white
- colorvalue300a.style = background + white
- candidateD.textContent = ''
- colorvalue300b.style = background + white
- colorvalue310.style = background + white
- colorvalue320.style = background + white
- colorvalue330.style = background + white
- colorvalue340.style = background + white
- colorvalue350.style = background + white
- colorvalue360.style = background + white
- colorvalue370.style = background + white
- colorvalue380.style = background + white
- colorvalue390.style = background + white
- colorvalue400.style = background + white
- colorvalue400a.style = background + white
- candidateE.textContent = ''
- colorvalue400b.style = background + white
- colorvalue410.style = background + white
- colorvalue420.style = background + white
- colorvalue430.style = background + white
- colorvalue440.style = background + white
- colorvalue450.style = background + white
- colorvalue460.style = background + white
- colorvalue470.style = background + white
- colorvalue480.style = background + white
- colorvalue490.style = background + white
- colorvalue500.style = background + white
- colorvalue500a.style = background + white
- candidateF.textContent = OrangeCandidate4
- colorvalue500b.style = background + orange0
- colorvalue510.style = background + orange10
- colorvalue520.style = background + orange20
- colorvalue530.style = background + orange30
- colorvalue540.style = background + orange40
- colorvalue550.style = background + orange50
- colorvalue560.style = background + orange60
- colorvalue570.style = background + orange70
- colorvalue580.style = background + orange80
- colorvalue590.style = background + orange90
- colorvalue600.style = background + orange100
- colorvalue600a.style = background + orange100a
- map.setPaintProperty(layer1, 'fill-color', color4)
- csslider.addEventListener('input', function(y) {
- // Adjust the colorscale. layer here is arbitrary - this could
- // be another layer name found in your style or a custom layer
- // added on the fly using `addSource`.
- var colorscale = (y.target.value) / 100;
- // Value indicator
- cssliderValue.textContent = y.target.value/10 + ' points';
- cssliderValue.textContent = y.target.value/10 + ' points';
- if(y.
- target.value>10) {colorpct510.textContent = Math.round(10*y.target.value/100)} else colorpct510.textContent = Math.round(10*y.target.value/10)/10
- if(y.target.value>10) {colorpct520.textContent = Math.round(20*y.target.value/100)} else colorpct520.textContent = Math.round(20*y.target.value/10)/10
- if(y.target.value>10) {colorpct530.textContent = Math.round(30*y.target.value/100)} else colorpct530.textContent = Math.round(30*y.target.value/10)/10
- if(y.target.value>10) {colorpct540.textContent = Math.round(40*y.target.value/100)} else colorpct540.textContent = Math.round(40*y.target.value/10)/10
- if(y.target.value>10) {colorpct550.textContent = Math.round(50*y.target.value/100)} else colorpct550.textContent = Math.round(50*y.target.value/10)/10
- if(y.target.value>10) {colorpct560.textContent = Math.round(60*y.target.value/100)} else colorpct560.textContent = Math.round(60*y.target.value/10)/10
- if(y.target.value>10) {colorpct570.textContent = Math.round(70*y.target.value/100)} else colorpct570.textContent = Math.round(70*y.target.value/10)/10
- if(y.target.value>10) {colorpct580.textContent = Math.round(80*y.target.value/100)} else colorpct580.textContent = Math.round(80*y.target.value/10)/10
- if(y.target.value>10) {colorpct590.textContent = Math.round(90*y.target.value/100)} else colorpct590.textContent = Math.round(90*y.target.value/10)/10
- if(y.target.value>10) {colorpct600.textContent = Math.round(100*y.target.value/100)} else colorpct600.textContent = Math.round(100*y.target.value/10)/10
- if(y.target.value>10) {colorpct600a.textContent = Math.round(100*y.target.value/100) + '%+'} else colorpct600a.textContent = Math.round(100*y.target.value/10)/10 + '%+'
- var color4 = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Orange4]
- ],
- 0, orange0,
- 0.0001, orange10,
- 0.1*colorscale, orange20,
- 0.2*colorscale, orange30,
- 0.3*colorscale, orange40,
- 0.4*colorscale, orange50,
- 0.5*colorscale, orange60,
- 0.6*colorscale, orange70,
- 0.7*colorscale, orange80,
- 0.8*colorscale, orange90,
- 0.9*colorscale, orange100,
- 1.0*colorscale, orange100a
- ]
- map.setPaintProperty(layer1, 'fill-color', color4)
- });
- //orange mouseover
- map.on('mousemove', function(l) {
- var states = map.queryRenderedFeatures(l.point, {
- layer: [layer1]
- });
- // Must edit states.properties for candidate
- if (states.length > 0) {
- legendtitle.innerHTML = '<h2>Idaho 2018 Governor GE Results by Precinct/County</h2><h3>'+ states[0].properties.G_NAME18 + '</h3><h3>' +states[0].properties.G_County + ' County</h3>Total Votes: ' + Math.round(states[0].properties.G_Gtotal) + '</h3>'
- cpct.innerHTML = ' '
- dpct.innerHTML = ' '
- epct.innerHTML = ' '
- fpct.innerHTML = ' <strong>' + Math.round(states[0].properties.G_PCTBayes*10000)/100 + '%</strong>'
- } else {
- legendtitle.innerHTML = '<h2>Idaho 2018 Governor GE Results by Precinct/County</h2><h3>Statewide Overall Result</h3><h3>Statewide Votes: ' + StatewideVotes + '</h3>'
- cpct.innerHTML = ' '
- dpct.innerHTML = ' '
- epct.innerHTML = ' '
- fpct.innerHTML = ' <strong>' + OrangeStatewidePCT4 + '%</strong>'
- }
- });
- }
- }
- var layers4 = document.getElementById('menu4');
- if (x4status > 1){} else {layers4.appendChild(link4)}
- }
- }
- else if (clickedLayer2018 === 'SPI') {x1status ++;
- x1.style.display = 'block';
- x2.style.display = 'none';
- x3.style.display = 'none';
- x4.style.display = 'none';
- var toggleableLayerIds1 = ['SPI','W','R','B'];
- toggleableLayerNames1 = ['SPI','Winner','Ybarra (R)','Wilson (D)'];
- for (var i = 0; i < toggleableLayerIds1.length; i++) {
- var id1 = toggleableLayerIds1[i];
- var Names1 = toggleableLayerNames1[i];
- var link1 = document.createElement('a');
- link1.href = '#';
- link1.className = 'none';
- if(id1 === "SPI") {link1.className = 'header'}
- if(id1 === 'W') {link1.className = 'active1'}
- link1.shortcut = id1;
- link1.textContent = Names1
- link1.onclick = function (g) {
- var clickedLayer1 = this.shortcut;
- var clickedName1 = this.textContent
- var current1 = document.getElementsByClassName('active1');
- if(current1[0].className === 'active1') {current1[0].className = current1[0].className.replace("active1","")}
- this.className = "active1";
- g.preventDefault();
- g.stopPropagation();
- if (clickedLayer1 === 'SPI'){}
- if (clickedLayer1 === "W"){
- var color = Multi
- // reset color slider & text
- cssliderValue.textContent = '10 points';
- csslider.value = '100'
- colorpct510.textContent = '10'
- colorpct520.textContent = '20'
- colorpct530.textContent = '30'
- colorpct540.textContent = '40'
- colorpct550.textContent = '50'
- colorpct560.textContent = '60'
- colorpct570.textContent = '70'
- colorpct580.textContent = '80'
- colorpct590.textContent = '90'
- colorpct600.textContent = '99'
- colorpct600a.textContent = '100'
- //set labels - must edit - copy and paste from default
- candidateC.textContent = ''
- colorvalue200b.style = background + white
- colorvalue210.style = background + white
- colorvalue220.style = background + white
- colorvalue230.style = background + white
- colorvalue240.style = background + white
- colorvalue250.style = background + white
- colorvalue260.style = background + white
- colorvalue270.style = background + white
- colorvalue280.style = background + white
- colorvalue290.style = background + white
- colorvalue300.style = background + white
- colorvalue300a.style = background + white
- candidateD.textContent = ''
- colorvalue300b.style = background + white
- colorvalue310.style = background + white
- colorvalue320.style = background + white
- colorvalue330.style = background + white
- colorvalue340.style = background + white
- colorvalue350.style = background + white
- colorvalue360.style = background + white
- colorvalue370.style = background + white
- colorvalue380.style = background + white
- colorvalue390.style = background + white
- colorvalue400.style = background + white
- colorvalue400a.style = background + white
- candidateE.textContent = RedCandidate
- colorvalue400b.style = background + red0
- colorvalue410.style = background + red10
- colorvalue420.style = background + red20
- colorvalue430.style = background + red30
- colorvalue440.style = background + red40
- colorvalue450.style = background + red50
- colorvalue460.style = background + red60
- colorvalue470.style = background + red70
- colorvalue480.style = background + red80
- colorvalue490.style = background + red90
- colorvalue500.style = background + red100
- colorvalue500a.style = background + red100a
- candidateF.textContent = BlueCandidate
- colorvalue500b.style = background + blue0
- colorvalue510.style = background + blue10
- colorvalue520.style = background + blue20
- colorvalue530.style = background + blue30
- colorvalue540.style = background + blue40
- colorvalue550.style = background + blue50
- colorvalue560.style = background + blue60
- colorvalue570.style = background + blue70
- colorvalue580.style = background + blue80
- colorvalue590.style = background + blue90
- colorvalue600.style = background + blue100
- colorvalue600a.style = background + blue100a
- map.setPaintProperty(layer1, 'fill-color', color);
- csslider.addEventListener('input', function(y) {
- // Adjust the colorscale. layer here is arbitrary - this could
- // be another layer name found in your style or a custom layer
- // added on the fly using `addSource`.
- var colorscale = (y.target.value) / 100;
- // Value indicator
- cssliderValue.textContent = y.target.value/10 + ' points';
- if(y.target.value>10) {colorpct510.textContent = Math.round(10*y.target.value/100)} else colorpct510.textContent = Math.round(10*y.target.value/10)/10
- if(y.target.value>10) {colorpct520.textContent = Math.round(20*y.target.value/100)} else colorpct520.textContent = Math.round(20*y.target.value/10)/10
- if(y.target.value>10) {colorpct530.textContent = Math.round(30*y.target.value/100)} else colorpct530.textContent = Math.round(30*y.target.value/10)/10
- if(y.target.value>10) {colorpct540.textContent = Math.round(40*y.target.value/100)} else colorpct540.textContent = Math.round(40*y.target.value/10)/10
- if(y.target.value>10) {colorpct550.textContent = Math.round(50*y.target.value/100)} else colorpct550.textContent = Math.round(50*y.target.value/10)/10
- if(y.target.value>10) {colorpct560.textContent = Math.round(60*y.target.value/100)} else colorpct560.textContent = Math.round(60*y.target.value/10)/10
- if(y.target.value>10) {colorpct570.textContent = Math.round(70*y.target.value/100)} else colorpct570.textContent = Math.round(70*y.target.value/10)/10
- if(y.target.value>10) {colorpct580.textContent = Math.round(80*y.target.value/100)} else colorpct580.textContent = Math.round(80*y.target.value/10)/10
- if(y.target.value>10) {colorpct590.textContent = Math.round(90*y.target.value/100)} else colorpct590.textContent = Math.round(90*y.target.value/10)/10
- if(y.target.value>10) {colorpct600.textContent = Math.round(100*y.target.value/100)} else colorpct600.textContent = Math.round(100*y.target.value/10)/10
- if(y.target.value>10) {colorpct600a.textContent = Math.round(100*y.target.value/100) + '%+'} else colorpct600a.textContent = Math.round(100*y.target.value/10)/10 + '%+'
- var color = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Wincode]
- ],
- 0, red0,
- 0.0000001, red10,
- 0.1*colorscale, red20,
- 0.2*colorscale, red30,
- 0.3*colorscale, red40,
- 0.4*colorscale, red50,
- 0.5*colorscale, red60,
- 0.6*colorscale, red70,
- 0.7*colorscale, red80,
- 0.8*colorscale, red90,
- 0.9*colorscale, red100,
- 1, red100a,
- 1.00000001, green10,
- 1+(.1*colorscale), green20,
- 1+(.2*colorscale), green30,
- 1+(.3*colorscale), green40,
- 1+(.4*colorscale), green50,
- 1+(.5*colorscale), green60,
- 1+(.6*colorscale), green70,
- 1+(.7*colorscale), green80,
- 1+(.8*colorscale), green90,
- 1+(.9*colorscale), green100,
- 2, green100a,
- 2.00000001, blue10,
- 2+(.1*colorscale), blue20,
- 2+(.2*colorscale), blue30,
- 2+(.3*colorscale), blue40,
- 2+(.4*colorscale), blue50,
- 2+(.5*colorscale), blue60,
- 2+(.6*colorscale), blue70,
- 2+(.7*colorscale), blue80,
- 2+(.8*colorscale), blue90,
- 2+(.9*colorscale), blue100,
- 3, blue100a,
- 3.00000001, yellow10,
- 3+(.1*colorscale), yellow20,
- 3+(.2*colorscale), yellow30,
- 3+(.3*colorscale), yellow40,
- 3+(.4*colorscale), yellow50,
- 3+(.5*colorscale), yellow60,
- 3+(.6*colorscale), yellow70,
- 3+(.7*colorscale), yellow80,
- 3+(.8*colorscale), yellow90,
- 3+(.9*colorscale), yellow100,
- 4, yellow100a,
- 4.00000001, orange10,
- 4+(.1*colorscale), orange20,
- 4+(.2*colorscale), orange30,
- 4+(.3*colorscale), orange40,
- 4+(.4*colorscale), orange50,
- 4+(.5*colorscale), orange60,
- 4+(.6*colorscale), orange70,
- 4+(.7*colorscale), orange80,
- 4+(.8*colorscale), orange90,
- 4+(.9*colorscale), orange100,
- 5, orange100a,
- 5.00000001, purple10,
- 5+(.1*colorscale), purple20,
- 5+(.2*colorscale), purple30,
- 5+(.3*colorscale), purple40,
- 5+(.4*colorscale), purple50,
- 5+(.5*colorscale), purple60,
- 5+(.6*colorscale), purple70,
- 5+(.7*colorscale), purple80,
- 5+(.8*colorscale), purple90,
- 5+(.9*colorscale), purple100,
- 6, purple100a,
- 9, tie,
- 10, novotes,
- ]
- map.setPaintProperty(layer1, 'fill-color', color);
- });
- //Multi mouseover
- map.on('mousemove', function(e) {
- var states = map.queryRenderedFeatures(e.point, {
- layer: [layer1]
- });
- // Must edit states.properties for candidate
- if (states.length > 0) {
- legendtitle.innerHTML = '<h2>Idaho 2018 SPI GE Results by Precinct/County</h2><h3>'+ states[0].properties.G_NAME18 + '</h3><h3>' +states[0].properties.G_County + ' County</h3>' + '</h3><h3>Total Votes: ' + Math.round(states[0].properties.G_SPETotal) + '</h3>'
- epct.innerHTML = ' <strong>' + Math.round(states[0].properties.G_PCTYbarr*10000)/100 + '%</strong>'
- fpct.innerHTML = ' <strong>' + Math.round(states[0].properties.G_PCTWilso*10000)/100 + '%</strong>'
- } else {
- legendtitle.innerHTML = '<h2>Idaho 2018 SPI GE Results by Precinct/County</h2><h3>Statewide Overall Result</h3><h3>Statewide Votes: ' + StatewideVotes + '</h3>'
- epct.innerHTML = ' <strong>' + RedStatewidePCT + '%</strong>'
- fpct.innerHTML = ' <strong>' + BlueStatewidePCT + '%</strong>'
- }
- });
- }
- else if (clickedLayer1 === "R"){
- var color = ColorRed;
- // reset color slider & text
- cssliderValue.textContent = '10 points';
- csslider.value = '100'
- colorpct510.textContent = '10'
- colorpct520.textContent = '20'
- colorpct530.textContent = '30'
- colorpct540.textContent = '40'
- colorpct550.textContent = '50'
- colorpct560.textContent = '60'
- colorpct570.textContent = '70'
- colorpct580.textContent = '80'
- colorpct590.textContent = '90'
- colorpct600.textContent = '99'
- colorpct600a.textContent = '100'
- //set labels
- candidateC.textContent = ''
- colorvalue200b.style = background + white
- colorvalue210.style = background + white
- colorvalue220.style = background + white
- colorvalue230.style = background + white
- colorvalue240.style = background + white
- colorvalue250.style = background + white
- colorvalue260.style = background + white
- colorvalue270.style = background + white
- colorvalue280.style = background + white
- colorvalue290.style = background + white
- colorvalue300.style = background + white
- colorvalue300a.style = background + white
- candidateD.textContent = ''
- colorvalue300b.style = background + white
- colorvalue310.style = background + white
- colorvalue320.style = background + white
- colorvalue330.style = background + white
- colorvalue340.style = background + white
- colorvalue350.style = background + white
- colorvalue360.style = background + white
- colorvalue370.style = background + white
- colorvalue380.style = background + white
- colorvalue390.style = background + white
- colorvalue400.style = background + white
- colorvalue400a.style = background + white
- candidateE.textContent = ''
- colorvalue400b.style = background + white
- colorvalue410.style = background + white
- colorvalue420.style = background + white
- colorvalue430.style = background + white
- colorvalue440.style = background + white
- colorvalue450.style = background + white
- colorvalue460.style = background + white
- colorvalue470.style = background + white
- colorvalue480.style = background + white
- colorvalue490.style = background + white
- colorvalue500.style = background + white
- colorvalue500a.style = background + white
- candidateF.textContent = RedCandidate
- colorvalue500b.style = background + red0
- colorvalue510.style = background + red10
- colorvalue520.style = background + red20
- colorvalue530.style = background + red30
- colorvalue540.style = background + red40
- colorvalue550.style = background + red50
- colorvalue560.style = background + red60
- colorvalue570.style = background + red70
- colorvalue580.style = background + red80
- colorvalue590.style = background + red90
- colorvalue600.style = background + red100
- colorvalue600a.style = background + red100a
- map.setPaintProperty(layer1, 'fill-color', color)
- csslider.addEventListener('input', function(y) {
- // Adjust the colorscale. layer here is arbitrary - this could
- // be another layer name found in your style or a custom layer
- // added on the fly using `addSource`.
- var colorscale = (y.target.value) / 100;
- // Value indicator
- cssliderValue.textContent = y.target.value/10 + ' points';
- if(y.target.value>10) {colorpct510.textContent = Math.round(10*y.target.value/100)} else colorpct510.textContent = Math.round(10*y.target.value/10)/10
- if(y.target.value>10) {colorpct520.textContent = Math.round(20*y.target.value/100)} else colorpct520.textContent = Math.round(20*y.target.value/10)/10
- if(y.target.value>10) {colorpct530.textContent = Math.round(30*y.target.value/100)} else colorpct530.textContent = Math.round(30*y.target.value/10)/10
- if(y.target.value>10) {colorpct540.textContent = Math.round(40*y.target.value/100)} else colorpct540.textContent = Math.round(40*y.target.value/10)/10
- if(y.target.value>10) {colorpct550.textContent = Math.round(50*y.target.value/100)} else colorpct550.textContent = Math.round(50*y.target.value/10)/10
- if(y.target.value>10) {colorpct560.textContent = Math.round(60*y.target.value/100)} else colorpct560.textContent = Math.round(60*y.target.value/10)/10
- if(y.target.value>10) {colorpct570.textContent = Math.round(70*y.target.value/100)} else colorpct570.textContent = Math.round(70*y.target.value/10)/10
- if(y.target.value>10) {colorpct580.textContent = Math.round(80*y.target.value/100)} else colorpct580.textContent = Math.round(80*y.target.value/10)/10
- if(y.target.value>10) {colorpct590.textContent = Math.round(90*y.target.value/100)} else colorpct590.textContent = Math.round(90*y.target.value/10)/10
- if(y.target.value>10) {colorpct600.textContent = Math.round(100*y.target.value/100)} else colorpct600.textContent = Math.round(100*y.target.value/10)/10
- if(y.target.value>10) {colorpct600a.textContent = Math.round(100*y.target.value/100) + '%+'} else colorpct600a.textContent = Math.round(100*y.target.value/10)/10 + '%+'
- var color = ["interpolate",
- ["exponential", 0.1*colorscale],
- ["number",
- ["get", Red]
- ],
- 0, red0,
- 0.0001, red10,
- 0.1*colorscale, red20,
- 0.2*colorscale, red30,
- 0.3*colorscale, red40,
- 0.4*colorscale, red50,
- 0.5*colorscale, red60,
- 0.6*colorscale, red70,
- 0.7*colorscale, red80,
- 0.8*colorscale, red90,
- 0.9*colorscale, red100,
- 1*colorscale, red100a
- ]
- map.setPaintProperty(layer1, 'fill-color', color)
- });
- //red mouseover
- map.on('mousemove', function(h) {
- var states = map.queryRenderedFeatures(h.point, {
- layer: [layer1]
- });
- // Must edit states.properties for candidate
- if (states.length > 0) {
- legendtitle.innerHTML = '<h2>Idaho 2018 SPI GE Results by Precinct/County</h2><h3>'+ states[0].properties.G_NAME18 + '</h3><h3>' +states[0].properties.G_County + ' County</h3><h3>Total Votes: ' + Math.round(states[0].properties.G_SPETotal) + '</h3>'
- epct.innerHTML = ' '
- fpct.innerHTML = ' <strong>' + Math.round(states[0].properties.G_PCTYbarr*10000)/100 + '% </strong>'
- } else {
- legendtitle.innerHTML = '<h2>Idaho 2018 SPI GE Results by Precinct/County</h2><h3>Statewide Overall Result</h3><h3>Statewide Votes: ' + StatewideVotes + '</h3>'
- epct.innerHTML = ' '
- fpct.innerHTML = ' <strong>' + RedStatewidePCT + '%</strong>'
- }
- });
- }
- else if (clickedLayer1 === "B"){
- var color = ColorBlue;
- // reset color slider & text
- cssliderValue.textContent = '10 points';
- csslider.value = '100'
- colorpct510.textContent = '10'
- colorpct520.textContent = '20'
- colorpct530.textContent = '30'
- colorpct540.textContent = '40'
- colorpct550.textContent = '50'
- colorpct560.textContent = '60'
- colorpct570.textContent = '70'
- colorpct580.textContent = '80'
- colorpct590.textContent = '90'
- colorpct600.textContent = '99'
- colorpct600a.textContent = '100'
- //set labels
- candidateC.textContent = ''
- colorvalue200b.style = background + white
- colorvalue210.style = background + white
- colorvalue220.style = background + white
- colorvalue230.style = background + white
- colorvalue240.style = background + white
- colorvalue250.style = background + white
- colorvalue260.style = background + white
- colorvalue270.style = background + white
- colorvalue280.style = background + white
- colorvalue290.style = background + white
- colorvalue300.style = background + white
- colorvalue300a.style = background + white
- candidateD.textContent = ''
- colorvalue300b.style = background + white
- colorvalue310.style = background + white
- colorvalue320.style = background + white
- colorvalue330.style = background + white
- colorvalue340.style = background + white
- colorvalue350.style = background + white
- colorvalue360.style = background + white
- colorvalue370.style = background + white
- colorvalue380.style = background + white
- colorvalue390.style = background + white
- colorvalue400.style = background + white
- colorvalue400a.style = background + white
- candidateE.textContent = ''
- colorvalue400b.style = background + white
- colorvalue410.style = background + white
- colorvalue420.style = background + white
- colorvalue430.style = background + white
- colorvalue440.style = background + white
- colorvalue450.style = background + white
- colorvalue460.style = background + white
- colorvalue470.style = background + white
- colorvalue480.style = background + white
- colorvalue490.style = background + white
- colorvalue500.style = background + white
- colorvalue500a.style = background + white
- candidateF.textContent = BlueCandidate
- colorvalue500b.style = background + blue0
- colorvalue510.style = background + blue10
- colorvalue520.style = background + blue20
- colorvalue530.style = background + blue30
- colorvalue540.style = background + blue40
- colorvalue550.style = background + blue50
- colorvalue560.style = background + blue60
- colorvalue570.style = background + blue70
- colorvalue580.style = background + blue80
- colorvalue590.style = background + blue90
- colorvalue600.style = background + blue100
- colorvalue600a.style = background + blue100a
- map.setPaintProperty(layer1, 'fill-color', color)
- csslider.addEventListener('input', function(y) {
- // Adjust the colorscale. layer here is arbitrary - this could
- // be another layer name found in your style or a custom layer
- // added on the fly using `addSource`.
- var colorscale = (y.target.value) / 100;
- // Value indicator
- cssliderValue.textContent = y.target.value/10 + ' points';
- if(y.target.value>10) {colorpct510.textContent = Math.round(10*y.target.value/100)} else colorpct510.textContent = Math.round(10*y.target.value/10)/10
- if(y.target.value>10) {colorpct520.textContent = Math.round(20*y.target.value/100)} else colorpct520.textContent = Math.round(20*y.target.value/10)/10
- if(y.target.value>10) {colorpct530.textContent = Math.round(30*y.target.value/100)} else colorpct530.textContent = Math.round(30*y.target.value/10)/10
- if(y.target.value>10) {colorpct540.textContent = Math.round(40*y.target.value/100)} else colorpct540.textContent = Math.round(40*y.target.value/10)/10
- if(y.target.value>10) {colorpct550.textContent = Math.round(50*y.target.value/100)} else colorpct550.textContent = Math.round(50*y.target.value/10)/10
- if(y.target.value>10) {colorpct560.textContent = Math.round(60*y.target.value/100)} else colorpct560.textContent = Math.round(60*y.target.value/10)/10
- if(y.target.value>10) {colorpct570.textContent = Math.round(70*y.target.value/100)} else colorpct570.textContent = Math.round(70*y.target.value/10)/10
- if(y.target.value>10) {colorpct580.textContent = Math.round(80*y.target.value/100)} else colorpct580.textContent = Math.round(80*y.target.value/10)/10
- if(y.target.value>10) {colorpct590.textContent = Math.round(90*y.target.value/100)} else colorpct590.textContent = Math.round(90*y.target.value/10)/10
- if(y.target.value>10) {colorpct600.textContent = Math.round(100*y.target.value/100)} else colorpct600.textContent = Math.round(100*y.target.value/10)/10
- if(y.target.value>10) {colorpct600a.textContent = Math.round(100*y.target.value/100) + '%+'} else colorpct600a.textContent = Math.round(100*y.target.value/10)/10 + '%+'
- var color = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Blue]
- ],
- 0, blue0,
- 0.0001, blue10,
- 0.1*colorscale, blue20,
- 0.2*colorscale, blue30,
- 0.3*colorscale, blue40,
- 0.4*colorscale, b1lue50,
- 0.5*colorscale, blue60,
- 0.6*colorscale, blue70,
- 0.7*colorscale, blue80,
- 0.8*colorscale, blue90,
- 0.9*colorscale, blue100,
- 1*colorscale, blue100a,
- ]
- map.setPaintProperty(layer1, 'fill-color', color)
- });
- //Blue Mouseover
- map.on('mousemove', function(i) {
- var states = map.queryRenderedFeatures(i.point, {
- layer: [layer1]
- });
- // Must edit states.properties for candidate
- if (states.length > 0) {
- legendtitle.innerHTML = '<h2>Idaho 2018 SPI GE Results by Precinct/County</h2><h3>'+ states[0].properties.G_NAME18 + '</h3><h3>' +states[0].properties.G_County + ' County</h3><h3>Total Votes: ' + Math.round(states[0].properties.G_SPETotal) + '</h3>'
- epct.innerHTML = ' '
- fpct.innerHTML = ' <strong>' + Math.round(states[0].properties.G_PCTWilso*10000)/100 + '%</strong>';
- } else {
- legendtitle.innerHTML = '<h2>Idaho 2018 SPI GE Results by Precinct/County</h2><h3>Statewide Overall Result</h3><h3>Statewide Votes: ' + StatewideVotes + '</h3>'
- epct.innerHTML = ' '
- fpct.innerHTML = ' <strong>' + BlueStatewidePCT + '%</strong>'
- }
- })
- }
- }
- var layers1 = document.getElementById('menu1');
- if (x1status >1){} else {layers1.appendChild(link1)}}
- }
- }
- }
- var layers2018 = document.getElementById('menu2018');
- if (x2018status> 1) {} else {layers2018.appendChild(link2018)}
- }
- }
- else if (clickedLayer === layer2)
- {map.setLayoutProperty(layer1,'visibility','none')
- map.setLayoutProperty(layer2,'visibility','visible')
- x2014status ++;
- x1.style.display = 'none'
- x2.style.display = 'none'
- x3.style.display = 'none'
- x4.style.display = 'none'
- x2014.style.display = 'block'
- x2018.style.display = 'none'
- var toggleableLayerIds2014= ['2014','Gov','SPI'];
- toggleableLayerNames2014 = ['2014','Gov','SPI'];
- for (var i = 0; i < toggleableLayerIds2014.length; i++) {
- var id2014 = toggleableLayerIds2014[i];
- var Names2014 = toggleableLayerNames2014[i];
- var link2014 = document.createElement('a');
- link2014.href = '#';
- link2014.className = 'active2014';
- if(id2014 === '2014') {link2014.className = 'header'}
- if(id2014 === 'SPI') {link2014.className = ''}
- link2014.shortcut = id2014;
- link2014.textContent = Names2014
- link2014.onclick = function (l) {
- var clickedLayer2014 = this.shortcut;
- var clickedName2014 = this.textContent
- var current2014 = document.getElementsByClassName('active2014');
- if(current2014[0].className === 'active2014') {current2014[0].className = current2014[0].className.replace('active2014','')}
- this.className = 'active2014';
- l.preventDefault();
- l.stopPropagation();
- if (clickedLayer2014 === "2014"){}
- else if (clickedLayer2014 === 'Gov')
- {x3status ++;
- x1.style.display = 'none'
- x2.style.display = 'none'
- x3.style.display = 'block'
- x4.style.display = 'none'
- var toggleableLayerIds3 = ['Gov','W','R','B'];
- toggleableLayerNames3 = ['Gov','Winner','Otter (R)','Balukoff (D)'];
- for (var i = 0; i < toggleableLayerIds3.length; i++) {
- var id3 = toggleableLayerIds3[i];
- var Names3 = toggleableLayerNames3[i];
- var link3 = document.createElement('a');
- link3.href = '#';
- link3.className = 'none';
- if(id3 === "Gov") {link3.className = 'header'}
- if(id3 === 'W') {link3.className = 'active3'}
- link3.shortcut = id3
- link3.textContent = Names3
- link3.onclick = function (g) {
- var clickedLayer3 = this.shortcut;
- var clickedName3 = this.textContent
- var current3 = document.getElementsByClassName('active3');
- if(current3[0].className === 'active3') {current3[0].className = current3[0].className.replace("active3","")}
- this.className = 'active3';
- g.preventDefault();
- g.stopPropagation();
- {if (clickedLayer3 === 'Gov'){}
- else if (clickedLayer3 === "W")
- {var color3 = Multi3;
- // reset color slider & text
- cssliderValue.textContent = '10 points';
- csslider.value = '100'
- colorpct510.textContent = '10'
- colorpct520.textContent = '20'
- colorpct530.textContent = '30'
- colorpct540.textContent = '40'
- colorpct550.textContent = '50'
- colorpct560.textContent = '60'
- colorpct570.textContent = '70'
- colorpct580.textContent = '80'
- colorpct590.textContent = '90'
- colorpct600.textContent = '99'
- colorpct600a.textContent = '100'
- //set labels - must edit - copy and paste from default
- candidateC.textContent = ''
- colorvalue200b.style = background + white
- colorvalue210.style = background + white
- colorvalue220.style = background + white
- colorvalue230.style = background + white
- colorvalue240.style = background + white
- colorvalue250.style = background + white
- colorvalue260.style = background + white
- colorvalue270.style = background + white
- colorvalue280.style = background + white
- colorvalue290.style = background + white
- colorvalue300.style = background + white
- colorvalue300a.style = background + white
- candidateD.textContent = ''
- colorvalue300b.style = background + white
- colorvalue310.style = background + white
- colorvalue320.style = background + white
- colorvalue330.style = background + white
- colorvalue340.style = background + white
- colorvalue350.style = background + white
- colorvalue360.style = background + white
- colorvalue370.style = background + white
- colorvalue380.style = background + white
- colorvalue390.style = background + white
- colorvalue400.style = background + white
- colorvalue400a.style = background + white
- candidateE.textContent = RedCandidate3
- colorvalue400b.style = background + red0
- colorvalue410.style = background + red10
- colorvalue420.style = background + red20
- colorvalue430.style = background + red30
- colorvalue440.style = background + red40
- colorvalue450.style = background + red50
- colorvalue460.style = background + red60
- colorvalue470.style = background + red70
- colorvalue480.style = background + red80
- colorvalue490.style = background + red90
- colorvalue500.style = background + red100
- colorvalue500a.style = background + red100a
- candidateF.textContent = BlueCandidate3
- colorvalue500b.style = background + blue0
- colorvalue510.style = background + blue10
- colorvalue520.style = background + blue20
- colorvalue530.style = background + blue30
- colorvalue540.style = background + blue40
- colorvalue550.style = background + blue50
- colorvalue560.style = background + blue60
- colorvalue570.style = background + blue70
- colorvalue580.style = background + blue80
- colorvalue590.style = background + blue90
- colorvalue600.style = background + blue100
- colorvalue600a.style = background + blue100a
- map.setPaintProperty(layer2, 'fill-color', color3);
- csslider.addEventListener('input', function(y) {
- // Adjust the colorscale. layer here is arbitrary - this could
- // be another layer name found in your style or a custom layer
- // added on the fly using `addSource`.
- var colorscale = (y.target.value) / 100;
- // Value indicator
- cssliderValue.textContent = y.target.value/10 + ' points';
- if(y.target.value>10) {colorpct510.textContent = Math.round(10*y.target.value/100)} else colorpct510.textContent = Math.round(10*y.target.value/10)/10
- if(y.target.value>10) {colorpct520.textContent = Math.round(20*y.target.value/100)} else colorpct520.textContent = Math.round(20*y.target.value/10)/10
- if(y.target.value>10) {colorpct530.textContent = Math.round(30*y.target.value/100)} else colorpct530.textContent = Math.round(30*y.target.value/10)/10
- if(y.target.value>10) {colorpct540.textContent = Math.round(40*y.target.value/100)} else colorpct540.textContent = Math.round(40*y.target.value/10)/10
- if(y.target.value>10) {colorpct550.textContent = Math.round(50*y.target.value/100)} else colorpct550.textContent = Math.round(50*y.target.value/10)/10
- if(y.target.value>10) {colorpct560.textContent = Math.round(60*y.target.value/100)} else colorpct560.textContent = Math.round(60*y.target.value/10)/10
- if(y.target.value>10) {colorpct570.textContent = Math.round(70*y.target.value/100)} else colorpct570.textContent = Math.round(70*y.target.value/10)/10
- if(y.target.value>10) {colorpct580.textContent = Math.round(80*y.target.value/100)} else colorpct580.textContent = Math.round(80*y.target.value/10)/10
- if(y.target.value>10) {colorpct590.textContent = Math.round(90*y.target.value/100)} else colorpct590.textContent = Math.round(90*y.target.value/10)/10
- if(y.target.value>10) {colorpct600.textContent = Math.round(100*y.target.value/100)} else colorpct600.textContent = Math.round(100*y.target.value/10)/10
- if(y.target.value>10) {colorpct600a.textContent = Math.round(100*y.target.value/100) + '%+'} else colorpct600a.textContent = Math.round(100*y.target.value/10)/10 + '%+'
- var color3 = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Wincode3]
- ],
- 0, red0,
- 0.0000001, red10,
- 0.1*colorscale, red20,
- 0.2*colorscale, red30,
- 0.3*colorscale, red40,
- 0.4*colorscale, red50,
- 0.5*colorscale, red60,
- 0.6*colorscale, red70,
- 0.7*colorscale, red80,
- 0.8*colorscale, red90,
- 0.9*colorscale, red100,
- 1, red100a,
- 1.00000001, green10,
- 1+(.1*colorscale), green20,
- 1+(.2*colorscale), green30,
- 1+(.3*colorscale), green40,
- 1+(.4*colorscale), green50,
- 1+(.5*colorscale), green60,
- 1+(.6*colorscale), green70,
- 1+(.7*colorscale), green80,
- 1+(.8*colorscale), green90,
- 1+(.9*colorscale), green100,
- 2, green100a,
- 2.00000001, blue10,
- 2+(.1*colorscale), blue20,
- 2+(.2*colorscale), blue30,
- 2+(.3*colorscale), blue40,
- 2+(.4*colorscale), blue50,
- 2+(.5*colorscale), blue60,
- 2+(.6*colorscale), blue70,
- 2+(.7*colorscale), blue80,
- 2+(.8*colorscale), blue90,
- 2+(.9*colorscale), blue100,
- 3, blue100a,
- 3.00000001, yellow10,
- 3+(.1*colorscale), yellow20,
- 3+(.2*colorscale), yellow30,
- 3+(.3*colorscale), yellow40,
- 3+(.4*colorscale), yellow50,
- 3+(.5*colorscale), yellow60,
- 3+(.6*colorscale), yellow70,
- 3+(.7*colorscale), yellow80,
- 3+(.8*colorscale), yellow90,
- 3+(.9*colorscale), yellow100,
- 4, yellow100a,
- 4.00000001, orange10,
- 4+(.1*colorscale), orange20,
- 4+(.2*colorscale), orange30,
- 4+(.3*colorscale), orange40,
- 4+(.4*colorscale), orange50,
- 4+(.5*colorscale), orange60,
- 4+(.6*colorscale), orange70,
- 4+(.7*colorscale), orange80,
- 4+(.8*colorscale), orange90,
- 4+(.9*colorscale), orange100,
- 5, orange100a,
- 5.00000001, purple10,
- 5+(.1*colorscale), purple20,
- 5+(.2*colorscale), purple30,
- 5+(.3*colorscale), purple40,
- 5+(.4*colorscale), purple50,
- 5+(.5*colorscale), purple60,
- 5+(.6*colorscale), purple70,
- 5+(.7*colorscale), purple80,
- 5+(.8*colorscale), purple90,
- 5+(.9*colorscale), purple100,
- 6, purple100a,
- 9, tie,
- 10, novotes,
- ]
- map.setPaintProperty(layer2, 'fill-color', color3);
- });
- //Multi mouseover
- map.on('mousemove', function(m) {
- var states = map.queryRenderedFeatures(m.point, {
- layer: [layer2]
- });
- // Must edit states.properties for candidate
- if (states.length > 0) {
- legendtitle.innerHTML = + '<h2>Idaho 2014 Gov GE Results by Precinct</h2><h3>'+ states[0].properties.PRECINCT14 + '</h3><h3>' +states[0].properties.G_County + ' County</h3>' + '</h3><h3>Total Votes: ' + Math.round(states[0].properties.G_GovTotal) + '</h3>'
- epct.innerHTML = ' <strong>' + Math.round(states[0].properties.G_PCTOtter*10000)/100 + '%</strong>'
- fpct.innerHTML = ' <strong>' + Math.round(states[0].properties.G_PCTBaluk*10000)/100 + '%</strong>'
- } else {
- legendtitle.innerHTML = '<h2>Idaho 2014 Gov GE Results by Precinct/County</h2><h3>Statewide Overall Result</h3><h3>Statewide Votes: ' + StatewideVotes2 + '</h3>'
- epct.innerHTML = ' <strong>' + RedStatewidePCT3 + '%</strong>'
- fpct.innerHTML = ' <strong>' + BlueStatewidePCT3 + '%</strong>'
- }
- });
- }
- else if (clickedLayer3 === "R")
- {var color3 = ColorRed3;
- // reset color slider & text
- cssliderValue.textContent = '10 points';
- csslider.value = '100'
- colorpct510.textContent = '10'
- colorpct520.textContent = '20'
- colorpct530.textContent = '30'
- colorpct540.textContent = '40'
- colorpct550.textContent = '50'
- colorpct560.textContent = '60'
- colorpct570.textContent = '70'
- colorpct580.textContent = '80'
- colorpct590.textContent = '90'
- colorpct600.textContent = '99'
- colorpct600a.textContent = '100'
- //set labels
- candidateC.textContent = ''
- colorvalue200b.style = background + white
- colorvalue210.style = background + white
- colorvalue220.style = background + white
- colorvalue230.style = background + white
- colorvalue240.style = background + white
- colorvalue250.style = background + white
- colorvalue260.style = background + white
- colorvalue270.style = background + white
- colorvalue280.style = background + white
- colorvalue290.style = background + white
- colorvalue300.style = background + white
- colorvalue300a.style = background + white
- candidateD.textContent = ''
- colorvalue300b.style = background + white
- colorvalue310.style = background + white
- colorvalue320.style = background + white
- colorvalue330.style = background + white
- colorvalue340.style = background + white
- colorvalue350.style = background + white
- colorvalue360.style = background + white
- colorvalue370.style = background + white
- colorvalue380.style = background + white
- colorvalue390.style = background + white
- colorvalue400.style = background + white
- colorvalue400a.style = background + white
- candidateE.textContent = ''
- colorvalue400b.style = background + white
- colorvalue410.style = background + white
- colorvalue420.style = background + white
- colorvalue430.style = background + white
- colorvalue440.style = background + white
- colorvalue450.style = background + white
- colorvalue460.style = background + white
- colorvalue470.style = background + white
- colorvalue480.style = background + white
- colorvalue490.style = background + white
- colorvalue500.style = background + white
- colorvalue500a.style = background + white
- candidateF.textContent = RedCandidate3
- colorvalue500b.style = background + red0
- colorvalue510.style = background + red10
- colorvalue520.style = background + red20
- colorvalue530.style = background + red30
- colorvalue540.style = background + red40
- colorvalue550.style = background + red50
- colorvalue560.style = background + red60
- colorvalue570.style = background + red70
- colorvalue580.style = background + red80
- colorvalue590.style = background + red90
- colorvalue600.style = background + red100
- colorvalue600a.style = background + red100a
- map.setPaintProperty(layer2, 'fill-color', color3)
- csslider.addEventListener('input', function(y) {
- // Adjust the colorscale. layer here is arbitrary - this could
- // be another layer name found in your style or a custom layer
- // added on the fly using `addSource`.
- var colorscale = (y.target.value) / 100;
- // Value indicator
- cssliderValue.textContent = y.target.value/10 + ' points';
- if(y.target.value>10) {colorpct510.textContent = Math.round(10*y.target.value/100)} else colorpct510.textContent = Math.round(10*y.target.value/10)/10
- if(y.target.value>10) {colorpct520.textContent = Math.round(20*y.target.value/100)} else colorpct520.textContent = Math.round(20*y.target.value/10)/10
- if(y.target.value>10) {colorpct530.textContent = Math.round(30*y.target.value/100)} else colorpct530.textContent = Math.round(30*y.target.value/10)/10
- if(y.target.value>10) {colorpct540.textContent = Math.round(40*y.target.value/100)} else colorpct540.textContent = Math.round(40*y.target.value/10)/10
- if(y.target.value>10) {colorpct550.textContent = Math.round(50*y.target.value/100)} else colorpct550.textContent = Math.round(50*y.target.value/10)/10
- if(y.target.value>10) {colorpct560.textContent = Math.round(60*y.target.value/100)} else colorpct560.textContent = Math.round(60*y.target.value/10)/10
- if(y.target.value>10) {colorpct570.textContent = Math.round(70*y.target.value/100)} else colorpct570.textContent = Math.round(70*y.target.value/10)/10
- if(y.target.value>10) {colorpct580.textContent = Math.round(80*y.target.value/100)} else colorpct580.textContent = Math.round(80*y.target.value/10)/10
- if(y.target.value>10) {colorpct590.textContent = Math.round(90*y.target.value/100)} else colorpct590.textContent = Math.round(90*y.target.value/10)/10
- if(y.target.value>10) {colorpct600.textContent = Math.round(100*y.target.value/100)} else colorpct600.textContent = Math.round(100*y.target.value/10)/10
- if(y.target.value>10) {colorpct600a.textContent = Math.round(100*y.target.value/100) + '%+'} else colorpct600a.textContent = Math.round(100*y.target.value/10)/10 + '%+'
- var color3 = ["interpolate",
- ["exponential", 0.1*colorscale],
- ["number",
- ["get", Red3]
- ],
- 0, red0,
- 0.0001, red10,
- 0.1*colorscale, red20,
- 0.2*colorscale, red30,
- 0.3*colorscale, red40,
- 0.4*colorscale, red50,
- 0.5*colorscale, red60,
- 0.6*colorscale, red70,
- 0.7*colorscale, red80,
- 0.8*colorscale, red90,
- 0.9*colorscale, red100,
- 1*colorscale, red100a
- ]
- map.setPaintProperty(layer2, 'fill-color', color3)
- });
- //red mouseover
- map.on('mousemove', function(h) {
- var states = map.queryRenderedFeatures(h.point, {
- layer: [layer2]
- });
- // Must edit states.properties for candidate
- if (states.length > 0) {
- legendtitle.innerHTML = '<h2>Idaho 2014 Gov GE Results by Precinct</h2><h3>'+ states[0].properties.PRECINCT14 + '</h3><h3>' +states[0].properties.G_County + ' County</h3><h3>Total Votes: ' + Math.round(states[0].properties.G_GovTotal) + '</h3>'
- epct.innerHTML = ' '
- fpct.innerHTML = ' <strong>' + Math.round(states[0].properties.G_PCTOtter*10000)/100 + '% </strong>'
- } else {
- legendtitle.innerHTML = '<h2>Idaho 2014 Gov GE Results by Precinct</h2><h3>Statewide Overall Result</h3><h3>Statewide Votes: ' + StatewideVotes2 + '</h3>'
- epct.innerHTML = ' '
- fpct.innerHTML = ' <strong>' + RedStatewidePCT3 + '%</strong>'
- }
- });
- }
- else if (clickedLayer3 === "B") {var color3 = ColorBlue3;
- // reset color slider & text
- cssliderValue.textContent = '10 points';
- csslider.value = '100'
- colorpct510.textContent = '10'
- colorpct520.textContent = '20'
- colorpct530.textContent = '30'
- colorpct540.textContent = '40'
- colorpct550.textContent = '50'
- colorpct560.textContent = '60'
- colorpct570.textContent = '70'
- colorpct580.textContent = '80'
- colorpct590.textContent = '90'
- colorpct600.textContent = '99'
- colorpct600a.textContent = '100'
- //set labels
- candidateC.textContent = ''
- colorvalue200b.style = background + white
- colorvalue210.style = background + white
- colorvalue220.style = background + white
- colorvalue230.style = background + white
- colorvalue240.style = background + white
- colorvalue250.style = background + white
- colorvalue260.style = background + white
- colorvalue270.style = background + white
- colorvalue280.style = background + white
- colorvalue290.style = background + white
- colorvalue300.style = background + white
- colorvalue300a.style = background + white
- candidateD.textContent = ''
- colorvalue300b.style = background + white
- colorvalue310.style = background + white
- colorvalue320.style = background + white
- colorvalue330.style = background + white
- colorvalue340.style = background + white
- colorvalue350.style = background + white
- colorvalue360.style = background + white
- colorvalue370.style = background + white
- colorvalue380.style = background + white
- colorvalue390.style = background + white
- colorvalue400.style = background + white
- colorvalue400a.style = background + white
- candidateE.textContent = ''
- colorvalue400b.style = background + white
- colorvalue410.style = background + white
- colorvalue420.style = background + white
- colorvalue430.style = background + white
- colorvalue440.style = background + white
- colorvalue450.style = background + white
- colorvalue460.style = background + white
- colorvalue470.style = background + white
- colorvalue480.style = background + white
- colorvalue490.style = background + white
- colorvalue500.style = background + white
- colorvalue500a.style = background + white
- candidateF.textContent = BlueCandidate3
- colorvalue500b.style = background + blue0
- colorvalue510.style = background + blue10
- colorvalue520.style = background + blue20
- colorvalue530.style = background + blue30
- colorvalue540.style = background + blue40
- colorvalue550.style = background + blue50
- colorvalue560.style = background + blue60
- colorvalue570.style = background + blue70
- colorvalue580.style = background + blue80
- colorvalue590.style = background + blue90
- colorvalue600.style = background + blue100
- colorvalue600a.style = background + blue100a
- map.setPaintProperty(layer2, 'fill-color', color3)
- csslider.addEventListener('input', function(y) {
- // Adjust the colorscale. layer here is arbitrary - this could
- // be another layer name found in your style or a custom layer
- // added on the fly using `addSource`.
- var colorscale = (y.target.value) / 100;
- // Value indicator
- cssliderValue.textContent = y.target.value/10 + ' points';
- if(y.target.value>10) {colorpct510.textContent = Math.round(10*y.target.value/100)} else colorpct510.textContent = Math.round(10*y.target.value/10)/10
- if(y.target.value>10) {colorpct520.textContent = Math.round(20*y.target.value/100)} else colorpct520.textContent = Math.round(20*y.target.value/10)/10
- if(y.target.value>10) {colorpct530.textContent = Math.round(30*y.target.value/100)} else colorpct530.textContent = Math.round(30*y.target.value/10)/10
- if(y.target.value>10) {colorpct540.textContent = Math.round(40*y.target.value/100)} else colorpct540.textContent = Math.round(40*y.target.value/10)/10
- if(y.target.value>10) {colorpct550.textContent = Math.round(50*y.target.value/100)} else colorpct550.textContent = Math.round(50*y.target.value/10)/10
- if(y.target.value>10) {colorpct560.textContent = Math.round(60*y.target.value/100)} else colorpct560.textContent = Math.round(60*y.target.value/10)/10
- if(y.target.value>10) {colorpct570.textContent = Math.round(70*y.target.value/100)} else colorpct570.textContent = Math.round(70*y.target.value/10)/10
- if(y.target.value>10) {colorpct580.textContent = Math.round(80*y.target.value/100)} else colorpct580.textContent = Math.round(80*y.target.value/10)/10
- if(y.target.value>10) {colorpct590.textContent = Math.round(90*y.target.value/100)} else colorpct590.textContent = Math.round(90*y.target.value/10)/10
- if(y.target.value>10) {colorpct600.textContent = Math.round(100*y.target.value/100)} else colorpct600.textContent = Math.round(100*y.target.value/10)/10
- if(y.target.value>10) {colorpct600a.textContent = Math.round(100*y.target.value/100) + '%+'} else colorpct600a.textContent = Math.round(100*y.target.value/10)/10 + '%+'
- var color3 = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Blue3]
- ],
- 0, blue0,
- 0.0001, blue10,
- 0.1*colorscale, blue20,
- 0.2*colorscale, blue30,
- 0.3*colorscale, blue40,
- 0.4*colorscale, blue50,
- 0.5*colorscale, blue60,
- 0.6*colorscale, blue70,
- 0.7*colorscale, blue80,
- 0.8*colorscale, blue90,
- 0.9*colorscale, blue100,
- 1*colorscale, blue100a,
- ]
- map.setPaintProperty(layer2, 'fill-color', color3)
- });
- //Blue Mouseover
- map.on('mousemove', function(i) {
- var states = map.queryRenderedFeatures(i.point, {
- layer: [layer2]
- });
- // Must edit states.properties for candidate
- if (states.length > 0) {
- legendtitle.innerHTML = '<h2>Idaho 2014 Gov GE Results by Precinct</h2><h3>'+ states[0].properties.PRECINCT14 + '</h3><h3>' +states[0].properties.G_County + ' County</h3>Total Votes: ' + Math.round(states[0].properties.G_GovTotal) + '</h3>'
- epct.innerHTML = ' '
- fpct.innerHTML = ' <strong>' + Math.round(states[0].properties.G_PCTBaluk*10000)/100 + '%</strong>';
- } else {
- legendtitle.innerHTML = '<h2>Idaho 2014 Gov GE Results by Precinct</h2><h3>Statewide Overall Result</h3><h3>Statewide Votes: ' + StatewideVotes2 + '</h3>'
- epct.innerHTML = ' '
- fpct.innerHTML = ' <strong>' + BlueStatewidePCT3 + '%</strong>'
- }
- })
- }
- }
- }
- var layers3 = document.getElementById('menu3');
- if (x3status >1){} else {layers3.appendChild(link3)}
- }
- }
- else if (clickedLayer2014 === 'SPI')
- {x2status ++;
- x1.style.display = 'none'
- x2.style.display = 'block'
- x3.style.display = 'none'
- x4.style.display = 'none'
- var toggleableLayerIds2 = ['SPI','W','R','B'];
- toggleableLayerNames2 = ['SPI','Winner','Ybarra (R)','Jones (D)'];
- for (var i = 0; i < toggleableLayerIds2.length; i++) {
- var id2 = toggleableLayerIds2[i];
- var Names2 = toggleableLayerNames2[i];
- var link2 = document.createElement('a');
- link2.href = '#';
- link2.className = 'none';
- if(id2 === "SPI") {link2.className = 'header'}
- if(id2 === 'W') {link2.className = 'active2'}
- link2.shortcut = id2
- link2.textContent = Names2
- link2.onclick = function (g) {
- var clickedLayer2 = this.shortcut;
- var clickedName2 = this.textContent
- var current2 = document.getElementsByClassName('active2');
- if(current2[0].className === 'active2') {current2[0].className = current2[0].className.replace("active2","")}
- this.className = 'active2';
- // build a reference to the existing node to be replaced
- g.preventDefault();
- g.stopPropagation();
- {if (clickedLayer2 === 'SPI') {}
- else if (clickedLayer2 === "W")
- {var color2 = Multi2;
- // reset color slider & text
- cssliderValue.textContent = '10 points';
- csslider.value = '100'
- colorpct510.textContent = '10'
- colorpct520.textContent = '20'
- colorpct530.textContent = '30'
- colorpct540.textContent = '40'
- colorpct550.textContent = '50'
- colorpct560.textContent = '60'
- colorpct570.textContent = '70'
- colorpct580.textContent = '80'
- colorpct590.textContent = '90'
- colorpct600.textContent = '99'
- colorpct600a.textContent = '100'
- //set labels - must edit - copy and paste from default
- candidateC.textContent = ''
- colorvalue200b.style = background + white
- colorvalue210.style = background + white
- colorvalue220.style = background + white
- colorvalue230.style = background + white
- colorvalue240.style = background + white
- colorvalue250.style = background + white
- colorvalue260.style = background + white
- colorvalue270.style = background + white
- colorvalue280.style = background + white
- colorvalue290.style = background + white
- colorvalue300.style = background + white
- colorvalue300a.style = background + white
- candidateD.textContent = ''
- colorvalue300b.style = background + white
- colorvalue310.style = background + white
- colorvalue320.style = background + white
- colorvalue330.style = background + white
- colorvalue340.style = background + white
- colorvalue350.style = background + white
- colorvalue360.style = background + white
- colorvalue370.style = background + white
- colorvalue380.style = background + white
- colorvalue390.style = background + white
- colorvalue400.style = background + white
- colorvalue400a.style = background + white
- candidateE.textContent = RedCandidate2
- colorvalue400b.style = background + red0
- colorvalue410.style = background + red10
- colorvalue420.style = background + red20
- colorvalue430.style = background + red30
- colorvalue440.style = background + red40
- colorvalue450.style = background + red50
- colorvalue460.style = background + red60
- colorvalue470.style = background + red70
- colorvalue480.style = background + red80
- colorvalue490.style = background + red90
- colorvalue500.style = background + red100
- colorvalue500a.style = background + red100a
- candidateF.textContent = BlueCandidate2
- colorvalue500b.style = background + blue0
- colorvalue510.style = background + blue10
- colorvalue520.style = background + blue20
- colorvalue530.style = background + blue30
- colorvalue540.style = background + blue40
- colorvalue550.style = background + blue50
- colorvalue560.style = background + blue60
- colorvalue570.style = background + blue70
- colorvalue580.style = background + blue80
- colorvalue590.style = background + blue90
- colorvalue600.style = background + blue100
- colorvalue600a.style = background + blue100a
- map.setPaintProperty(layer2, 'fill-color', color2);
- csslider.addEventListener('input', function(y) {
- // Adjust the colorscale. layer here is arbitrary - this could
- // be another layer name found in your style or a custom layer
- // added on the fly using `addSource`.
- var colorscale = (y.target.value) / 100;
- // Value indicator
- cssliderValue.textContent = y.target.value/10 + ' points';
- if(y.target.value>10) {colorpct510.textContent = Math.round(10*y.target.value/100)} else colorpct510.textContent = Math.round(10*y.target.value/10)/10
- if(y.target.value>10) {colorpct520.textContent = Math.round(20*y.target.value/100)} else colorpct520.textContent = Math.round(20*y.target.value/10)/10
- if(y.target.value>10) {colorpct530.textContent = Math.round(30*y.target.value/100)} else colorpct530.textContent = Math.round(30*y.target.value/10)/10
- if(y.target.value>10) {colorpct540.textContent = Math.round(40*y.target.value/100)} else colorpct540.textContent = Math.round(40*y.target.value/10)/10
- if(y.target.value>10) {colorpct550.textContent = Math.round(50*y.target.value/100)} else colorpct550.textContent = Math.round(50*y.target.value/10)/10
- if(y.target.value>10) {colorpct560.textContent = Math.round(60*y.target.value/100)} else colorpct560.textContent = Math.round(60*y.target.value/10)/10
- if(y.target.value>10) {colorpct570.textContent = Math.round(70*y.target.value/100)} else colorpct570.textContent = Math.round(70*y.target.value/10)/10
- if(y.target.value>10) {colorpct580.textContent = Math.round(80*y.target.value/100)} else colorpct580.textContent = Math.round(80*y.target.value/10)/10
- if(y.target.value>10) {colorpct590.textContent = Math.round(90*y.target.value/100)} else colorpct590.textContent = Math.round(90*y.target.value/10)/10
- if(y.target.value>10) {colorpct600.textContent = Math.round(100*y.target.value/100)} else colorpct600.textContent = Math.round(100*y.target.value/10)/10
- if(y.target.value>10) {colorpct600a.textContent = Math.round(100*y.target.value/100) + '%+'} else colorpct600a.textContent = Math.round(100*y.target.value/10)/10 + '%+'
- var color2 = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Wincode2]
- ],
- 0, red0,
- 0.0000001, red10,
- 0.1*colorscale, red20,
- 0.2*colorscale, red30,
- 0.3*colorscale, red40,
- 0.4*colorscale, red50,
- 0.5*colorscale, red60,
- 0.6*colorscale, red70,
- 0.7*colorscale, red80,
- 0.8*colorscale, red90,
- 0.9*colorscale, red100,
- 1, red100a,
- 1.00000001, green10,
- 1+(.1*colorscale), green20,
- 1+(.2*colorscale), green30,
- 1+(.3*colorscale), green40,
- 1+(.4*colorscale), green50,
- 1+(.5*colorscale), green60,
- 1+(.6*colorscale), green70,
- 1+(.7*colorscale), green80,
- 1+(.8*colorscale), green90,
- 1+(.9*colorscale), green100,
- 2, green100a,
- 2.00000001, blue10,
- 2+(.1*colorscale), blue20,
- 2+(.2*colorscale), blue30,
- 2+(.3*colorscale), blue40,
- 2+(.4*colorscale), blue50,
- 2+(.5*colorscale), blue60,
- 2+(.6*colorscale), blue70,
- 2+(.7*colorscale), blue80,
- 2+(.8*colorscale), blue90,
- 2+(.9*colorscale), blue100,
- 3, blue100a,
- 3.00000001, yellow10,
- 3+(.1*colorscale), yellow20,
- 3+(.2*colorscale), yellow30,
- 3+(.3*colorscale), yellow40,
- 3+(.4*colorscale), yellow50,
- 3+(.5*colorscale), yellow60,
- 3+(.6*colorscale), yellow70,
- 3+(.7*colorscale), yellow80,
- 3+(.8*colorscale), yellow90,
- 3+(.9*colorscale), yellow100,
- 4, yellow100a,
- 4.00000001, orange10,
- 4+(.1*colorscale), orange20,
- 4+(.2*colorscale), orange30,
- 4+(.3*colorscale), orange40,
- 4+(.4*colorscale), orange50,
- 4+(.5*colorscale), orange60,
- 4+(.6*colorscale), orange70,
- 4+(.7*colorscale), orange80,
- 4+(.8*colorscale), orange90,
- 4+(.9*colorscale), orange100,
- 5, orange100a,
- 5.00000001, purple10,
- 5+(.1*colorscale), purple20,
- 5+(.2*colorscale), purple30,
- 5+(.3*colorscale), purple40,
- 5+(.4*colorscale), purple50,
- 5+(.5*colorscale), purple60,
- 5+(.6*colorscale), purple70,
- 5+(.7*colorscale), purple80,
- 5+(.8*colorscale), purple90,
- 5+(.9*colorscale), purple100,
- 6, purple100a,
- 9, tie,
- 10, novotes,
- ]
- map.setPaintProperty(layer2, 'fill-color', color2);
- });
- //Multi mouseover
- map.on('mousemove', function(m) {
- var states = map.queryRenderedFeatures(m.point, {
- layer: [layer2]
- });
- // Must edit states.properties for candidate
- if (states.length > 0) {
- legendtitle.innerHTML = '<h2>Idaho 2014 SPI GE Results by Precinct</h2><h3>'+ states[0].properties.PRECINCT14 + '</h3><h3>' +states[0].properties.G_County + ' County</h3>' + '</h3><h3>Total Votes: ' + Math.round(states[0].properties.G_SupEdTot) + '</h3>'
- epct.innerHTML = ' <strong>' + Math.round(states[0].properties.G_PCTWasde*10000)/100 + '%</strong>'
- fpct.innerHTML = ' <strong>' + Math.round(states[0].properties.G_PCTJones*10000)/100 + '%</strong>'
- } else {
- legendtitle.innerHTML = '<h2>Idaho 2014 SPI GE Results by Precinct/County</h2><h3>Statewide Overall Result</h3><h3>Statewide Votes: ' + StatewideVotes2 + '</h3>'
- epct.innerHTML = ' <strong>' + RedStatewidePCT2 + '%</strong>'
- fpct.innerHTML = ' <strong>' + BlueStatewidePCT2 + '%</strong>'
- }
- });
- }
- else if (clickedLayer2 === "R")
- {var color2 = ColorRed2;
- // reset color slider & text
- cssliderValue.textContent = '10 points';
- csslider.value = '100'
- colorpct510.textContent = '10'
- colorpct520.textContent = '20'
- colorpct530.textContent = '30'
- colorpct540.textContent = '40'
- colorpct550.textContent = '50'
- colorpct560.textContent = '60'
- colorpct570.textContent = '70'
- colorpct580.textContent = '80'
- colorpct590.textContent = '90'
- colorpct600.textContent = '99'
- colorpct600a.textContent = '100'
- //set labels
- candidateC.textContent = ''
- colorvalue200b.style = background + white
- colorvalue210.style = background + white
- colorvalue220.style = background + white
- colorvalue230.style = background + white
- colorvalue240.style = background + white
- colorvalue250.style = background + white
- colorvalue260.style = background + white
- colorvalue270.style = background + white
- colorvalue280.style = background + white
- colorvalue290.style = background + white
- colorvalue300.style = background + white
- colorvalue300a.style = background + white
- candidateD.textContent = ''
- colorvalue300b.style = background + white
- colorvalue310.style = background + white
- colorvalue320.style = background + white
- colorvalue330.style = background + white
- colorvalue340.style = background + white
- colorvalue350.style = background + white
- colorvalue360.style = background + white
- colorvalue370.style = background + white
- colorvalue380.style = background + white
- colorvalue390.style = background + white
- colorvalue400.style = background + white
- colorvalue400a.style = background + white
- candidateE.textContent = ''
- colorvalue400b.style = background + white
- colorvalue410.style = background + white
- colorvalue420.style = background + white
- colorvalue430.style = background + white
- colorvalue440.style = background + white
- colorvalue450.style = background + white
- colorvalue460.style = background + white
- colorvalue470.style = background + white
- colorvalue480.style = background + white
- colorvalue490.style = background + white
- colorvalue500.style = background + white
- colorvalue500a.style = background + white
- candidateF.textContent = RedCandidate2
- colorvalue500b.style = background + red0
- colorvalue510.style = background + red10
- colorvalue520.style = background + red20
- colorvalue530.style = background + red30
- colorvalue540.style = background + red40
- colorvalue550.style = background + red50
- colorvalue560.style = background + red60
- colorvalue570.style = background + red70
- colorvalue580.style = background + red80
- colorvalue590.style = background + red90
- colorvalue600.style = background + red100
- colorvalue600a.style = background + red100a
- map.setPaintProperty(layer2, 'fill-color', color2)
- csslider.addEventListener('input', function(y) {
- // Adjust the colorscale. layer here is arbitrary - this could
- // be another layer name found in your style or a custom layer
- // added on the fly using `addSource`.
- var colorscale = (y.target.value) / 100;
- // Value indicator
- cssliderValue.textContent = y.target.value/10 + ' points';
- if(y.target.value>10) {colorpct510.textContent = Math.round(10*y.target.value/100)} else colorpct510.textContent = Math.round(10*y.target.value/10)/10
- if(y.target.value>10) {colorpct520.textContent = Math.round(20*y.target.value/100)} else colorpct520.textContent = Math.round(20*y.target.value/10)/10
- if(y.target.value>10) {colorpct530.textContent = Math.round(30*y.target.value/100)} else colorpct530.textContent = Math.round(30*y.target.value/10)/10
- if(y.target.value>10) {colorpct540.textContent = Math.round(40*y.target.value/100)} else colorpct540.textContent = Math.round(40*y.target.value/10)/10
- if(y.target.value>10) {colorpct550.textContent = Math.round(50*y.target.value/100)} else colorpct550.textContent = Math.round(50*y.target.value/10)/10
- if(y.target.value>10) {colorpct560.textContent = Math.round(60*y.target.value/100)} else colorpct560.textContent = Math.round(60*y.target.value/10)/10
- if(y.target.value>10) {colorpct570.textContent = Math.round(70*y.target.value/100)} else colorpct570.textContent = Math.round(70*y.target.value/10)/10
- if(y.target.value>10) {colorpct580.textContent = Math.round(80*y.target.value/100)} else colorpct580.textContent = Math.round(80*y.target.value/10)/10
- if(y.target.value>10) {colorpct590.textContent = Math.round(90*y.target.value/100)} else colorpct590.textContent = Math.round(90*y.target.value/10)/10
- if(y.target.value>10) {colorpct600.textContent = Math.round(100*y.target.value/100)} else colorpct600.textContent = Math.round(100*y.target.value/10)/10
- if(y.target.value>10) {colorpct600a.textContent = Math.round(100*y.target.value/100) + '%+'} else colorpct600a.textContent = Math.round(100*y.target.value/10)/10 + '%+'
- var color2 = ["interpolate",
- ["exponential", 0.1*colorscale],
- ["number",
- ["get", Red2]
- ],
- 0, red0,
- 0.0001, red10,
- 0.1*colorscale, red20,
- 0.2*colorscale, red30,
- 0.3*colorscale, red40,
- 0.4*colorscale, red50,
- 0.5*colorscale, red60,
- 0.6*colorscale, red70,
- 0.7*colorscale, red80,
- 0.8*colorscale, red90,
- 0.9*colorscale, red100,
- 1*colorscale, red100a
- ]
- map.setPaintProperty(layer2, 'fill-color', color2)
- });
- //red mouseover
- map.on('mousemove', function(h) {
- var states = map.queryRenderedFeatures(h.point, {
- layer: [layer2]
- });
- // Must edit states.properties for candidate
- if (states.length > 0) {
- legendtitle.innerHTML = '<h2>Idaho 2014 SPI GE Results by Precinct</h2><h3>'+ states[0].properties.PRECINCT14 + '</h3><h3>' +states[0].properties.G_County + ' County</h3><h3>Total Votes: ' + Math.round(states[0].properties.G_SupEdTot) + '</h3>'
- epct.innerHTML = ' '
- fpct.innerHTML = ' <strong>' + Math.round(states[0].properties.G_PCTWasde*10000)/100 + '% </strong>'
- } else {
- legendtitle.innerHTML = '<h2>Idaho 2014 SPI GE Results by Precinct</h2><h3>Statewide Overall Result</h3><h3>Statewide Votes: ' + StatewideVotes2 + '</h3>'
- epct.innerHTML = ' '
- fpct.innerHTML = ' <strong>' + RedStatewidePCT2 + '%</strong>'
- }
- });
- }
- else if (clickedLayer2 === "B") {var color2 = ColorBlue2;
- // reset color slider & text
- cssliderValue.textContent = '10 points';
- csslider.value = '100'
- colorpct510.textContent = '10'
- colorpct520.textContent = '20'
- colorpct530.textContent = '30'
- colorpct540.textContent = '40'
- colorpct550.textContent = '50'
- colorpct560.textContent = '60'
- colorpct570.textContent = '70'
- colorpct580.textContent = '80'
- colorpct590.textContent = '90'
- colorpct600.textContent = '99'
- colorpct600a.textContent = '100'
- //set labels
- candidateC.textContent = ''
- colorvalue200b.style = background + white
- colorvalue210.style = background + white
- colorvalue220.style = background + white
- colorvalue230.style = background + white
- colorvalue240.style = background + white
- colorvalue250.style = background + white
- colorvalue260.style = background + white
- colorvalue270.style = background + white
- colorvalue280.style = background + white
- colorvalue290.style = background + white
- colorvalue300.style = background + white
- colorvalue300a.style = background + white
- candidateD.textContent = ''
- colorvalue300b.style = background + white
- colorvalue310.style = background + white
- colorvalue320.style = background + white
- colorvalue330.style = background + white
- colorvalue340.style = background + white
- colorvalue350.style = background + white
- colorvalue360.style = background + white
- colorvalue370.style = background + white
- colorvalue380.style = background + white
- colorvalue390.style = background + white
- colorvalue400.style = background + white
- colorvalue400a.style = background + white
- candidateE.textContent = ''
- colorvalue400b.style = background + white
- colorvalue410.style = background + white
- colorvalue420.style = background + white
- colorvalue430.style = background + white
- colorvalue440.style = background + white
- colorvalue450.style = background + white
- colorvalue460.style = background + white
- colorvalue470.style = background + white
- colorvalue480.style = background + white
- colorvalue490.style = background + white
- colorvalue500.style = background + white
- colorvalue500a.style = background + white
- candidateF.textContent = BlueCandidate2
- colorvalue500b.style = background + blue0
- colorvalue510.style = background + blue10
- colorvalue520.style = background + blue20
- colorvalue530.style = background + blue30
- colorvalue540.style = background + blue40
- colorvalue550.style = background + blue50
- colorvalue560.style = background + blue60
- colorvalue570.style = background + blue70
- colorvalue580.style = background + blue80
- colorvalue590.style = background + blue90
- colorvalue600.style = background + blue100
- colorvalue600a.style = background + blue100a
- map.setPaintProperty(layer2, 'fill-color', color2)
- csslider.addEventListener('input', function(y) {
- // Adjust the colorscale. layer here is arbitrary - this could
- // be another layer name found in your style or a custom layer
- // added on the fly using `addSource`.
- var colorscale = (y.target.value) / 100;
- // Value indicator
- cssliderValue.textContent = y.target.value/10 + ' points';
- if(y.target.value>10) {colorpct510.textContent = Math.round(10*y.target.value/100)} else colorpct510.textContent = Math.round(10*y.target.value/10)/10
- if(y.target.value>10) {colorpct520.textContent = Math.round(20*y.target.value/100)} else colorpct520.textContent = Math.round(20*y.target.value/10)/10
- if(y.target.value>10) {colorpct530.textContent = Math.round(30*y.target.value/100)} else colorpct530.textContent = Math.round(30*y.target.value/10)/10
- if(y.target.value>10) {colorpct540.textContent = Math.round(40*y.target.value/100)} else colorpct540.textContent = Math.round(40*y.target.value/10)/10
- if(y.target.value>10) {colorpct550.textContent = Math.round(50*y.target.value/100)} else colorpct550.textContent = Math.round(50*y.target.value/10)/10
- if(y.target.value>10) {colorpct560.textContent = Math.round(60*y.target.value/100)} else colorpct560.textContent = Math.round(60*y.target.value/10)/10
- if(y.target.value>10) {colorpct570.textContent = Math.round(70*y.target.value/100)} else colorpct570.textContent = Math.round(70*y.target.value/10)/10
- if(y.target.value>10) {colorpct580.textContent = Math.round(80*y.target.value/100)} else colorpct580.textContent = Math.round(80*y.target.value/10)/10
- if(y.target.value>10) {colorpct590.textContent = Math.round(90*y.target.value/100)} else colorpct590.textContent = Math.round(90*y.target.value/10)/10
- if(y.target.value>10) {colorpct600.textContent = Math.round(100*y.target.value/100)} else colorpct600.textContent = Math.round(100*y.target.value/10)/10
- if(y.target.value>10) {colorpct600a.textContent = Math.round(100*y.target.value/100) + '%+'} else colorpct600a.textContent = Math.round(100*y.target.value/10)/10 + '%+'
- var color2 = ["interpolate",
- ["exponential", 0.1],
- ["number",
- ["get", Blue2]
- ],
- 0, blue0,
- 0.0001, blue10,
- 0.1*colorscale, blue20,
- 0.2*colorscale, blue30,
- 0.3*colorscale, blue40,
- 0.4*colorscale, blue50,
- 0.5*colorscale, blue60,
- 0.6*colorscale, blue70,
- 0.7*colorscale, blue80,
- 0.8*colorscale, blue90,
- 0.9*colorscale, blue100,
- 1*colorscale, blue100a,
- ]
- map.setPaintProperty(layer2, 'fill-color', color2)
- });
- //Blue Mouseover
- map.on('mousemove', function(i) {
- var states = map.queryRenderedFeatures(i.point, {
- layer: [layer2]
- });
- // Must edit states.properties for candidate
- if (states.length > 0) {
- legendtitle.innerHTML = '<h2>Idaho 2014 SPI GE Results by Precinct</h2><h3>'+ states[0].properties.PRECINCT14 + '</h3><h3>' +states[0].properties.G_County + ' County</h3>Total Votes: ' + Math.round(states[0].properties.G_SupEdTot) + '</h3>'
- epct.innerHTML = ' '
- fpct.innerHTML = ' <strong>' + Math.round(states[0].properties.G_PCTJones*10000)/100 + '%</strong>';
- } else {
- legendtitle.innerHTML = '<h2>Idaho 2014 SPI GE Results by Precinct</h2><h3>Statewide Overall Result</h3><h3>Statewide Votes: ' + StatewideVotes2 + '</h3>'
- epct.innerHTML = ' '
- fpct.innerHTML = ' <strong>' + BlueStatewidePCT2 + '%</strong>'
- }
- })
- }
- }
- }
- var layers2 = document.getElementById('menu2');
- if (x2status >1){} else {layers2.appendChild(link2)}
- }
- }
- }
- var layers2014 = document.getElementById('menu2014');
- if (x2014status> 1) {} else {layers2014.appendChild(link2014) }
- } }
- }
- var layers = document.getElementById('menu');
- layers.appendChild(link);}
- })
- // listen for Change
- slider.addEventListener('input', function(z) {
- // Adjust the layers opacity. layer here is arbitrary - this could
- // be another layer name found in your style or a custom layer
- // added on the fly using `addSource`.
- map.setPaintProperty(layer1,'fill-opacity', parseInt(z.target.value, 10) / 100);
- map.setPaintProperty(layer2,'fill-opacity', parseInt(z.target.value, 10) / 100)
- // Value indicator
- sliderValue.textContent = z.target.value + '%';
- })
- //county layer - must edit or delete
- map.on('load',
- function () {map.addLayer({
- id: layerCounty,
- type: 'line',
- source: {
- type: 'vector',
- // Mapbox tileset Map ID - must edit for different tilesets
- url: 'mapbox://cinyc.7whn2ikm'
- },
- 'source-layer': layerCounty,
- paint: {
- 'line-color': "#000000",
- 'line-width': 1
- },},)})
- map.on('mouseenter', layer1, function () {
- map.getCanvas().style.cursor = 'pointer';
- });
- // Change it back to a pointer when it leaves.
- map.on('mouseleave', layer1, function () {
- map.getCanvas().style.cursor = '';
- });
- map.addControl(new MapboxGeocoder({
- accessToken: mapboxgl.accessToken,
- // limit results to US
- country: 'us',
- // apply a client side filter to further limit results to those strictly within
- // Idaho
- filter: function (item) {
- // returns true if item contains Idaho region
- return item.context.map(function (i) {
- // id is in the form {index}.{id} per https://github.com/mapbox/carmen/blob/master/carmen-geojson.md
- // this example attempts to find the `region` named `Idaho`
- return (i.id.split('.').shift() === 'region' && i.text === 'Idaho');
- }).reduce(function (acc, cur) {
- return acc || cur;
- });
- }
- }));
- map.addControl(new mapboxgl.FullscreenControl());
- map.addControl(new mapboxgl.NavigationControl());
- // the rest of the code will go in here
- </script></body></html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement