function ResizeMap(){var n=$(document.getElementById("ContinentalMap"));n.height(n.width()*.56);map1.resize();map1.fitBounds(ContinentalMapFitBoundsCords);n=$(document.getElementById("AlaskaMap"));n.height(n.width()*.9);map2.resize();map2.fitBounds(AlaskaMapFitBoundsCords);n=$(document.getElementById("HawaiiMap"));n.height(n.width()*.56);map3.resize();map3.fitBounds(HawaiiMapFitBoundsCords);n=$(document.getElementById("AntillesMap"));n.height(n.width()*.77);map4.resize();map4.fitBounds(AntillesMapFitBoundsCords)}function GetCenterCoords(n){var t=(n[0][0]+n[1][0])/2,i=(n[0][1]+n[1][1])/2;return[t,i]}function BuildMap(n,t,i){try{jQuery("#loading").removeClass("hidden");ResizeMap();var u=$.getJSON(n).done(function(n){console.log("%cMessage: Loading State Geometry - Success","color:green;");GetOutageInfo(n,t,i)}).fail(function(n,t,i){console.log("%cError: Loading State Geometry - Error: "+n.status+" - "+i,"color:red;");MapError("Failed to Load Geometry Data","Request Error Code: "+n.status+" - "+i)})}catch(r){console.log("%cError: Function BuildMap. Message: "+r.message,"color:red;");MapError("Failed to Load Geometry Data",r.message)}}function GetOutageInfo(n,t,i){try{var u=$.getJSON(t).done(function(t){console.log("%cMessage: Loading State Info - Success","color:green;");DrawMap(n,t,i)}).fail(function(n,t,i){console.log("%cError: Loading State Info - Error: "+n.status+" - "+i,"color:red;");MapError("Failed to Load Outage Data","Request Error Code: "+n.status+" - "+i)})}catch(r){console.log("%cError: Function GetOutageInfo. Message: "+r.message,"color:red;");MapError("Failed to Load Outage Data",r.message)}}function DrawMap(n,t,i){try{var r=[],u=[],f=[],e=[];$.each(n.StateGeometry.Areas,function(n,i){var s="#3F3F3F",h=0,o=0;$.each(t.WebStateRecord,function(n,t){t.StateName==i.NAME&&(h=t.CustomerCount,o=t.OutageCount,o<1e4?s="#004FA2":o>=1e4&&o<5e4?s="#A29F00":o>=5e4&&o<1e5?s="#A05B00":o>=1e5&&(s="#A21300"),h==0&&(s="#3F3F3F"))});map=null;i.NAME=="Alaska"?(map=map2,u.push(i.NAME)):i.NAME=="Hawaii"?(map=map3,f.push(i.NAME)):i.NAME=="Virgin Islands"?(map=map4,e.push(i.NAME)):(map=map1,r.push(i.NAME));try{map.addLayer({id:i.NAME,type:"fill",source:{type:"geojson",data:{type:"FeatureCollection",features:[{type:"Feature",properties:{Name:i.NAME,OutageCount:o,CustomerCount:h},geometry:i.geometry}]}},layout:{},paint:{"fill-color":s,"fill-opacity":1,"fill-outline-color":"#000"}})}catch(c){console.log("%cError: Function map.addLayer | For: "+i.NAME+" | Message: "+c.message,"color:red;")}});map1.on("click",function(n){var u=map1.queryRenderedFeatures(n.point,{layers:r}),f,t;u.length&&(f=u[0],t=f.properties.Name.toLowerCase(),t!=null&&(document.location.href="/area/"+i+"/"+t))});map2.on("click",function(n){var r=map2.queryRenderedFeatures(n.point,{layers:u}),f,t;r.length&&(f=r[0],t=f.properties.Name.toLowerCase(),t!=null&&(document.location.href="/area/"+i+"/"+t))});map3.on("click",function(n){var r=map3.queryRenderedFeatures(n.point,{layers:f}),u,t;r.length&&(u=r[0],t=u.properties.Name.toLowerCase(),t!=null&&(document.location.href="/area/"+i+"/"+t))});map4.on("click",function(n){var r=map4.queryRenderedFeatures(n.point,{layers:e}),u,t;r.length&&(u=r[0],t=u.properties.Name.toLowerCase(),t!=null&&(document.location.href="/area/"+i+"/"+t))});map1.on("mousemove",function(n){var t=map1.queryRenderedFeatures(n.point,{layers:r});map1.getCanvas().style.cursor=t.length?"pointer":"";t.length!=0?(document.getElementById("StateName").innerHTML="State Name: "+t[0].layer.id,document.getElementById("StateServed").innerHTML="Customers Tracked: "+t[0].properties.CustomerCount.toLocaleString(),document.getElementById("StateOut").innerHTML="Customers Out: "+t[0].properties.OutageCount.toLocaleString(),document.getElementById("mappopup").style.left=n.originalEvent.clientX+"px",document.getElementById("mappopup").style.top=n.originalEvent.clientY+"px",document.getElementById("mappopup").style.display="block",document.getElementById("mappopup").style.marginLeft=document.documentElement.clientWidth/2>n.originalEvent.clientX?"20px":"-"+(document.getElementById("mappopup").clientWidth+10)+"px",document.getElementById("mappopup").style.marginTop=document.documentElement.clientHeight/4*3>n.originalEvent.clientY?"-10px":"-40px"):(document.getElementById("StateName").innerHTML="",document.getElementById("StateServed").innerHTML="",document.getElementById("StateOut").innerHTML="",document.getElementById("mappopup").style.display="none")});map2.on("mousemove",function(n){var t=map2.queryRenderedFeatures(n.point,{layers:u});map2.getCanvas().style.cursor=t.length?"pointer":"";t.length!=0?(document.getElementById("StateName").innerHTML="State Name: "+t[0].layer.id,document.getElementById("StateServed").innerHTML="Customers Tracked: "+t[0].properties.CustomerCount.toLocaleString(),document.getElementById("StateOut").innerHTML="Customers Out: "+t[0].properties.OutageCount.toLocaleString(),document.getElementById("mappopup").style.left=n.originalEvent.clientX+"px",document.getElementById("mappopup").style.top=n.originalEvent.clientY+"px",document.getElementById("mappopup").style.display="block",document.getElementById("mappopup").style.marginLeft=document.documentElement.clientWidth/2>n.originalEvent.clientX?"20px":"-"+(document.getElementById("mappopup").clientWidth+10)+"px",document.getElementById("mappopup").style.marginTop=document.documentElement.clientHeight/4*3>n.originalEvent.clientY?"-10px":"-40px"):(document.getElementById("StateName").innerHTML="",document.getElementById("StateServed").innerHTML="",document.getElementById("StateOut").innerHTML="",document.getElementById("mappopup").style.display="none")});map3.on("mousemove",function(n){var t=map3.queryRenderedFeatures(n.point,{layers:f});map3.getCanvas().style.cursor=t.length?"pointer":"";t.length!=0?(document.getElementById("StateName").innerHTML="State Name: "+t[0].layer.id,document.getElementById("StateServed").innerHTML="Customers Tracked: "+t[0].properties.CustomerCount.toLocaleString(),document.getElementById("StateOut").innerHTML="Customers Out: "+t[0].properties.OutageCount.toLocaleString(),document.getElementById("mappopup").style.left=n.originalEvent.clientX+"px",document.getElementById("mappopup").style.top=n.originalEvent.clientY+"px",document.getElementById("mappopup").style.display="block",document.getElementById("mappopup").style.marginLeft=document.documentElement.clientWidth/2>n.originalEvent.clientX?"20px":"-"+(document.getElementById("mappopup").clientWidth+10)+"px",document.getElementById("mappopup").style.marginTop=document.documentElement.clientHeight/4*3>n.originalEvent.clientY?"-10px":"-40px"):(document.getElementById("StateName").innerHTML="",document.getElementById("StateServed").innerHTML="",document.getElementById("StateOut").innerHTML="",document.getElementById("mappopup").style.display="none")});map4.on("mousemove",function(n){var t=map4.queryRenderedFeatures(n.point,{layers:e});map4.getCanvas().style.cursor=t.length?"pointer":"";t.length!=0?(document.getElementById("StateName").innerHTML="State Name: "+t[0].layer.id,document.getElementById("StateServed").innerHTML="Customers Tracked: "+t[0].properties.CustomerCount.toLocaleString(),document.getElementById("StateOut").innerHTML="Customers Out: "+t[0].properties.OutageCount.toLocaleString(),document.getElementById("mappopup").style.left=n.originalEvent.clientX+"px",document.getElementById("mappopup").style.top=n.originalEvent.clientY+"px",document.getElementById("mappopup").style.display="block",document.getElementById("mappopup").style.marginLeft=document.documentElement.clientWidth/2>n.originalEvent.clientX?"20px":"-"+(document.getElementById("mappopup").clientWidth+10)+"px",document.getElementById("mappopup").style.marginTop=document.documentElement.clientHeight/4*3>n.originalEvent.clientY?"-10px":"-40px"):(document.getElementById("StateName").innerHTML="",document.getElementById("StateServed").innerHTML="",document.getElementById("StateOut").innerHTML="",document.getElementById("mappopup").style.display="none")});ResizeMap();jQuery("#loading").addClass("hidden");jQuery("#MapContainer1").removeClass("hidden");jQuery("#MapContainer2").removeClass("hidden");jQuery("#MapContainer3").removeClass("hidden")}catch(o){console.log("%cError: Function DrawMap. Message: "+o.message,"color:red;");MapError("Failed to Draw the Map",o.message)}}function MapError(n,t){jQuery("#loading").addClass("hidden");document.getElementById("ContinentalMap").outerHTML='<div class="AlertBox4" style="z-index: 1000">Outage Map Error - '+n+" <br /> "+t+"  <br />On desktop try pressing CTRL+Shift+R at the same time<br />On mobile clear your all time browser cache<br />If the error persists you can reach out to info@poweroutage.us<\/div> "}var map1=new mapboxgl.Map({container:"ContinentalMap",center:GetCenterCoords(ContinentalMapFitBoundsCords),zoom:3.8,style:{version:8,name:"Empty",metadata:{"mapbox:autocomposite":!0},sources:{},layers:[{id:"background",type:"background",paint:{"background-color":"rgba(0,0,0,0)"}}]},interactive:!1,trackResize:!0}),map2,map3,map4;map1.scrollZoom.disable();map2=new mapboxgl.Map({container:"AlaskaMap",center:GetCenterCoords(AlaskaMapFitBoundsCords),zoom:2.15,style:{version:8,name:"Empty",metadata:{"mapbox:autocomposite":!0},sources:{},layers:[{id:"background",type:"background",paint:{"background-color":"rgba(0,0,0,0)"}}]},interactive:!1,trackResize:!0});map2.scrollZoom.disable();map3=new mapboxgl.Map({container:"HawaiiMap",center:GetCenterCoords(HawaiiMapFitBoundsCords),zoom:4.2,style:{version:8,name:"Empty",metadata:{"mapbox:autocomposite":!0},sources:{},layers:[{id:"background",type:"background",paint:{"background-color":"rgba(0,0,0,0)"}}]},interactive:!1,trackResize:!0});map3.scrollZoom.disable();map4=new mapboxgl.Map({container:"AntillesMap",center:GetCenterCoords(AntillesMapFitBoundsCords),zoom:5.8,style:{version:8,name:"Empty",metadata:{"mapbox:autocomposite":!0},sources:{},layers:[{id:"background",type:"background",paint:{"background-color":"rgba(0,0,0,0)"}}]},interactive:!1,trackResize:!0});map4.scrollZoom.disable();window.onresize=ResizeMap