Skip to content

Instantly share code, notes, and snippets.

@enactdev
Last active July 30, 2018 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enactdev/a6e803b6cb48f070a91bbf1545e33593 to your computer and use it in GitHub Desktop.
Save enactdev/a6e803b6cb48f070a91bbf1545e33593 to your computer and use it in GitHub Desktop.
Bears Ears changes: Obama to Trump

Bears Ears changes: Obama to Trump

This map shows Obama's Bears Ears National Monument outlined in black, with Trump's much smaller replacement overlaid in blue.

A full description of how I created this is available on my blog.

Short description: Files were downloaded from blm.gov, converted to GeoJSON with ogr2ogr, edited with QGIS, simplified with mapshaper.org, and displayed with Leaflet.

ogr2ogr -skipfailures -f "GeoJSON" -t_srs WGS84 bears_ears_obmama.json NLCS_NM_NCA_historic.gdb

Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
{"type":"FeatureCollection","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:OGC:1.3:CRS84"}}, "features": [
{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-109.95993564479926,37.7643473928615],[-109.96140114650002,37.76434744740251],[-109.96139279669025,37.77146303481561],[-109.95226216380239,37.77146292469729],[-109.95227161282837,37.76434747188315],[-109.95993564479926,37.7643473928615]]]},"properties":{"NLCS_ID":"NLCS000851","NLCS_NAME":"Bears Ears - Shash Jáa Unit","CASEFILE_NO":"UNK","NLCS_TYPE":"National Monument","ADMIN_ST":"UT","GlobalID":"{B266750E-4808-4C5D-8608-B129AE9743D0}","Shape_Length":3187.476791998426,"Shape_Area":634950.9011210196}},
{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-109.77221824979655,37.68197340023895],[-109.76714674997969,37.680212155925894],[-109.76415501352274,37.677078453368324],[-109.75773185615027,37.67359183963062],[-109.75243166259631,37.67310421018771],[-109.74378456764654,37.669802105623624],[-109.73271250650568,37.66794975624098],[-109.72259982878181,37.66575236203867],[-109.71698842750261,37.66579874493328],[-109.71383096300315,37.66860519108607],[-109.70845458002886,37.66676684731318],[-109.70434430333395,37.667557188234156],[-109.69856442792128,37.66592531149627],[-109.69653173227593,37.66397213040188],[-109.69183575151449,37.66457351548635],[-109.68937538191176,37.66381505146279],[-109.68717781992297,37.660708064179495],[-109.68271964192982,37.6632865037438],[-109.68009097623985,37.66378281520777],[-109.67659836716415,37.65678710988237],[-109.67012942365943,37.65104062501359],[-109.66728252253641,37.65205986942528],[-109.66037858419404,37.65183862380999],[-109.65428131416196,37.64948796702682],[-109.64431358359921,37.648654029025394],[-109.64135706281243,37.650585026390324],[-109.63895382386917,37.64844005241317],[-109.63892084520849,37.621149117584594],[-109.67540187837075,37.621120497869185],[-109.6753947111927,37.60663790625227],[-109.65714988196025,37.6066679623325],[-109.65715640122086,37.59214486766969],[-109.63899510137549,37.5921221809139],[-109.63913181813494,37.56311828264878],[-109.63179865105644,37.56313066668631],[-109.63162882268806,37.558136122333956],[-109.62941791744629,37.55770441759496],[-109.62834521538382,37.55416931330795],[-109.62632527384488,37.5517006199265],[-109.62759932733842,37.54989801826071],[-109.63146834601298,37.547947583337205],[-109.63055441293308,37.53817924243303],[-109.62860213106039,37.53273253416662],[-109.62622227747994,37.531638611604784],[-109.62583166571582,37.52901293232144],[-109.62078169086199,37.534584781684764],[-109.61643435887788,37.533637242252766],[-109.61958881792826,37.53008403145269],[-109.61925987616334,37.52865158299478],[-109.62240339984362,37.5255187662384],[-109.62008768843648,37.51852326373566],[-109.62425515046999,37.51831237263189],[-109.62653317530098,37.51604774699972],[-109.62655612313817,37.5095141711101],[-109.62813041639319,37.50855879776459],[-109.6268001001604,37.50503407291273],[-109.62717578902559,37.50024580191209],[-109.62883297968811,37.496766557634785],[-109.62912104100923,37.49207049048054],[-109.62846113333181,37.48267477947804],[-109.63022261988442,37.47425721735637],[-109.63024599841951,37.466314081374456],[-109.6271625835905,37.46554145819834],[-109.62351838713458,37.46829443317479],[-109.6204103868361,37.46789494470385],[-109.61583891887591,37.471048435526924],[-109.61215831782563,37.47186244317286],[-109.6121663877175,37.468658388289114],[-109.61958234750458,37.463934435325385],[-109.62041666698882,37.45898041563175],[-109.61752483720166,37.45671296336021],[-109.61476922947625,37.45152722930106],[-109.61114215947154,37.44884259311925],[-109.61847222235764,37.43764547898754],[-109.62078703731777,37.435575838605736],[-109.6173621720057,37.4338395524304],[-109.61523148230172,37.43063312693377],[-109.61003511075829,37.42866859212101],[-109.60928967555992,37.42615740786947],[-109.61032407399134,37.42321958217926],[-109.61629770743181,37.42300925878815],[-109.61606481478589,37.42006591782308],[-109.61365740721533,37.41890287621324],[-109.6086837253311,37.41375000042953],[-109.60827491444657,37.41116953022525],[-109.61493209752054,37.410046296391286],[-109.6137834013108,37.40837962996342],[-109.61449910551067,37.405231481877166],[-109.6079542294844,37.40463836695765],[-109.60856481509312,37.400058119075666],[-109.60794796016569,37.396990740614086],[-109.60316784708111,37.396036348877],[-109.60319140390752,37.36011090302039],[-109.61868530061486,37.36009147115152],[-109.6239922187631,37.34943370658638],[-109.62348297642582,37.34449074086566],[-109.6197943818688,37.34581290066796],[-109.61777178936437,37.343975490665365],[-109.6202455283641,37.33810185225658],[-109.6219360785521,37.3358796298357],[-109.61764037525734,37.33292059856781],[-109.61829729381147,37.32986111091702],[-109.62037516050984,37.32828703681179],[-109.62242498185965,37.32421296283563],[-109.62089346475958,37.32125000012789],[-109.61745921830313,37.32041666674022],[-109.6174537037992,37.31706115174399],[-109.61376724705008,37.31710058167581],[-109.6175944787645,37.31333522057518],[-109.62172940963087,37.31208333392185],[-109.6235466005876,37.30884259307495],[-109.62233295422318,37.30516704357174],[-109.622453704111,37.29823958176751],[-109.62127306892164,37.2974537041583],[-109.62179770335128,37.29310185236323],[-109.62428339860027,37.29252413685914],[-109.62667331157576,37.287824074291095],[-109.62594082276043,37.28513888866647],[-109.63020613944167,37.28178021514528],[-109.63037040110014,37.273178764428],[-109.63944274425498,37.27317667441408],[-109.63941921159547,37.25866097234926],[-109.64664007258787,37.258656156603],[-109.64663078995748,37.24151782045453],[-109.65077140661296,37.2391016090056],[-109.65797620686972,37.23732387581992],[-109.65998247377193,37.23788487524517],[-109.66488500680401,37.23583187590073],[-109.67014007349212,37.231810609003126],[-109.67200967363169,37.22868480889716],[-109.67469607376779,37.228333609077396],[-109.67758947403821,37.22294420845405],[-109.68700167373022,37.218494675385344],[-109.69573320632183,37.218687075813826],[-109.70420307295556,37.21580200912607],[-109.7068822071508,37.21574120920594],[-109.71288540634515,37.21326240902824],[-109.71435947342205,37.2053064753917],[-109.71581527329813,37.204350209170904],[-109.71672680658884,37.19900960870704],[-109.72123843241243,37.19710565719421],[-109.72817926847038,37.197102171806925],[-109.7281761328791,37.200725910813325],[-109.72364568247887,37.20072815722746],[-109.72363481354381,37.215212530808856],[-109.71910591539073,37.21520794511183],[-109.7190762355874,37.22968923486461],[-109.72814956243265,37.22969001890023],[-109.72814856610766,37.23330920194247],[-109.73719741951732,37.23329282038138],[-109.73719683074138,37.24777702680785],[-109.723613602216,37.24778821214527],[-109.72361370787227,37.24416780566764],[-109.71455007428831,37.24416988306038],[-109.71454743160848,37.24054981134423],[-109.71001439194858,37.240550307184044],[-109.71001822877354,37.24417093468556],[-109.7054949124899,37.244175127420846],[-109.70549933044065,37.251413846011204],[-109.70097417887588,37.25141581616734],[-109.7009754074995,37.255033809679574],[-109.69192321325866,37.25503541827303],[-109.69192260713514,37.25865161035791],[-109.68924631451105,37.25865062157217],[-109.68926937224948,37.282898550556894],[-109.69529585748701,37.2849626998771],[-109.69853168214344,37.283795299321575],[-109.72899876962497,37.26410471490799],[-109.7330356629359,37.261891271383824],[-109.74081060436923,37.258640667096074],[-109.74809808517033,37.25863735359252],[-109.74810989864554,37.274091261313444],[-109.74334314114641,37.274824625642914],[-109.74243280439067,37.277083333420414],[-109.73800209543495,37.28008102981853],[-109.72998504393348,37.28014039157828],[-109.73000673939487,37.316631117746255],[-109.72364008903168,37.31920622836801],[-109.72040835278807,37.32152146760735],[-109.71955220689833,37.32367492235129],[-109.71649825524581,37.32598899123514],[-109.71313079144699,37.327062279573],[-109.70811152518726,37.32991147121224],[-109.70034265710233,37.33124304886389],[-109.69613055835688,37.334982697051096],[-109.69386231924163,37.33572733829106],[-109.69385619986497,37.351664515539866],[-109.69783405485734,37.35386940159431],[-109.70731724859833,37.357637213384905],[-109.71363927994041,37.36282822183533],[-109.71913274424875,37.3684239748656],[-109.72318515250932,37.36932778811627],[-109.72520180214052,37.372850636066175],[-109.72751087989234,37.37455272931282],[-109.74838200076807,37.374611371943224],[-109.74838860192068,37.381454397727836],[-109.74385899942813,37.38105376606841],[-109.74359498581462,37.37713534783928],[-109.74037871334546,37.37507466582599],[-109.7398973742076,37.378939215428694],[-109.73098031406128,37.37943293680965],[-109.72655308441566,37.37833325349884],[-109.72018896679863,37.379699130396084],[-109.71033868814376,37.37788774828542],[-109.70268111257118,37.380515759927924],[-109.69520162334541,37.38212609284132],[-109.69270393788291,37.38157691733913],[-109.69054527050976,37.37902150032317],[-109.68242470283796,37.38250906488466],[-109.67821876098603,37.38573394054537],[-109.67787923824181,37.387442618062366],[-109.66641531519127,37.38415042618412],[-109.66308876568256,37.38515584326588],[-109.6569713976614,37.38546700759096],[-109.65694057870354,37.39158639349681],[-109.65607421969771,37.398906863468966],[-109.65724062500814,37.40650648612827],[-109.6592731777015,37.410670288886216],[-109.65757588556987,37.41804156606475],[-109.69392037931003,37.418040902944206],[-109.69388639569529,37.45792285267734],[-109.71201447997122,37.457922341847535],[-109.71200104629462,37.46154624335524],[-109.72569397627079,37.46154710018786],[-109.72558671702757,37.47595626974346],[-109.73013345980989,37.475952099044086],[-109.73013667680462,37.494095751783455],[-109.76598690991615,37.49416327876065],[-109.76595846774875,37.51959668163234],[-109.78415375445988,37.51953695673236],[-109.78418368736564,37.546282983959564],[-109.79500287240938,37.54848100152048],[-109.79994162803999,37.547215026978144],[-109.80539257594548,37.54791846959954],[-109.80932746618367,37.54714154989476],[-109.81226439426695,37.54891473962804],[-109.81492985870307,37.55704829273549],[-109.81449419272997,37.56281920742421],[-109.83485035240447,37.56275879167485],[-109.84079746556702,37.5598855359428],[-109.85052728049195,37.56090736867006],[-109.85228758449914,37.5624927631919],[-109.85839607945684,37.56387239420564],[-109.85906447951818,37.562983506844475],[-109.87484407203371,37.56298324333581],[-109.87482233020503,37.5720521665517],[-109.89486472420714,37.586396484374326],[-109.9006756482891,37.58693560898049],[-109.91416431539974,37.58213793711684],[-109.91495822592071,37.58708038070565],[-109.91858109980892,37.59044944529327],[-109.91842058220169,37.596980020217295],[-109.91741841301055,37.597891551157815],[-109.91769539617124,37.60249352453825],[-109.91440189766018,37.602811425542775],[-109.91140599535355,37.60170921056796],[-109.89843492992858,37.60491474679472],[-109.89608583922113,37.60496322656285],[-109.88998154835555,37.60853980190963],[-109.88631157317349,37.60921988448259],[-109.88412632049665,37.61118173289876],[-109.87843480480056,37.61174606220468],[-109.87478392813848,37.613639052167244],[-109.87478027230772,37.620488777247395],[-109.89300277150801,37.62046217120871],[-109.89298843271351,37.64940375316489],[-109.85729275453538,37.64942445700135],[-109.85494046212331,37.64858042266782],[-109.84713460501567,37.64952836730387],[-109.84302166671272,37.649048821892215],[-109.8398005468803,37.651685448445754],[-109.83736473093018,37.655638055335665],[-109.83461349450452,37.65773276132332],[-109.83313694107794,37.66062425333755],[-109.82842979062191,37.665380429379695],[-109.81967100887832,37.671339461394126],[-109.8150628909736,37.67340742418065],[-109.80511092444625,37.675480442443614],[-109.80223704827864,37.67420748123324],[-109.79305121849433,37.677959359817876],[-109.7807444066578,37.681447795270095],[-109.77221824979655,37.68197340023895]]]},"properties":{"NLCS_ID":"NLCS000851","NLCS_NAME":"Bears Ears - Shash Jáa Unit","CASEFILE_NO":"UNK","NLCS_TYPE":"National Monument","ADMIN_ST":"UT","GlobalID":"{AAB2AD31-19C5-4C01-9940-2A9578973907}","Shape_Length":227741.96924504917,"Shape_Area":574091016.8005579}},
{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-109.67162707138284,38.17805785498213],[-109.66885107581766,38.17696082895353],[-109.66212840640425,38.171813833773214],[-109.65056659961098,38.16495844714411],[-109.6397451281328,38.16216445718961],[-109.63638343906348,38.160303826461885],[-109.62783215674493,38.1524000568573],[-109.62073802593869,38.15025266373175],[-109.61635371070336,38.14755297273912],[-109.61156317222665,38.14136640327513],[-109.55977968145405,38.14140695858679],[-109.55978951292981,38.12938194514731],[-109.55310803278213,38.12582219049739],[-109.55343613867358,38.12277027323299],[-109.5499050215439,38.1181164197726],[-109.55037138999802,38.11593362710597],[-109.54100210343202,38.10828745189182],[-109.53901619083022,38.10771336741418],[-109.53360826670645,38.10128952313991],[-109.53304454504676,38.09905910747619],[-109.5298665486732,38.09544094882741],[-109.53179566059933,38.090096786426514],[-109.52938737644416,38.08686224793732],[-109.52379257491033,38.08511840379365],[-109.51988562204532,38.08047295890055],[-109.51982396295827,38.07307519917629],[-109.51593155314778,38.06920880412778],[-109.51423960347557,38.064480246522024],[-109.50747854447512,38.059257679688436],[-109.50389610083863,38.05272144108591],[-109.50157339566996,38.051129242729104],[-109.50128413835873,38.04411177828064],[-109.49851988215299,38.04075249517141],[-109.49908400768871,38.028342421111276],[-109.49598615946476,38.025035468736206],[-109.4953054756181,38.02076910210317],[-109.49079226640728,38.01654569863885],[-109.48919340924934,38.012928381278364],[-109.48959558869075,38.00937413497761],[-109.48626270645042,38.007730312037985],[-109.48329570575744,38.00390307910724],[-109.47814334979964,38.00163488974733],[-109.47767202987072,37.99995517876634],[-109.47997031749301,37.99692939241939],[-109.47918450590345,37.99481634810997],[-109.4828349039595,37.9896989760172],[-109.48572189585111,37.98357742263386],[-109.48871653743798,37.979599740972205],[-109.49073254860087,37.97355565229497],[-109.49221736769807,37.97176883159683],[-109.49474671281511,37.95992582058545],[-109.61854964252151,37.95993377163179],[-109.61852485800605,37.94543839683831],[-109.62766000352671,37.94543630781759],[-109.6276516665531,37.93818907055234],[-109.63678159797233,37.93818194236385],[-109.63677110854964,37.930933623745695],[-109.75838249946501,37.930882685929916],[-109.75818250704047,37.93587269447079],[-109.75485223267187,37.93820088789279],[-109.74983071248617,37.936793393105766],[-109.74888878215704,37.93521335858517],[-109.74528382341077,37.93576013879153],[-109.7435043317671,37.94004629616286],[-109.73875000052922,37.94239674303463],[-109.73647653129231,37.93921296298436],[-109.73087963019849,37.93767906456089],[-109.72254629589773,37.943478540898525],[-109.71918717772867,37.94312763895489],[-109.71220337201083,37.945814479947146],[-109.712175925748,37.95131236325718],[-109.70745370410108,37.95000886714092],[-109.70508347352366,37.950916809578565],[-109.704282627562,37.95395811315827],[-109.70727146625309,37.95671177226572],[-109.70989000213741,37.961011647640326],[-109.71856560751141,37.96800303781973],[-109.71805994853524,37.97063448739451],[-109.71922690081442,37.973842379444456],[-109.72432263195851,37.97873020782639],[-109.72335867363384,37.98061480167806],[-109.71985370327462,37.980000467312934],[-109.71599347056143,37.97549121069139],[-109.71592979463111,37.97161281767057],[-109.71236243307484,37.96978423557222],[-109.71048797396837,37.96618089934952],[-109.70703910256557,37.96476415325031],[-109.70158535867847,37.96599541385467],[-109.6957637075567,37.96808879983151],[-109.68913710384216,37.96482594114818],[-109.6817540067326,37.966465432792106],[-109.67975591601979,37.9649902746611],[-109.6738785575245,37.965654380446146],[-109.66938965365802,37.96423643603917],[-109.66811265999823,37.96497227522559],[-109.66809745973042,37.96902643083599],[-109.67384944903955,37.97131259240677],[-109.67452212689953,37.97306506545717],[-109.67330596345576,37.9794372849571],[-109.67378393700095,37.98306849869031],[-109.6721864027125,37.98752896775424],[-109.6722410321223,37.99050087950325],[-109.6638928752962,37.99258991141701],[-109.66388642030795,38.01789842135714],[-109.68218200354718,38.01789966203867],[-109.6821884397456,38.04711827380045],[-109.68204217599953,38.06131943495664],[-109.68204213844555,38.09030890882031],[-109.68231221060496,38.10487420402759],[-109.68233769329882,38.126871458218844],[-109.70651384600228,38.1268690406457],[-109.70652975353607,38.17034954633353],[-109.69331566444706,38.17362114849593],[-109.6869271242262,38.17309509237904],[-109.6792863308247,38.17660174537986],[-109.67162707138284,38.17805785498213]]]},"properties":{"NLCS_ID":"NLCS000851","NLCS_NAME":"Bears Ears - Indian Creek Unit","CASEFILE_NO":"UNK","NLCS_TYPE":"National Monument","ADMIN_ST":"UT","GlobalID":"{589B432E-AC46-42B8-AC88-A63F506DA5A2}","Shape_Length":112787.11278199426,"Shape_Area":349839726.2289047}},
{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-109.80232537865791,37.43968128320019],[-109.78421531872513,37.43968987580659],[-109.78421967546542,37.43245234498379],[-109.80236455311224,37.43244590799373],[-109.80232537865791,37.43968128320019]]]},"properties":{"NLCS_ID":"NLCS000851","NLCS_NAME":"Bears Ears - Shash Jáa Unit","CASEFILE_NO":"UNK","NLCS_TYPE":"National Monument","ADMIN_ST":"UT","GlobalID":"{00C1F7FF-3C43-4CEC-830D-4BC84E713446}","Shape_Length":4813.635926209462,"Shape_Area":1287862.9542339537}}
]}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Obama's Bears Ears vs. Trump's Replacement.">
<title>Obama's Bears Ears vs. Trump's Replacement</title>
<script src="https://code.jquery.com/jquery-2.2.4.min.js"
integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
crossorigin="anonymous"></script>
<!-- Load Leaflet from CDN -->
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.2.0/dist/leaflet.css"
integrity="sha512-M2wvCLH6DSRazYeZRIm1JnYyh22purTM+FDB5CsyxtQJYeKq83arPe5wgbNmcFXGqiSH2XR8dT/fJISVA1r/zQ=="
crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.2.0/dist/leaflet.js"
integrity="sha512-lInM/apFSqyy1o6s89K4iQUKg6ppXEgsVxT35HbzUupEVRh2Eu9Wdl4tHj7dZO0s1uvplcYGmt3498TtHq+log=="
crossorigin=""></script>
<!-- Load Esri Leaflet from CDN -->
<script src="https://unpkg.com/esri-leaflet@2.1.1/dist/esri-leaflet.js"
integrity="sha512-ECQqaYZke9cSdqlFG08zSkudgrdF6I1d8ViSa7I3VIszJyVqw4ng1G8sehEXlumdMnFYfzY0tMgdQa4WCs9IUw=="
crossorigin=""></script>
<!-- load the latest release from the cdn automatically -->
<script src="https://unpkg.com/esri-leaflet-vector"></script>
<!-- Map funcitons -->
<script src="map_functions.js"></script>
<script>
var key_field = 'ZCTA5CE10'
//alert('key_field: '+key_field)
var display_property = 'RebatesTtl'
var max_value = 0;
var min_value = 0;
var hue_blue = ['#d1e5f0', '#92c5de', '#4393c3', '#2166ac']
//var hue_red = ['#fddbc7', '#f4a582', '#d6604d', '#b2182b']
//var hue_red = ['#b2182b', '#d6604d', '#f4a582', '#fddbc7']
//var map_hues = ['#b2182b', '#d6604d', '#f4a582', '#fddbc7', '#d1e5f0', '#92c5de', '#4393c3', '#2166ac']
var map_hues = hue_blue
var nuteral_color = '#f7f7f7'
var positive_colors = hue_blue
//var negative_colors = hue_red
</script>
<link rel="stylesheet" id="map-style" href="map_style.css" type="text/css" media="all" />
</head>
<body>
<div id="layout">
<!-- Menu toggle -->
<a href="#menu" id="menuLink" class="menu-link">
<!-- Hamburger icon -->
<span></span>
</a>
<div id="main">
<div class="header">
<h1>Obama's Bears Ears</h1>
</div>
<div class="content">
<div id="mapid_1"></div>
</div> <!-- /content -->
</div> <!-- /main -->
<script>
//alert(max_value);
/*
1 44 104 208 2957
-1376 -268 -153 -70 -1
*/
function returnBreakdowns(){
return [0, mapRound(0.25*max_value), mapRound(0.5*max_value), mapRound(0.75*max_value)]
//return [mapRound(0.75*max_value), mapRound(0.5*max_value), mapRound(0.25*max_value), 0,
// mapRound(0.25*min_value), mapRound(0.5*min_value), mapRound(0.75*min_value), mapRound(min_value)]
//return [208, 104, 44, 0, -70, -153, -268, -1376]
}
//var zipcode_map = L.map('mapid_1').setView([40.0434, -75.7298], 10);
// 40.233845, and the longitude is -111.658531
// -110.029070528837423, 37.57
var zipcode_map = L.map('mapid_1').setView([37.77, -110.02], 9);
var layer = L.esri.Vector.basemap('ModernAntique').addTo(zipcode_map);
// control that shows state info on hover
var info = L.control();
info.onAdd = function (map) {
this._div = L.DomUtil.create('div', 'info');
this.update();
return this._div;
};
info.update = function (properties) {
this._div.innerHTML = '<h4>Electric Cars:</h4>' + (properties ?
'<b>' + properties['Zip'] + ' has ' + properties[display_property] + ' electric cars</b><br />'
: 'Hover over a zipcode'); };
//info.addTo(zipcode_map);
var geojson;
zipcode_map.attributionControl.addAttribution(' | map by Chris A. Williams for Enact Development');
var legend = L.control({position: 'bottomright'});
legend.onAdd = function (map) {
if (min_value > 0) {
min_value = 0;
}
display_grades = [0, mapRound(0.25*max_value), mapRound(0.5*max_value), mapRound(0.75*max_value), mapRound(max_value)]
display_grades.reverse();
if (min_value < 0) {
display_grades = returnBreakdowns()
//alert(display_grades)
var div = L.DomUtil.create('div', 'info legend')
var grades = display_grades
var labels = []
var from, to;
for (var i = 1; i < grades.length; i++) {
to = Number(grades[i]);
from = Number(grades[i - 1]);
if ( from > 0 )
{
x = from
from = to
to = x
}
labels.push(
'<i style="background:' + getColor(to) + '"></i> ' +
//from.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + ((i + 1) < grades.length ? '&ndash;' + to.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") : ' <!--or less-->'));
from.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + '&ndash;' + to.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")
);
if ( from == 0 && to > 0) {
labels.push(
'<i style="background:' + getColor(0) + '"></i> ' + from.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")
);
}
}
}
else {
var div = L.DomUtil.create('div', 'info legend'),
//grades = [0, mapRound(0.05*max_value), mapRound(0.15*max_value), mapRound(0.30*max_value), mapRound(0.45*max_value), mapRound(0.60*max_value), mapRound(0.75*max_value), mapRound(0.90*max_value)],
grades = display_grades,
labels = [],
from, to;
for (var i = 0; i < grades.length; i++) {
from = grades[i];
to = grades[i + 1];
if ( from == 0 ) {
labels.push(
'<i style="background:' + getColor(from) + '"></i> ' + from.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")
);
}
labels.push(
'<i style="background:' + getColor(from) + '"></i> ' +
from.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + (to ? '&ndash;' + to.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") : '+'));
}
}
div.innerHTML = labels.join('<br>');
return div;
};
</script>
<script>
$(document).ready(function() {
$.getJSON( "bears_ears_obama_cut_small.json", function() {
//console.log( "success" );
})
.done(function( geojson_data ) {
//console.log( "second success" );
//console.log(geojson_data)
geojson = L.geoJson(geojson_data, {
style: {
weight: 4,
opacity: 1,
color: 'black',
dashArray: '3',
fillColor: '#000000'
},
onEachFeature: onEachFeature
}).addTo(zipcode_map);
//legend.addTo(zipcode_map);
})
.fail(function() {
console.log( "error" );
})
.always(function() {
//console.log( "getJSON().always()" );
});
$.getJSON( "bears_ears_trump_cut_small.json", function() {
//console.log( "success" );
})
.done(function( trump_data ) {
//console.log( "second success" );
//console.log(geojson_data)
geojson = L.geoJson(trump_data, {
style: style,
onEachFeature: onEachFeature
}).addTo(zipcode_map);
//legend.addTo(zipcode_map);
})
.fail(function() {
console.log( "error" );
})
.always(function() {
//console.log( "getJSON().always()" );
});
} );
</script>
</div>
</body>
</html>
function mapRound(x){
return Number(Math.round(Number(x) * 100) / 100).toFixed(2)
}
function getColor(d) {
d = Number(d)
if (min_value > 0) {
min_value = 0;
}
breakdowns = returnBreakdowns()
if ( d == 0 ) {
return nuteral_color
}
for (i = 0; i < breakdowns.length; i++) {
if (d < 0 && d >= breakdowns[i]) {
//console.log('will be returning: '+map_hues[i]+' for: '+d+'. max_value: '+max_value+', min_value: '+min_value)
return map_hues[i]
} else if (d > breakdowns[i]) {
//console.log('will be returning: '+map_hues[i]+' for: '+d+'. max_value: '+max_value+', min_value: '+min_value)
return map_hues[i]
}
}
return map_hues[map_hues.length - 1]
}
function style(feature) {
return {
weight: 2,
opacity: 1,
color: 'white',
dashArray: '3',
fillOpacity: 0.7,
fillColor: getColor(feature.properties[display_property])
};
}
function highlightFeature(e) {
var layer = e.target;
layer.setStyle({
weight: 5,
color: '#666',
dashArray: '',
fillOpacity: 0.7
});
if (!L.Browser.ie && !L.Browser.opera && !L.Browser.edge) {
layer.bringToFront();
}
info.update(layer.feature.properties);
}
function resetHighlight(e) {
geojson.resetStyle(e.target);
info.update();
}
/*
function zoomToFeature(e) {
zipcode_map.fitBounds(e.target.getBounds());
}
*/
function onEachFeature(feature, layer) {
layer.on({
mouseover: highlightFeature,
mouseout: resetHighlight,
//click: zoomToFeature
});
}
#mapid_1 {
width: 800px;
height:800px;
}
#mapid_2 {
width: 800px;
height:800px;
}
.info {
padding: 6px 8px;
font: 14px/16px Arial, Helvetica, sans-serif;
background: white;
background: rgba(255,255,255,0.8);
box-shadow: 0 0 15px rgba(0,0,0,0.2);
border-radius: 5px;
}
.info h4 {
margin: 0 0 5px;
color: #777;
}
.legend {
text-align: left;
line-height: 18px;
color: #555;
}
.legend i {
width: 18px;
height: 18px;
float: left;
margin-right: 8px;
opacity: 0.7;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment