text: /*
   * @title WET-BOEW Geomap
   * @overview Displays a dynamic map over which information from additional sources can be overlaid.
   * @license wet-boew.github.io/wet-boew/License-en.html / wet-boew.github.io/wet-boew/Licence-fr.html
   * @author @pjackson28
   */
  !function(a,b,c,d){"use strict";var e,f,g,h="wb-geomap",i="."+h,j=d.doc,k=0,l=[],m=!1,n={overlays:[],tables:[],useScaleLine:!1,useMousePosition:!1,useLegend:!1,useMapControls:!0,useGeocoder:!1,useGeolocation:!1,useAOI:!1},o=function(b){var c,g,i=b.target,j=i.className.split(/\s+/),k={};/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&(m=!0),b.currentTarget===i&&(c=a(i),f||(e=d.i18n,f={add:e("add"),close:e("close"),colon:e("colon"),err:e("err"),hiddenLayer:e("geo-hdnlyr"),toggleLayer:e("geo-tgllyr"),labelSelect:e("geo-lblsel"),select:e("geo-sel"),zoomFeature:e("geo-zmfeat"),zoomin:e("geo-zmin"),zoomout:e("geo-zmout"),zoomworld:e("geo-zmwrld"),baseMapTitle:e("geo-bmapttl"),baseMapURL:e("geo-bmap-url"),baseMapMatrixSet:e("geo-bmap-matrix-set"),scaleline:e("geo-sclln"),mouseposition:e("geo-msepos"),access:e("geo-ally"),accessTitle:e("geo-allyttl"),attribLink:e("geo-attrlnk"),attribTitle:e("geo-attrttl"),ariaMap:e("geo-ariamap"),geoLocationURL:e("geo-locurl-geogratis"),geoCoderPlaceholder:e("geo-loc-placeholder"),geoCoderLabel:e("geo-loc-label"),aoiNorth:e("geo-aoi-north"),aoiEast:e("geo-aoi-east"),aoiSouth:e("geo-aoi-south"),aoiWest:e("geo-aoi-west"),aoiInstructions:e("geo-aoi-instructions"),aoiTitle:e("geo-aoi-title"),aoiBtnDraw:e("geo-aoi-btndraw"),aoiBtnClear:e("geo-aoi-btnclear"),aoiBtnClose:e("close"),geolocBtn:e("geo-geoloc-btn"),geolocFail:e("geo-geoloc-fail"),geolocUncapable:e("geo-geoloc-uncapable"),geoLgndGrphc:e("geo-lgnd-grphc"),dismiss:e("dismiss")}),g={useScaleLine:-1!==j.indexOf("scaleline")?!0:void 0,useMousePosition:-1!==j.indexOf("position")?!0:void 0,useLegend:-1!==j.indexOf("legend"),useMapControls:-1!==j.indexOf("static")?!1:!0,useGeocoder:-1!==j.indexOf("geocoder")?!0:!1,useGeolocation:-1!==j.indexOf("geolocation")?!0:!1,useAOI:-1!==j.indexOf("aoi")?!0:!1,useAOIOpen:-1!==j.indexOf("aoi-open")?!0:!1},a.extend(k,n,g,d.getData(c,h)),k.layersFile?a.ajax({url:k.layersFile,async:!0,dataType:"script",success:function(){k=a.extend(k,wet_boew_geomap),k&&k.basemap&&k.basemap.type&&"xyz"===k.basemap.type&&(k.basemap.type="osm"),i.geomap=new p({target:c,settings:k}),l.push(i.geomap)}}):(i.geomap=new p({target:c,settings:k}),l.push(i.geomap))),d.getMap=function(a){return J(a)},d.getLayer=function(a,b){return R(a,b)}},p=function(b){var c=b.target,d={};this.id=c.attr("id"),this.mapLayers=[],this.layerDiv=c.find(".wb-geomap-layers").attr("id","geomap-layers-"+this.id),this.legendDiv=c.find(".wb-geomap-legend").attr("id","geomap-legend-"+this.id),this.mapDiv=c.find(".wb-geomap-map").attr("id","geomap-map-"+this.id),this.settings=b.settings,this.settings.aspectRatio=this.settings.basemap&&this.settings.basemap.mapOptions&&void 0!==this.settings.basemap.mapOptions.aspectRatio?this.settings.basemap.mapOptions.aspectRatio:.8,this.map=I(this),this.legend=new r(this),d=this.addBasemap(),this.map.setView(new ol.View(d)),this.addMapLayers(),d.extent&&this.map.getView().fit(d.extent,this.map.getSize());var e=this.mapLayers;this.map.getLayersByName=function(a){var b,c,d=e.length,f={popup:{visible:function(){return!0}},geometry:{bounds:ol.proj.transform(this.getOverlays().getArray()[0].getPosition(),"EPSG:3978","EPSG:4326")}};for(b=0;b!==d;b+=1)if(c=e[b],c.id&&c.id===a)return[{features:[f]}]},this.loadControls(),this.accessibilize(),this.createPopup(),j.on("wb-ready.wb-geomap","#"+this.id,function(){a("#"+this.id).find(".geomap-progress").remove()})},q=function(b,c){var d=this,e=[];return this.map=b,this.settings=c,this.id=this.settings.tableId?this.settings.tableId:T(),this.layer=this.createOLLayer(),this.settings.accessible="undefined"==typeof this.settings.accessible?!0:this.settings.accessible,this.settings.visible="undefined"==typeof this.settings.visible?!0:this.settings.visible,this.settings.zoom="undefined"==typeof this.settings.zoom?!0:this.settings.zoom,this.settings.accessible&&this.map.layerDiv.append("<div class='panel panel-default'><div class='panel-heading'><div class='panel-title' role='heading'>"+this.settings.title+"</div></div><div class='panel-body'><div data-layer='"+this.id+"' class='geomap-table-wrapper' style='display:none;'></div></div></div>"),Object.defineProperty(d,"isVisible",{get:function(){return d.visibilityState},set:function(a){d.visibilityState=a,e.forEach(function(b){return b(a)})}}),d.layer?(this.observeVisibility=function(a){e.push(a)},this.observeVisibility(function(b){var c=a("div[ data-layer='"+d.id+"' ].geomap-table-wrapper");b?(c.fadeIn(),c.parent().find(".layer-msg").remove()):(c.fadeOut(),c.parent().append("<div class='layer-msg'><p>"+f.hiddenLayer+"</p></div>").fadeIn()),d.layer.setVisible(d.isVisible)}),0!==this.map.legendDiv.length&&this.addToLegend(),this.isVisible=this.settings.visible,this):null},r=function(b){return this.map=b,this.symbolMapArray=[],this.target=a("#"+b.id+".wb-geomap").find(".wb-geomap-legend"),this.target.attr("id","geomap-legend-"+b.id),this.target.empty(),this},s=function(a,b){var c;return a.getInteractions().forEach(function(a){a instanceof b&&(c=a)}),c},t=function(b,c,d,e,f){var g,h,i,j,k,l,m,n=d.getGeometry().getExtent(),o=ol.extent.getWidth(n),p=ol.extent.getHeight(n),q=a("#"+b);k=1,k||(k=Math.max(o/e||0,p/f||0)||1),c.setView(new ol.View({minResolution:k,maxResolution:k,projection:new ol.proj.Projection({code:"",units:"pixels"})})),m=Math.max(e,o/k),l=Math.max(f,p/k),j=ol.extent.getCenter(n),g=m*k/2,h=l*k/2,i=[j[0]-g,j[1]-h,j[0]+g,j[1]+h],q.width(Math.round(m)),q.height(Math.round(l)),c.updateSize(),c.getView().fit(i,c.getSize())},u=function(){var a=B(d.drawColours[k],.5),b=B(d.drawColours[k],1),c={fill:a,stroke:b,transparent:[0,0,0,0]};return k+=1,k===d.drawColours.length&&(k=0),c},v=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m=u();this.createStyleFunction=function(a,b){return e=a,b=b,f=e&&e.type?e.type:"default",function(a){return"rule"===f?new n(a,b):"symbol"===f?new o:"default"===f?new p(a,b):"unique"===f?new q(a,b):"select"===f?new r(a,b):void 0}};var n=function(f){for(var n,o,p=e.rule,q=p.length,r={EQUAL_TO:function(a,b){return String(a)===String(b[0])},GREATER_THAN:function(a,b){return a>b[0]},LESS_THAN:function(a,b){return a<b[0]},BETWEEN:function(a,b){return a>=b[0]&&a<=b[1]}},s=f&&f.getGeometry()?f.getGeometry().getType():"Polygon",t=0;t!==q;t+=1)if(n=p[t],o=n.filter,k=n.init.strokeDash?n.init.strokeDash:[1,0],l=n.init.strokeWidth?n.init.strokeWidth:1,h=n.init.fillOpacity?n.init.fillOpacity:n.init.graphicOpacity?n.init.graphicOpacity:.5,i=n.init.pointRadius?n.init.pointRadius:5,j=n.init.strokeColor?B(n.init.strokeColor,h):m.transparent,g=B(n.init.fillColor,h),d=n.init.graphicName?n.init.graphicName:null,a=n.init.externalGraphic?n.init.externalGraphic:null,b=n.init.graphicHeight?n.init.graphicHeight:25,c=n.init.graphicWidth?n.init.graphicWidth:25,r[o](f.attributes[n.field],n.value))switch(s){case"Polygon":return z({fill:new ol.style.Fill({color:g}),stroke:new ol.style.Stroke({color:j,width:l,lineDash:k})});case"Point":return d?w({symbol:d,fill:new ol.style.Fill({color:g}),stroke:new ol.style.Stroke({color:j,lineDash:k}),radius:i}):a?x({src:a,opacity:h,size:[c,b]}):y({radius:i,fill:new ol.style.Fill({color:g}),stroke:new ol.style.Stroke({color:j,width:l,lineDash:k})});case"LineString":return A({stroke:new ol.style.Stroke({color:j,width:l,lineDash:k})});default:return z({fill:new ol.style.Fill({color:g}),stroke:new ol.style.Stroke({color:j,width:l,lineDash:k})})}},o=function(){return h=e.init.fillOpacity?e.init.fillOpacity:e.init.graphicOpacity?e.init.graphicOpacity:1,i=e.init.pointRadius?e.init.pointRadius:5,j=e.init.strokeColor?B(e.init.strokeColor,h):m.transparent,g=B(e.init.fillColor,h),d=e.init.graphicName?e.init.graphicName:null,a=e.init.externalGraphic?e.init.externalGraphic:null,b=e.init.graphicHeight?e.init.graphicHeight:25,c=e.init.graphicWidth?e.init.graphicWidth:25,d?w({symbol:e.init.graphicName,fill:new ol.style.Fill({color:g}),stroke:new ol.style.Stroke({color:j,lineDash:k}),radius:i}):a?x({src:a,opacity:h,size:[c,b]}):y({radius:i,fill:new ol.style.Fill({color:g}),stroke:new ol.style.Stroke({color:j,width:l})})},p=function(){return h=e.fillOpacity?e.fillOpacity:e.graphicOpacity?e.graphicOpacity:1,g=e.fillColor?B(e.fillColor,h):m.transparent,j=e.strokeColor?B(e.strokeColor,h):m.transparent,l=e.strokeWidth?e.strokeWidth:1,k=e.strokeDash?e.strokeDash:[1,0],[new ol.style.Style({image:new ol.style.Circle({fill:new ol.style.Fill({color:g}),stroke:new ol.style.Stroke({color:j,width:l,lineDash:k}),radius:5}),fill:new ol.style.Fill({color:g}),stroke:new ol.style.Stroke({color:j,width:l,lineDash:k})})]},q=function(d,f){var n,o,p=e.field;for(n in e.init)switch(o=e.init[n],k=o.strokeDash?o.strokeDash:[1,0],l=o.strokeWidth?o.strokeWidth:1,h=o.fillOpacity?o.fillOpacity:o.graphicOpacity?o.graphicOpacity:.5,i=o.pointRadius?o.pointRadius:5,j=o.strokeColor?B(o.strokeColor,h):m.transparent,g=o.fillColor?B(o.fillColor,h):null,name=o.name?o.name:null,b=o.graphicHeight?o.graphicHeight:25,a=o.externalGraphic,c=o.graphicWidth?o.graphicWidth:25,f){case"Polygon":if(d.attributes&&d.attributes[p]===n)return z({fill:new ol.style.Fill({color:g}),stroke:new ol.style.Stroke({color:j,width:l,lineDash:k})});break;case"Point":if(a){if(d.attributes&&d.attributes[p]===n)return x({src:a,opacity:h,size:[c,b]})}else if(d.attributes&&d.attributes[p]===n)return y({radius:i,fill:new ol.style.Fill({color:g}),stroke:new ol.style.Stroke({color:j,width:l,lineDash:k})});break;case"LineString":if(d.attributes&&d.attributes[p]===n)return A({stroke:new ol.style.Stroke({color:j,width:l,lineDash:k})});break;default:if(d.attributes&&d.attributes[p]===n)return z({fill:new ol.style.Fill({color:g}),stroke:new ol.style.Stroke({color:j,width:l,lineDash:k})})}},r=function(d,f){switch(k=e.strokeDash?e.strokeDash:[1,0],l=e.strokeWidth?e.strokeWidth:1,h=e.fillOpacity?e.fillOpacity:e.graphicOpacity?e.graphicOpacity:.5,i=e.pointRadius?e.pointRadius:5,j=e.strokeColor?B(e.strokeColor,h):m.transparent,g=e.fillColor?B(e.fillColor,h):null,name=e.name?e.name:null,b=e.graphicHeight?e.graphicHeight:25,a=e.externalGraphic,c=e.graphicWidth?e.graphicWidth:25,f){case"Polygon":return z({fill:new ol.style.Fill({color:g}),stroke:new ol.style.Stroke({color:j,width:l,lineDash:k})});case"Point":return a?x({src:a,opacity:h,size:[c,b]}):y({radius:i,fill:new ol.style.Fill({color:g}),stroke:new ol.style.Stroke({color:j,width:l,lineDash:k})});case"LineString":return A({stroke:new ol.style.Stroke({color:j,width:l,lineDash:k})});default:return z({fill:new ol.style.Fill({color:g}),stroke:new ol.style.Stroke({color:j,width:l,lineDash:k})})}}},w=function(a){var b={square:[new ol.style.Style({image:new ol.style.RegularShape({fill:a.fill,stroke:a.stroke,points:4,radius:a.radius,angle:Math.PI/4})})],triangle:[new ol.style.Style({image:new ol.style.RegularShape({fill:a.fill,stroke:a.stroke,points:3,radius:a.radius,rotation:Math.PI/4,angle:0})})],star:[new ol.style.Style({image:new ol.style.RegularShape({fill:a.fill,stroke:a.stroke,points:5,radius:a.radius,radius2:.4*a.radius,angle:0})})],cross:[new ol.style.Style({image:new ol.style.RegularShape({fill:a.fill,stroke:a.stroke,points:4,radius:a.radius,radius2:0,angle:0})})],x:[new ol.style.Style({image:new ol.style.RegularShape({fill:a.fill,stroke:a.stroke,points:4,radius:a.radius,radius2:0,angle:Math.PI/4})})]};return b[a.symbol]},x=function(a){return[new ol.style.Style({image:new ol.style.Icon({opacity:a.opacity,src:a.src,size:a.size})})]},y=function(a){return[new ol.style.Style({image:new ol.style.Circle({radius:a.radius,fill:a.fill,stroke:a.stroke})})]},z=function(a){return[new ol.style.Style({fill:a.fill,stroke:a.stroke})]},A=function(a){return[new ol.style.Style({stroke:a.stroke})]},B=function(a,b){var c=(a+"").trim(),d=null,e=c.match(/^#?(([0-9a-zA-Z]{3}){1,3})$/),f=b?b:1;return e?(c=e[1],6===c.length?d=[parseInt(c.substring(0,2),16),parseInt(c.substring(2,4),16),parseInt(c.substring(4,6),16),f]:3===c.length&&(d=[parseInt(c.substring(0,1)+c.substring(0,1),16),parseInt(c.substring(1,2)+c.substring(1,2),16),parseInt(c.substring(2,3)+c.substring(2,3),16),f]),d):a},C=function(a,b){return"<td><label class='wb-inv' for='cb_"+b.getId()+"'>"+f.labelSelect+"</label><input type='checkbox' id='cb_"+b.getId()+"' class='geomap-cbx' data-map='"+a.map.id+"' data-layer='"+b.layerId+"' data-feature='"+b.getId()+"' /></td>"},D=function(a,b){return"<td class='text-right'><a href='javascript:;' data-map='"+a.map.id+"' data-layer='"+b.layerId+"' data-feature='"+b.getId()+"' class='btn btn-link geomap-zoomto' alt='"+f.zoomFeature+"' role='button'><span class='glyphicon glyphicon-zoom-in'></span></a></td>"},E=function(b,d,e){if(d){var f=e.getOverlays().getArray()[0],g=a(c.getElementById("popup-geomap-map-"+e.id)),h="",i=R(e,d.layerId);if(d&&d.attributes){var j,k,l=d.getGeometry(),m="Point"===l.getType()?l.getCoordinates():event.mapBrowserEvent.coordinate,n=d.attributes;if(i.popupsInfo){h+=i.popupsInfo.content;for(j in n)n.hasOwnProperty(j)&&(k=new RegExp("_"+j,"igm"),h=h.replace(k,n[j]))}else for(j in n)n.hasOwnProperty(j)&&(h+="<tr><th><strong>"+j+"</strong></th><td> "+n[j]+"</td></tr>");g.find(".popup-content").html("<h5>"+d.layerTitle+"</h5><table style='width:100%;'>"+h+"</table>"),f.setPosition(m)}else f.setPosition(void 0)}},F=function(a){var b,c={};for(b in a)a.hasOwnProperty(b)&&"type"!==b&&"caption"!==b&&"url"!==b&&"title"!==b&&(c[b]=a[b]);return c},G=function(b,c){var d,e={};for(d in b)b.hasOwnProperty(d)&&a.inArray(d,c)<0&&(e[d]=b[d]);return e},H=function(a){var b,c={};for(b in a)a.hasOwnProperty(b)&&null!==a[b]&&(c[b]=a[b]);return c},I=function(b){var e,f=b.settings.useMapControls?ol.control.defaults({attributionOptions:{collapsible:!1}}):[],j=b.settings.useMapControls?ol.interaction.defaults({mouseWheelZoom:!0}):[];proj4.defs("EPSG:3978","+proj=lcc +lat_1=49 +lat_2=77 +lat_0=49 +lon_0=-95 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs"),proj4.defs("urn:ogc:def:crs:OGC:1.3:CRS84",proj4.defs("EPSG:4326"));var k=new ol.Map({controls:f,interactions:j,logo:!1,target:b.mapDiv.attr("id")});e=s(k,ol.interaction.MouseWheelZoom),b.settings.useMapControls&&e&&e.setActive(!1),b.mapDiv.height(b.mapDiv.width()*b.settings.aspectRatio),k.set("aspectRatio",b.settings.aspectRatio),k.id=b.id,k.once("postrender",function(){k.getLayer=function(a){var b,d,e=c.querySelector(a+" [data-geometry][data-type]"),f=e.dataset.geometry,g=e.dataset.type;return"wkt"===g&&-1!==f.indexOf("POINT")&&(f=f.replace(/,/,""),f=f.substring(f.indexOf("(")+1,f.indexOf(")")),f=f.split(" "),b=parseFloat(f[0]),d=parseFloat(f[1])),{getDataExtent:function(){return[b,d]}}},k.zoomToExtent=function(a){k.getView().setCenter(ol.proj.transform([a[0],a[1]],"EPSG:4326","EPSG:3978")),k.getView().setZoom(5)},d.ready(a("#"+b.id),h,[k])}),k.on("moveend",function(){a(b.id).trigger("wb-updated"+i,[b.map])}),b.mapDiv.append("<div id='tooltip_"+b.id+"' style='display:none;'><span class='tooltip-txt'></span></div>");var l=function(c){g=a("#tooltip_"+b.id);var d,e=a("#tooltip_"+b.id+" span.tooltip-txt");g.css({left:c[0]+"px",top:c[1]-15+"px",position:"absolute"}),d=k.forEachFeatureAtPixel(c,function(a){return a}),d&&d.tooltip?(g.hide(),e.html(d.tooltip),g.show()):g.hide()};return k.on("pointermove",function(c){return g=a("#tooltip_"+b.id),c.dragging?void g.hide():void l(k.getEventPixel(c.originalEvent))}),k},J=function(a){var b,c;for(c=l.length-1;-1!==c;c-=1)if(b=l[c],b.id===a)return b},K=function(b){var c=new ol.interaction.DragBox,d=new ol.proj.Projection({code:"EPSG:4326"}),e=b.map.getView().getProjection();c.on("boxend",function(){var f=c.getGeometry().transform(e,d).getExtent();m=L(b,f),b.map.getView().fit(m.getGeometry().getExtent(),b.map.getSize()),a("#geomap-aoi-minx-"+b.id).val(f[0].toFixed(6)),a("#geomap-aoi-maxx-"+b.id).val(f[2].toFixed(6)),a("#geomap-aoi-maxy-"+b.id).val(f[3].toFixed(6)),a("#geomap-aoi-miny-"+b.id).val(f[1].toFixed(6)),a("#geomap-aoi-extent-"+b.id).val(m.getGeometry().getExtent()).trigger("change"),a("#geomap-aoi-extent-lonlat-"+b.id).val(f[0]+", "+f[1]+", "+f[2]+", "+f[3]).trigger("change")}),c.on("boxstart",function(){R(b.map,"locLayer").getSource().clear(!0)}),b.map.addInteraction(c),c.setActive(!1),b.settings.useAOIOpen?b.mapDiv.before("<div class='geomap-aoi panel panel-default'><div id='geomap-aoi-"+b.id+"' class='panel-body'></div></div>"):b.mapDiv.before("<details class='geomap-aoi'><summary>"+f.aoiTitle+"</summary><div id='geomap-aoi-"+b.id+"'></div></details>");var g,h,i,k,l,m,n=a("#geomap-aoi-"+b.id);n.append("<fieldset id='form-aoi-"+b.id+"'><legend tabindex='-1'>"+f.aoiInstructions+"</legend><div class='row'><div class='col-md-2 form-group'><label for='geomap-aoi-maxy-"+b.id+"' class='wb-inv'>"+f.aoiNorth+"</label><div class='input-group input-group-sm'><span class='input-group-addon'>"+f.aoiNorth.charAt(0)+"</span><input type='number' id='geomap-aoi-maxy-"+b.id+"' placeholder='90' class='form-control input-sm' min='-90' max='90' step='0.000001'></input></div></div><div class='col-md-2 form-group'><label for='geomap-aoi-maxx-"+b.id+"' class='wb-inv'>"+f.aoiEast+"</label><div class='input-group input-group-sm'><span class='input-group-addon'>"+f.aoiEast.charAt(0)+"</span><input type='number' id='geomap-aoi-maxx-"+b.id+"' placeholder='180' class='form-control input-sm' min='-180' max='180' step='0.000001'></input> </div></div><div class='col-md-2 form-group'><label for='geomap-aoi-miny-"+b.id+"' class='wb-inv'>"+f.aoiSouth+"</label><div class='input-group input-group-sm'><span class='input-group-addon'>"+f.aoiSouth.charAt(0)+"</span><input type='number' id='geomap-aoi-miny-"+b.id+"' placeholder='-90' class='form-control input-sm' min='-90' max='90' step='0.000001'></input> </div></div><div class='col-md-2 form-group'><label for='geomap-aoi-minx-"+b.id+"' class='wb-inv'>"+f.aoiWest+"</label><div class='input-group input-group-sm'><span class='input-group-addon'>"+f.aoiWest.charAt(0)+"</span><input type='number' id='geomap-aoi-minx-"+b.id+"' placeholder='-180' class='form-control input-sm' min='-180' max='180' step='0.000001'></input> </div></div><div class='col-md-4'><button class='btn btn-default btn-sm' id='geomap-aoi-btn-draw-"+b.id+"'>"+f.add+"</button> <button class='btn btn-default btn-sm' id='geomap-aoi-btn-clear-"+b.id+"'>"+f.aoiBtnClear+"</button> </div></div><input type='hidden' id='geomap-aoi-extent-"+b.id+"'></input><input type='hidden' id='geomap-aoi-extent-lonlat-"+b.id+"'></input></fieldset>"),a("#geomap-aoi-btn-clear-"+b.id).after("<button id='geomap-aoi-toggle-mode-draw-"+b.id+"' href='#' class='btn btn-sm btn-default geomap-geoloc-aoi-btn' title='"+f.aoiBtnDraw+"'><i class='glyphicon glyphicon-edit'></i> "+f.aoiBtnDraw+"</button>"),j.on("click","#geomap-aoi-toggle-mode-draw-"+b.id,function(d){d.preventDefault();var e=s(b.map,ol.interaction.DragBox),f=s(b.map,ol.interaction.Select),g=c.getActive(),h=a("#geomap-aoi-"+b.id);a(this).toggleClass("active"),g||h.find("legend").trigger("setfocus.wb"),e.setActive(!g),f.setActive(g)}),j.on("click","#geomap-aoi-btn-clear-"+b.id,function(c){c.preventDefault(),a("#geomap-aoi-extent-"+b.id).val(""),a("#geomap-aoi-extent-lonlat-"+b.id).val(""),a("#geomap-aoi-minx-"+b.id).val("").parent().removeClass("has-error"),a("#geomap-aoi-miny-"+b.id).val("").parent().removeClass("has-error"),a("#geomap-aoi-maxx-"+b.id).val("").parent().removeClass("has-error"),a("#geomap-aoi-maxy-"+b.id).val("").parent().removeClass("has-error"),R(b.map,"locLayer").getSource().clear(!0)}),j.on("click","#geomap-aoi-btn-draw-"+b.id,function(c){c.preventDefault(),a("#geomap-aoi-extent-"+b.id).val(""),a("#geomap-aoi-extent-lonlat-"+b.id).val(""),a("#geomap-aoi-minx-"+b.id).parent().removeClass("has-error"),a("#geomap-aoi-maxx-"+b.id).parent().removeClass("has-error"),a("#geomap-aoi-maxy-"+b.id).parent().removeClass("has-error"),a("#geomap-aoi-miny-"+b.id).parent().removeClass("has-error"),R(b.map,"locLayer").getSource().clear(!0);var d,e,f=parseFloat(a("#geomap-aoi-minx-"+b.id).val()),g=parseFloat(a("#geomap-aoi-miny-"+b.id).val()),h=parseFloat(a("#geomap-aoi-maxx-"+b.id).val()),i=parseFloat(a("#geomap-aoi-maxy-"+b.id).val()),j=!0;return(!f||-180>f||f>180)&&(a("#geomap-aoi-minx-"+b.id).parent().addClass("has-error"),j=!1),(!h||-180>h||h>180)&&(a("#geomap-aoi-maxx-"+b.id).parent().addClass("has-error"),j=!1),(!i||-90>i||i>90)&&(a("#geomap-aoi-maxy-"+b.id).parent().addClass("has-error"),j=!1),(!g||-90>g||g>90)&&(a("#geomap-aoi-miny-"+b.id).parent().addClass("has-error"),j=!1),j===!1?!1:(e=[f,g,h,i],d=L(b,e),b.map.getView().fit(d.getGeometry().getExtent(),b.map.getSize()),a("#geomap-aoi-extent-"+b.id).val(d.getGeometry().getExtent()).trigger("change"),void a("#geomap-aoi-extent-lonlat-"+b.id).val(f+", "+g+", "+h+", "+i).trigger("change"))}),b.aoiExtent&&(g=b.aoiExtent.split(","),h=g[0].trim(),i=g[1].trim(),k=g[2].trim(),l=g[3].trim(),m=L(b,g),b.map.getView().fit(m.getGeometry().getExtent(),b.map.getSize()),a("#geomap-aoi-minx-"+b.id).val(h),a("#geomap-aoi-maxx-"+b.id).val(k),a("#geomap-aoi-maxy-"+b.id).val(l),a("#geomap-aoi-miny-"+b.id).val(i),a("#geomap-aoi-extent-"+b.id).val(m.getBounds().toBBOX()),a("#geomap-aoi-extent-lonlat-"+b.id).val(h+", "+i+", "+k+", "+l))},L=function(a,b,c){var d,e,f,g=[],h=new ol.proj.Projection({code:"EPSG:4326"}),i=a.map.getView().getProjection();for(d=P(parseFloat(b[0]),parseFloat(b[1]),parseFloat(b[2]),parseFloat(b[3])),e=d.length-1;-1!==e;e-=1)g.push([d[e].getCoordinates()[0],d[e].getCoordinates()[1]]);return f=new ol.Feature({geometry:new ol.geom.Polygon([g]).transform(h,i)}),c||R(a.map,"locLayer").getSource().addFeature(f),f},M=function(b){var d=c.createElement("button"),e=c.createElement("div");d.innerHTML="?",d.title=f.accessTitle,d.setAttribute("type","button"),d.addEventListener("click",function(){var d=c.createElement("div"),e=c.createElement("header"),g=c.createElement("h3"),h=c.createElement("a"),i=c.createElement("div"),j=c.createAttribute("role"),k=c.createAttribute("title"),l=c.createAttribute("href");d.className="panel panel-default geomap-help-dialog ol-control ",e.className="panel-heading",g.innerHTML=f.accessTitle,g.className="panel-title",e.appendChild(g),k.value=f.dismiss,h.setAttributeNode(k),l.value="#",h.setAttributeNode(l),j.value="button",h.setAttributeNode(j),h.innerHTML="&#xd7;<span class='wb-inv'>"+f.dismiss+"</span>",h.className="btn btn-link",d.appendChild(h),i.innerHTML="<p>"+f.access+"</p>",i.className="panel-body",d.appendChild(e),d.appendChild(i);var m=new ol.control.Control({element:d});h.addEventListener("click",function(c){c.preventDefault(),a(c.target).closest(".geomap-help-dialog").fadeOut(function(){b.map.removeControl(m)})}),b.map.addControl(m)},!1),e.className="geomap-help-btn ol-unselectable ol-control",e.appendChild(d),ol.control.Control.call(this,{element:e}),b.map.addControl(this)},N=function(b){function e(a,c){var d,e,f,g,h,i=[],j=new ol.proj.Projection({code:"EPSG:4326"}),k=b.map.getView().getProjection();if(R(b.map,"locLayer").getSource().clear(!0),a&&"undefined"!=typeof a){for(d=a.split(","),e=P(parseFloat(d[0]),parseFloat(d[1]),parseFloat(d[2]),parseFloat(d[3])),g=e.length-1;-1!==g;g-=1)i.push([e[g].getCoordinates()[0],e[g].getCoordinates()[1]]);f=new ol.Feature({geometry:new ol.geom.Polygon([i]).transform(j,k)}),R(b.map,"locLayer").getSource().addFeature(f),b.map.getView().fit(f.getGeometry().getExtent(),b.map.getSize())}else c&&"undefined"!=typeof c&&(h=0===b.map.getView().getZoom()?12:b.map.getView().getZoom(),f=new ol.Feature({geometry:new ol.geom.Point(c.split(",")).transform(j,k)}),R(b.map,"locLayer").getSource().addFeature(f),b.map.getView().setZoom(h),b.map.getView().setCenter(f.getGeometry().getCoordinates()))}function g(a){var c=a.nextSibling.firstChild;s(b.map,ol.interaction.KeyboardPan).setActive(!0),c.className+=" hide",c.innerHTML="",c.setAttribute("aria-hidden","true"),a.setAttribute("aria-expanded","false"),a.setAttribute("aria-activedescendent","")}function h(c,e){var f="",g=a("#wb-geomap-geocode-search-"+b.id),h=a("#wb-geomap-geoloc-al-"+b.id),i=function(a,b){var c=new RegExp(Object.keys(b).join("|"),"gi");return a.replace(c,function(a){return b[a.toLowerCase()]})};(!e||e.length<3)&&h.empty(),a.ajax({type:"GET",url:r,data:{q:e+"*"},success:function(c){if(c.length>0){var d,e,j,m,n,o,p=c.length,q="";for(d=0;d!==p;d+=1)e=c[d],m=e.title.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),n=e.bbox?e.bbox[0]+", "+e.bbox[1]+", "+e.bbox[2]+", "+e.bbox[3]:"",o=e.geometry&&"Point"===e.geometry.type?e.geometry.coordinates[0]+", "+e.geometry.coordinates[1]:"",q=u[e.type]?u[e.type]:"<span class='glyphicon glyphicon-map-marker' aria-hidden='true'></span>",m=i(m,t),j=m.replace(/<(?:.|\n)*?>/gm,""),f+="<li id='al-opt-"+b.id+"-"+d+"' class='al-opt' data-lat-lon='"+o+"' data-bbox='"+n+"' data-type='"+e.type+"'><a href='javascript:;' tabindex='-1'>"+q+"<span class='al-val'>"+m+"</span><span class='al-lbl wb-inv' aria-hidden='true'>"+j+"</span></a></li>";h.empty().append(f),h.removeClass("hide").attr("aria-hidden","false"),g.attr("aria-expanded","true"),a(".al-opt a").on("keydown click vclick",function(a){var b=a.target,c=a.type,d=a.which;switch(c){case"keydown":if(!a.ctrlKey&&!a.metaKey)return l(d,b);break;case"click":case"vclick":case"touchstart":if(!d||1===d)return k(b)}})}else h.empty(),h.addClass("hide").attr("aria-hidden","true"),h.attr("aria-expanded","false")},dataType:d.ielt10?"jsonp":"json",cache:!1})}function i(b,c){var d,e,f,i,j=c.target,k=j.nextSibling.firstChild,l=-1!==k.className.indexOf("hide");if(!(c.ctrlKey||c.altKey||c.metaKey))if(32===b||b>47&&91>b||b>95&&112>b||b>159&&177>b||b>187&&223>b)c.altKey||h(j,j.value+String.fromCharCode(b));else if(8!==b||c.altKey){if((38===b||40===b)&&""===j.getAttribute("aria-activedescendent"))return l&&h(j),d=k.getElementsByTagName("a"),0===d.length?!1:(e=d[38===b?d.length-1:0],j.setAttribute("aria-activedescendent",e.parentNode.getAttribute("id")),a(e).trigger(q),!1);l||(9===b||27===b||27===b&&!c.altKey)&&g(j)}else f=j.value,i=f.length,0!==i&&h(j,f.substring(0,i-1))}function k(b){var c=b.nodeName.toLowerCase(),d="a"===c?b:b.parentNode,f=d.parentNode.parentNode,h=f.parentNode.previousSibling,i=a(h),j=d.getElementsByTagName("span"),k=j[2].innerHTML;return h.value=k,e(d.parentNode.getAttribute("data-bbox"),d.parentNode.getAttribute("data-lat-lon")),i.trigger(q),g(h),!1}function l(b,c){var d,f,i,j,k,l=c.parentNode.parentNode,m=l.parentNode.previousSibling,n=a(m);if(!(event.ctrlKey||event.altKey||event.metaKey)){if(32===b||b>47&&91>b||b>95&&112>b||b>159&&177>b||b>187&&223>b)return m.value+=String.fromCharCode(b),n.trigger(q),h(m,m.value),!1;if(8===b)return i=m.value,j=i.length,0!==j&&(m.value=i.substring(0,j-1),h(m,m.value)),n.trigger(q),!1;if(13===b)return d=c.getElementsByTagName("span"),i=d[2].innerHTML,m.value=i,e(c.parentNode.getAttribute("data-bbox"),c.parentNode.getAttribute("data-lat-lon")),n.trigger(q),g(m),!1;if(9===b||27===b)return n.trigger(q),g(m),!1;if(38===b||40===b)return 38===b?(f=c.parentNode.previousSibling,f||(k=l.getElementsByTagName("li"),f=k[k.length-1])):(f=c.parentNode.nextSibling,f||(f=l.getElementsByTagName("li")[0])),f=f.getElementsByTagName("a")[0],m.setAttribute("aria-activedescendent",f.parentNode.getAttribute("id")),a(f).trigger(q),!1}}var n,o,p=c.createElement("div"),q="setfocus.wb",r=f.geoLocationURL,t={quebec:"<abbr title='Quebec'>QC</abbr>","québec":"<abbr title='Québec'>QC</abbr>","british columbia":"<abbr title='British Columbia'>BC</abbr>","colombie-britannique":"<abbr title='Colombie-Britannique'>BC</abbr>",alberta:"<abbr title='Alberta'>AB</abbr>",saskatchewan:"<abbr title='Saskatchewan'>SK</abbr>",manitoba:"<abbr title='Manitoba'>MB</abbr>",ontario:"<abbr title='Ontario'>ON</abbr>","newfoundland and labrador":"<abbr title='Newfoundland and Labrador'>NL</abbr>","terre-neuve-et-labrador":"<abbr title='Terre-Neuve-et-Labrador'>NL</abbr>","prince edward island":"<abbr title='Prince Edward Island'>PE</abbr>","île-du-prince-édouard":"<abbr title='Île-du-prince-Édouard'>PE</abbr>","nova scotia":"<abbr title='Nova Scotia'>NS</abbr>","nouvelle-écosse":"<abbr title='Nouvelle-Écosse'>NS</abbr>","new brunswick":"<abbr title='New Brunswick'>NB</abbr>","nouveau-brunswick":"<abbr title='Nouveau-Brunswick'>NB</abbr>",yukon:"<abbr title='Yukon'>YT</abbr>","northwest territories":"<abbr title='Northwest Territories'>NT</abbr>","territoires du nord-ouest":"<abbr title='Territoires du Nord-Ouest'>NT</abbr>",nunavut:"<abbr title='Nunavut'>NU</abbr>"},u={"ca.gc.nrcan.geoloc.data.model.Street":"<span class='glyphicon glyphicon-road' aria-hidden='true'></span>","ca.gc.nrcan.geoloc.data.model.Intersection":"<span class='glyphicon glyphicon-road' aria-hidden='true'></span>","ca.gc.nrcan.geoloc.data.model.Geoname":"<span class='glyphicon glyphicon-map-marker' aria-hidden='true'></span>","ca.gc.nrcan.geoloc.data.model.PostalCode":"<span class='glyphicon glyphicon-envelope' aria-hidden='true'></span>","ca.gc.nrcan.geoloc.data.model.NTS":"<span class='glyphicon glyphicon-globe' aria-hidden='true'></span>"};p.innerHTML="<label for='wb-geomap-geocode-search-"+b.id+"' class='wb-inv'>"+f.geoCoderLabel+"</label><input type='text' class='form-control' id='wb-geomap-geocode-search-"+b.id+"' placeholder='"+f.geoCoderPlaceholder+"' ></input><div class='wb-geomap-geoloc-al-cnt'><ul role='listbox' id='wb-geomap-geoloc-al-"+b.id+"' class='wb-geomap-geoloc-al hide' aria-hidden='true' aria-live='polite'></ul></div>",p.className="geomap-geoloc ol-unselectable ol-control",ol.control.Control.call(this,{element:p}),b.map.addControl(this),a("#wb-geomap-geocode-search-"+b.id).attr("autocomplete","off"),a("#wb-geomap-geocode-search-"+b.id).attr("role","textbox"),a("#wb-geomap-geocode-search-"+b.id).attr("aria-haspopup","true"),a("#wb-geomap-geocode-search-"+b.id).attr("aria-autocomplete","list"),a("#wb-geomap-geocode-search-"+b.id).attr("aria-owns","wb-geomap-geoloc-al-"+b.id),a("#wb-geomap-geocode-search-"+b.id).attr("aria-activedescendent",""),n=parseFloat(a(".geomap-geoloc").parent().width()),o=n>768?.6:.8,m?(a(".geomap-geoloc").css({width:n-10+"px"}),a(".wb-geomap-geoloc-al-cnt").css({width:n-10+"px"})):(a(".geomap-geoloc").css({width:n*o}),a(".wb-geomap-geoloc-al-cnt").css({width:n*o})),j.on("keydown","#wb-geomap-geocode-search-"+b.id,function(a){s(b.map,ol.interaction.KeyboardPan).setActive(!1);var c=a.which;return a.ctrlKey||a.metaKey?void 0:i(c,a)})},O=function(b){function d(){return g=new ol.Feature,e=new ol.Feature,g.setStyle(y({radius:6,fill:new ol.style.Fill({color:"#3399CC"}),stroke:new ol.style.Stroke({color:"#fff",width:2})})),[e,g]}var e,g,h,i,j,k=b||{},l=this;a("body").append("<section id='overlay-location-error' class='wb-overlay modal-content overlay-def wb-bar-t bg-danger'><header><h2 class='modal-title'>Geolocation error.</h2></header></section>"),a("#overlay-location-error").trigger("wb-init.wb-overlay"),h=c.createElement("button"),h.setAttribute("type","button"),h.setAttribute("title",f.geolocBtn),h.innerHTML="<span class='glyphicon glyphicon-screenshot'></span>",j=c.createElement("div"),j.className="ol-geolocate ol-unselectable ol-control",j.appendChild(h),l.geolocation=new ol.Geolocation(k),ol.control.Control.call(this,{element:j,target:k.target}),l.geolocation.on("change:accuracyGeometry",function(){e.setGeometry(l.geolocation.getAccuracyGeometry())}),l.geolocation.on("change:position",function(){i=l.geolocation.getPosition(),g.setGeometry(i?new ol.geom.Point(i):null);var b=l.featuresOverlay.getSource().getExtent();l.getMap().getView().fit(b,l.getMap().getSize()),a(h).html("<span style='color:#3399CC;' class='glyphicon glyphicon-screenshot'></span>")}),l.geolocation.on("error",function(b){2===b.code?(a("#overlay-location-error h2.modal-title").text(f.geolocUncapable),a("#overlay-location-error").trigger("open.wb-overlay")):(a("#overlay-location-error h2.modal-title").text(f.geolocFail),a("#overlay-location-error").trigger("open.wb-overlay"))}),h.addEventListener("click",function(){a(this).html("<span style='font-size:.9em;' class='glyphicon glyphicon-refresh glyphicon-spin'></span>"),
  "undefined"==typeof l.featuresOverlay?(l.featuresOverlay=new ol.layer.Vector({map:l.getMap(),source:new ol.source.Vector({})}),l.featuresOverlay.getSource().addFeatures(d()),l.geolocation.setTracking(!0)):0===l.featuresOverlay.getSource().getFeatures().length?(l.featuresOverlay.getSource().addFeatures(d()),l.geolocation.setTracking(!0)):(l.geolocation.setTracking(!1),l.featuresOverlay.getSource().clear(),a(this).html("<span class='glyphicon glyphicon-screenshot'></span>"))},!1)},P=function(a,b,c,d){var e,f=parseFloat(a),g=parseFloat(b),h=parseFloat(c),i=parseFloat(d),j=[];if(0===f.length||0===g.length||0===h.length||0===i.length)return!1;for(-180===f&&(f+=.1),180===h&&(h=-5),90===i&&(i-=3),-90===g&&(g=35),e=f;h>e;e+=.5)j.push(new ol.geom.Point([e,g]));for(j.push(new ol.geom.Point([h,g])),e=h;e>f;e-=.5)j.push(new ol.geom.Point([e,i]));return j.push(new ol.geom.Point([f,i])),j.push(new ol.geom.Point([f,g])),j},Q=function(){a(".wb-tables").trigger("wb-init.wb-tables")},R=function(a,b){var c;return a.getLayers().forEach(function(a){return b===a.id?void(c=a):void 0}),c},S=function(a){var b,c=J(a.getAttribute("data-map"));return a.getAttribute("data-layer")?(b=R(c.map,a.getAttribute("data-layer")),[c.map,b,a.getAttribute("data-feature")?b.getSource().getFeatureById(a.getAttribute("data-feature")):null]):[c.map,null,null]},T=function(){return Math.random().toString(36).slice(2)};j.on("click",".geomap-zoomto",function(b){var c,d,e,f,g,h=b.which,i="A"===b.target.tagName?b.target:a(b.target).closest("a")[0];h&&1!==h||(b.preventDefault(),c=i.getAttribute("data-map"),d=S(i),e=d[2].getGeometry(),f=e.getExtent(),g=d[0].getView(),"Point"===e.getType()?(g.fit(f,d[0].getSize()),g.setZoom(10)):g.fit(f,d[0].getSize()),a("#"+c+" .wb-geomap-map").trigger("setfocus.wb"))}),j.on("geomap.wb",i,o),j.on(d.resizeEvents,function(b){l.forEach(function(c){var d=a(c.map.getTargetElement()),e=d.find(".geomap-geoloc"),f=d.width();d.height(f*c.map.get("aspectRatio")),c.map.updateSize(),e&&("mediumview"===b.type||"largeview"===b.type||"xlargeview"===b.type?e.css({width:"60%"}):e.css({width:"80%"}))})}),j.on("change",".geomap-cbx",function(a){var b=a.target,c=S(b)[2],d=S(b)[0],e=s(d,ol.interaction.Select),f=b.checked;f?e.getFeatures().push(c):e.getFeatures().remove(c)}),j.on("focusin focusout mouseover mouseout",".wb-geomap-map",function(b){var c=b.currentTarget,d=b.type,e=c.className.indexOf("active"),f=J(c.getAttribute("data-map")),g=s(f.map,ol.interaction.MouseWheelZoom);f.settings.useMapControls&&g.setActive(!1),"mouseover"===d||"focusin"===d?(e&&a(c).addClass("active"),"focusin"===d&&f.settings.useMapControls&&g.setActive(!0)):e>0&&a(c).removeClass("active")}),p.prototype.addBasemap=function(){var b,c,d,e,g,h,i,j,k=this,l=k.settings.basemap,m=l&&0!==l.length,n={},o=[],p={},q=[];if(k.settings.attribution&&(p.attributions=[new ol.Attribution({html:k.settings.attribution.text})]),m)n.extent=l.mapOptions&&l.mapOptions.maxExtent?l.mapOptions.maxExtent.split(",").map(Number):null,n.projection=l.mapOptions&&l.mapOptions.projection?l.mapOptions.projection:"EPSG:3857",n.center=k.settings&&k.settings.center?ol.proj.transform(k.settings.center,"EPSG:4326",n.projection):l.mapOptions&&l.mapOptions.center?ol.proj.transform(l.mapOptions.center,"EPSG:4326",n.projection):l.mapOptions&&l.mapOptions.maxExtent?ol.extent.getCenter(n.extent):[0,0],n.zoom=k.settings&&k.settings.zoom?k.settings.zoom:l.mapOptions&&l.mapOptions.zoomLevel?l.mapOptions.zoomLevel:2,"wms"===l.type?(b=G(l,["mapOptions","url"]),b.srs=n.projection,b.crs=n.projection,q.push(new ol.layer.Image({extent:n.extent,source:new ol.source.ImageWMS({url:l.url,params:b})}))):"esri"===l.type?(p.url=l.url.replace("/MapServer/export","/MapServer"),q.push(new ol.layer.Tile({extent:n.extent,source:new ol.source.TileArcGISRest(p)}))):"xyz"===l.type?(a.isArray(l.url)?(a.each(l.url,function(a,b){o.push(b.replace(/\${/g,"{"))}),p.urls=o):p.url=l.url.replace(/\${/g,"{"),q.push(new ol.layer.Tile({source:new ol.source.XYZ(p)}))):"osm"===l.type?q.push(new ol.layer.Tile({source:new ol.source.OSM({attributions:[ol.source.OSM.ATTRIBUTION]})})):"mapquest"===l.type&&q.push(new ol.layer.Tile({source:new ol.source.MapQuest({layer:"sat"})}));else{for(d=ol.proj.get("EPSG:3978"),e=[38364.660062653464,22489.62831258996,13229.193125052918,7937.5158750317505,4630.2175937685215,2645.8386250105837,1587.5031750063501,926.0435187537042,529.1677250021168,317.50063500127004,185.20870375074085,111.12522225044451,66.1459656252646,38.36466006265346,22.48962831258996,13.229193125052918,7.9375158750317505,4.6302175937685215],g=this.mapDiv.width(),h=5,g>260&&500>=g?h=1:g>500&&725>=g?h=2:g>725&&1175>=g?h=3:g>1175&&2300>=g&&(h=4),i=h-1;-1!==i;i-=1)e.shift();for(j=new Array(e.length),c=0;c<e.length;++c)j[c]=h+c;n={extent:[-275e4,-9e5,36e5,463e4],resolutions:e,projection:d},q.push(new ol.layer.Tile({source:new ol.source.WMTS({attributions:[new ol.Attribution({html:"<a href='"+f.attribLink+"'>"+f.attribTitle+"</a>"})],url:f.baseMapURL,layer:f.baseMapTitle,matrixSet:f.baseMapMatrixSet,projection:d,tileGrid:new ol.tilegrid.WMTS({extent:[-275e4,-9e5,36e5,463e4],origin:[-34655800,3931e4],resolutions:e,matrixIds:j}),style:"default"})}))}for(var r=q.length-1;-1!==r;r-=1)k.map.addLayer(q[r]);return H(n)},q.prototype.addToLegend=function(){var b,c,d,e,g,h,i=this,j=this.map.legend.target;b=j.find("fieldset"),0===b.length&&(b=a("<fieldset name='legend'><legend class='wb-inv'>"+f.toggleLayer+"</legend></fieldset>").appendTo(j)),d=this.isVisibile?"checked='checked'":"",c=j.find("ul.geomap-lgnd"),0===c.length&&(c=a("<ul class='list-unstyled geomap-lgnd'></ul>").appendTo(b)),e=a("<input type='checkbox' id='cb_"+this.id+"' class='geomap-lgnd-cbx' value='"+this.id+"' "+d+" data-map='"+this.map.id+"' data-layer='"+this.id+"' />"),i.observeVisibility(function(b){a("#sb_"+i.id).toggle(b),i.map.legend.refresh(),e.get(0).checked=b}),e.change(function(){i.isVisible=a(this).is(":checked")}),g=a("<label>",{"for":"cb_"+this.id,text:this.settings.title}).prepend(e),h=a("<li class='checkbox geomap-lgnd-layer'>").append(g,"<div id='sb_"+this.id+"'></div>"),c.append(h),this.settings.options&&this.settings.options.legendUrl?a("#sb_"+this.id).append("<img src='"+this.settings.options.legendUrl+"' alt='"+f.geoLgndGrphc+"'/>"):this.settings.options&&this.settings.options.legendHTML?a("#sb_"+this.id).append(this.settings.options.legendHTML):"wms"!==this.settings.type&&this.map.legend.symbolize(this)},p.prototype.addTabularData=function(){var b,d,e,g,h,i,j,k,l,m,n,o,p,r,s,t,v,w,x,y,z,A,B,E,F,G,H,I,J,K="<th><span class='wb-inv'>"+f.zoomFeature+"</span></th>",L="<th><span class='wb-inv'>"+f.select+"</span></th>",M=new ol.format.WKT,N=/<\/?[^>]+>/gi,O=/\W/g;for(F=this.settings.tables.length-1;-1!==F;F-=1)if(d=c.getElementById(this.settings.tables[F].id)){for(b=a(d).wrap("<div data-layer='"+this.settings.tables[F].id+"' class='geomap-table-wrapper'></div>"),e=this.settings.tables[F],g=[],h=[],j=d.getElementsByTagName("th"),l=d.getElementsByTagName("tr"),m=l.length,n=this.settings.useMapControls,b.hasClass("wb-tables")&&"undefined"==typeof b.attr("data-wb-tables")&&b.attr("data-wb-tables",'{ "order": [], "columnDefs": [ { "targets": [ 0, '+(j.length+1)+' ], "orderable": false } ] }'),G=this.settings.tables[F].visible===!1?!1:!0,k=j.length-1;-1!==k;k-=1)h[k]=j[k].innerHTML.replace(N,"");for(i=b.find("thead tr"),e.zoom&&n&&i.append(K),i.prepend(L),I=u(),H="undefined"==typeof e.style?{strokeColor:I.stroke,fillColor:I.fill}:e.style,m=l.length-1;-1!==m;m-=1){for(o={},p=l[m],r=p.getAttribute("data-type"),v=p.getElementsByTagName("td"),B=0;B<v.length;B+=1)t=v[B],y=t.getElementsByTagName("script")[0],y&&y.parentNode.removeChild(y),o[h[B]]=t.innerHTML;if(null!==r){if("bbox"===r){for(z=p.getAttribute("data-geometry").split(","),s=P(z[0],z[1],z[2],z[3]),A="",E=s.length-1;-1!==E;E-=1)A+=s[E].getCoordinates()[0]+" "+s[E].getCoordinates()[1]+", ";A=A.slice(0,-2),x="POLYGON (("+A+"))"}else"wkt"===r&&(x=p.getAttribute("data-geometry"),-1!==x.indexOf("POINT")&&(x=x.replace(",","")));w=M.readFeature(x,{dataProjection:"EPSG:4326",featureProjection:this.map.getView().getProjection()}),w.setId(T()),w.layerId=e.id,w.layerTitle=b.attr("aria-label"),e.tooltips&&(w.tooltip=e.tooltipText?o[e.tooltipText]:o[Object.keys(o)[0]]),p.setAttribute("id",w.getId().replace(O,"_")),a(p).html(C(this,w)+p.innerHTML+(n&&e.zoom?D(this,w):"")),w.attributes=o,g.push(w)}}J=new q(this,{tableId:b.attr("id"),type:"wkt",visible:G,datatable:e.datatable,popupsInfo:e.popupsInfo,popups:e.popups,tooltips:e.tooltips,tooltipText:e.tooltipText,name:e.id,title:b.attr("aria-label"),features:g,style:H}),this.mapLayers.push(J)}},p.prototype.addMapLayers=function(){var b,c,d=this;d.addTabularData(),a.each(d.settings.overlays,function(a,b){c=new q(d,b),d.mapLayers.push(c)}),b=new ol.layer.Vector({source:new ol.source.Vector,style:new ol.style.Style({fill:new ol.style.Fill({color:"rgba( 255, 0, 20, 0.1 )"}),stroke:new ol.style.Stroke({color:"#ff0033",width:2}),image:new ol.style.RegularShape({fill:new ol.style.Fill({color:"#ff0033"}),stroke:new ol.style.Stroke({color:"#ff0033",width:5}),points:4,radius:10,radius2:0,angle:0})})}),b.id="locLayer",d.map.addLayer(b);for(var e=d.mapLayers.length-1;-1!==e;e-=1)d.mapLayers[e].layer&&d.map.addLayer(d.mapLayers[e].layer)},q.prototype.populateDataTable=function(){function b(){var a=0;for(var b in g)g.hasOwnProperty(b)&&(a+=1);return a}if(this.settings.accessible){var c,d,e=this,g=e.settings.attributes,h=b(),i=a("<table class='table' aria-label='"+e.settings.title+"' id='"+e.id+"'><caption>"+e.settings.caption+"</caption></table>"),j="<th><span class='wb-inv'>"+f.select+"</span></th>",k="",l=e.layer.getSource().getFeatures();e.settings.datatable?(i.addClass("wb-tables"),i.attr("data-wb-tables",'{ "order": [], "columnDefs": [ { "targets": [ 0, '+(h+1)+' ], "orderable": false } ] }')):i.addClass("table-condensed");for(c in g)g.hasOwnProperty(c)&&(d=g[c].alias?g[c].alias:g[c],j+="<th>"+d+"</th>");j="<thead><tr>"+j+(e.map.settings.useMapControls&&e.settings.zoom?"<th><span class='wb-inv'>"+f.zoomFeature+"</span></th>":"")+"</tr></thead>";for(var m=0;m<l.length;m+=1){k+="<tr>"+C(e,l[m]),g=l[m].attributes;for(c in g)g.hasOwnProperty(c)&&(k+="<td>"+g[c]+"</td>");k+=e.map.settings.useMapControls&&e.settings.zoom?D(e.map,l[m]):""}return i.append(j,"<tbody>"+k+"</tbody>"),a("div[ data-layer='"+e.id+"'].geomap-table-wrapper").append(i),Q(e.map),i}},q.prototype.createOLLayer=function(){function b(b){var c;return a.each(b,function(a,b){b.coordinates&&(c=a)}),c}var c,d,e,f,g,h,i,j=this,k=j.settings.attributes;if("wms"===j.settings.type){var l=F(j.settings),m=l.options.opacity?l.options.opacity:1;d=new ol.layer.Image({opacity:m,visible:j.settings.visible,source:new ol.source.ImageWMS({url:j.settings.url,params:l})}),j.settings.accessible=!1}else if("wkt"===j.settings.type)e=new v,d=new ol.layer.Vector({visible:j.settings.visible,source:new ol.source.Vector({features:j.settings.features}),style:e.createStyleFunction(j.settings.style,j.settings.featureType)}),j.settings.accessible=!1;else if("kml"===j.settings.type){var n=!j.settings.style;e=new v,c=u(),d=new ol.layer.Vector({visible:j.settings.visible,source:new ol.source.Vector({url:j.settings.url,format:new ol.format.KML({extractStyles:n})})}),"undefined"==typeof j.settings.style&&(j.settings.style={strokeColor:c.stroke,fillColor:c.fill}),d.getSource().once("addfeature",function(a){if(g=a.feature.getGeometry().getType(),!n){var b=e.createStyleFunction(j.settings.style,g);d.setStyle(b)}}),i=d.getSource(),h=i.on("change",function(){if("ready"===i.getState()){i.unByKey(h);for(var a=this.getFeatures(),b=0,c=a.length;c>b;b+=1){var e=a[b];if(j.settings.style.select){j.settings.style.select.type="select";var g=new v,l=g.createStyleFunction(j.settings.style.select,e.getGeometry().getType());e.selectStyle=l}e.setId(T()),e.layerId=d.id,e.layerTitle=d.title,f={};for(var m in k)k.hasOwnProperty(m)&&(f[k[m]]=e.getProperties()[m]);e.attributes=f,j.settings.tooltips&&(e.tooltip=j.settings.tooltipText?f[j.settings.tooltipText]:f[Object.keys(f)[0]])}j.populateDataTable(),j.map.legend.symbolize(j)}},i)}else if("json"===j.settings.type){var o=new ol.source.Vector;e=new v,c=u(),"undefined"==typeof j.settings.style&&(j.settings.style={strokeColor:c.stroke,fillColor:c.fill}),d=j.settings.cluster?new ol.layer.Vector({visible:j.settings.visible,source:new ol.source.Cluster({distance:40,source:o})}):new ol.layer.Vector({visible:j.settings.visible,source:o}),o.once("addfeature",function(){d.setStyle(e.createStyleFunction(j.settings.style,g))});var p=function(c){var e,f,g,h,i,l,m,n,p,q,r=j.settings.root,s=c[r]?c[r]:c.features?c.features:c;for(s instanceof Array==!1&&(s=a.map(s,function(a){return a})),n=0,p=s.length;p>n;n+=1)if(g=s[n],m||(m=b(g)),g[m]){if(h=g[m].coordinates[0],"Polygon"===g[m].type&&5===h.length){f=P(h[1][0],h[1][1],h[3][0],h[3][1]);for(var t=[],u=0,v=f.length;v>u;u+=1){var w=f[u];t.push(w.getCoordinates())}i=new ol.geom.Polygon([t])}else"Point"===g[m].type?i=new ol.geom.Point([g[m].coordinates[1],g[m].coordinates[0]]):"LineString"===g[m].type&&(i=new ol.geom.LineString(g[m].coordinates));l=i.transform("EPSG:4326",j.map.map.getView().getProjection()),e={};for(var x in k)q=null,k.hasOwnProperty(x)&&(q=k[x].path,q?e[k[x].alias]=g[x]?g[x][q]:"":e[k[x]]=g[x]?g[x]:"");g=new ol.Feature,g.setId(T()),g.layerId=d.id,g.layerTitle=d.title,g.attributes=e,g.setGeometry(l),o.addFeature(g),j.settings.tooltips&&(g.tooltip=j.settings.tooltipText?e[j.settings.tooltipText]:e[Object.keys(e)[0]])}j.populateDataTable(),j.map.legend.symbolize(j)};a.getJSON(j.settings.url,j.settings.params,p)}else if("geojson"===j.settings.type||"esrijson"===j.settings.type||"topojson"===j.settings.type){var q;e=new v,c=u(),"undefined"==typeof j.settings.style&&(j.settings.style={strokeColor:c.stroke,fillColor:c.fill}),q=j.settings.params?j.settings.url+"?"+a.param(j.settings.params):j.settings.url,d="geojson"===j.settings.type?new ol.layer.Vector({visible:j.settings.visible,source:new ol.source.Vector({url:q,format:new ol.format.GeoJSON,strategy:ol.loadingstrategy.bbox})}):"topojson"===j.settings.type?new ol.layer.Vector({visible:j.settings.visible,source:new ol.source.Vector({url:q,format:new ol.format.TopoJSON})}):new ol.layer.Vector({visible:j.settings.visible,source:new ol.source.Vector({url:q,format:new ol.format.EsriJSON,strategy:ol.loadingstrategy.bbox})}),d.getSource().once("addfeature",function(a){g=a.feature.getGeometry().getType();var b=e.createStyleFunction(j.settings.style,g);d.setStyle(b)}),i=d.getSource(),h=i.on("change",function(){if("ready"===i.getState()){i.unByKey(h);for(var a=this.getFeatures(),b=0,c=a.length;c>b;b+=1){var e=a[b];e.setId(T()),e.layerId=d.id,e.layerTitle=d.title,f={};for(var g in k)k.hasOwnProperty(g)&&(f[k[g]]=e.getProperties()[g]);e.attributes=f,j.settings.tooltips&&(e.tooltip=j.settings.tooltipText?f[j.settings.tooltipText]:f[Object.keys(f)[0]])}j.populateDataTable(),j.map.legend.symbolize(j)}},i)}return d?(d.id=j.id,d.title=j.settings.title,d.datatable=j.settings.datatable,d.popupsInfo=j.settings.popupsInfo,d.popups=j.settings.popups,d):null},p.prototype.loadControls=function(){var b,d,e,g,h=this,i=h.map,j=!1;if(g=new ol.interaction.Select({layers:h.layers}),g.getFeatures().on("remove",function(b){var c=b.element;c.setStyle(null),a("#cb_"+c.getId()).prop("checked",!1).closest("tr").removeClass("active")}),g.getFeatures().on("add",function(b){var c=b.element;c.selectStyle&&c.setStyle(c.selectStyle),a("#cb_"+c.getId()).prop("checked",!0).closest("tr").addClass("active")}),g.on("select",function(a){var b=this,c=a.selected?a.selected:b.getFeatures();c&&c.length>0&&"undefined"!=typeof c[0].layerTitle&&(j=R(b.getMap(),c[0].layerId).popups,c[0].layerTitle=b.getLayer(a.selected[0]).title,j&&E(a,c[0],i)),c&&0===c.length&&E(a,null,i)},g),i.getInteractions().extend([g]),h.settings.useMapControls){var k=c.createElement("span");k.className="glyphicon glyphicon-home",b=new ol.control.ZoomToExtent({extent:i.getView().calculateExtent(i.getSize()),label:k}),i.addControl(b),b.element.setAttribute("aria-label",f.zoomworld),b.element.setAttribute("title",f.zoomworld),h.settings.useMousePosition&&(d=new ol.control.MousePosition({coordinateFormat:ol.coordinate.createStringXY(4),projection:"EPSG:4326",undefinedHTML:""}),i.addControl(d),d.element.setAttribute("aria-label",f.mouseposition),d.element.setAttribute("title",f.mouseposition)),h.settings.useScaleLine&&(e=new ol.control.ScaleLine,i.addControl(e),e.element.setAttribute("aria-label",f.scaleline),e.element.setAttribute("title",f.scaleline))}h.settings.useGeocoder&&new N(h),h.settings.useAOI&&new K(h),h.settings.useGeolocation&&h.map.addControl(new O({projection:h.map.getView().getProjection()}))},p.prototype.createPopup=function(){var b,d,e,g=this;e=a("<div id='popup-"+g.mapDiv.attr("id")+"' class='ol-popup'></div>"),b=a("<a href='#' title='"+f.dismiss+"' class='ol-popup-closer' role='button'>&#xd7;<span class='wb-inv'>"+f.dismiss+"</span></a>"),e.append(b,"<div class='popup-content'></div>"),a("#"+g.mapDiv.attr("id")).append(e),d=new ol.Overlay({element:c.getElementById("popup-"+g.mapDiv.attr("id")),autoPan:!0,autoPanAnimation:{duration:250}}),b.on("click",function(a){return a.preventDefault(),d.setPosition(void 0),this.blur(),!1}),g.map.addOverlay(d)},p.prototype.accessibilize=function(){var a=this,b=a.mapDiv.find(".ol-zoom-in"),c=a.mapDiv.find(".ol-zoom-out");b.attr("aria-label",f.zoomin),b.attr("title",f.zoomin),c.attr("aria-label",f.zoomout),c.attr("title",f.zoomout),a.mapDiv.attr({tabindex:"0","data-map":a.id}),a.mapDiv.attr({role:"dialog","aria-label":f.ariaMap}),a.settings.useMapControls&&new M(a)},p.prototype.zoomAOI=function(a,b,c,d){var e,f,g,h=this,i=h.map,j=i.getView(),k="string"==typeof a;if(k&&!a.length)return void j.setZoom(j.getMaxZoom);if(k&&null!==a.substring(0,1).match(/[a-z]/gi)){var l=new ol.format.WKT;g=l.readFeature(a,{dataProjection:"EPSG:4326",featureProjection:j.getProjection()})}else{if(!b&&k){if(e=a.split(" "),4!==e.length)throw"4 cardinal point must be provided";a=e[0],b=e[1],c=e[2],d=e[3]}else if(!b||!c||!d)throw"Cardinal point must be provided";e=[parseFloat(d),parseFloat(c),parseFloat(b),parseFloat(a)],g=L(h,e,!0)}f=g.getGeometry().getExtent(),j.fit(f,i.getSize())},p.prototype.showLayer=function(a,b){var c,d,e,f=[],g=this.mapLayers,h=g.length;for(b=!!b,Array.isArray(a)?f=a:f.push(a),c=0;c!==h;c+=1)d=g[c],e=d.layer.title,a&&-1===f.indexOf(e)?e&&(d.isVisible=!b):d.isVisible=b},r.prototype.symbolize=function(b){if(b.layer){var c,d,e,f,g,h,i,j,k=this,l=b.settings.style,m=b.id,n=b.layer.getSource().getFeatures()[0],o=[],p="",q="";if("undefined"!=typeof l&&l.rule){if(d=l.rule.length)for(g=0;g!==d;g+=1){if(i=l.rule[g],c=i.filter,e=i.init,q="",j="ls_"+m+"_"+g,c&&!i.name)if(c.name)q=c.name;else switch(c){case"EQUAL_TO":q=i.field+" = "+i.value[0];break;case"GREATER_THAN":q=i.field+" > "+i.value[0];break;case"LESS_THAN":q=i.field+" < "+i.value[0];break;case"BETWEEN":q=i.field+" "+i.value[0]+" - "+i.value[1]}else i&&i.name&&(q=i.name);p+="<li><div class='geomap-legend-element'><div id='"+j+"' class='geomap-legend-symbol'></div><span class='geomap-legend-symbol-text'><small>"+q+"</small></span></div></li>",o.push({id:j,feature:n,symbolizer:e})}}else if("undefined"!=typeof l&&"unique"===l.type){g=0;for(var r in l.init)j="ls_"+m+"_"+g,e=l.init[r],q=e.name?e.name:r,p+="<li><div class='geomap-legend-element'><div id='"+j+"' class='geomap-legend-symbol'></div><span class='geomap-legend-symbol-text'><small>"+q+"</small></span></div></li>",o.push({id:j,feature:n,symbolizer:e}),g+=1}else"undefined"!=typeof l&&"symbol"===l.type?(j="ls_"+m+"_0",e=l.init,q=e.name?e.name:"",p+="<li><div class='geomap-legend-element'><div id='"+j+"' class='geomap-legend-symbol'></div><span class='geomap-legend-symbol-text'><small>"+q+"</small></span></div></li>",o.push({id:j,feature:n,symbolizer:e})):(j="ls_"+m+"_0",e={fillColor:l.fillColor,strokeColor:l.strokeColor,strokeWidth:l.strokeWidth,strokeDash:l.strokeDash},p+="<li><div class='geomap-legend-element'><div id='"+j+"' class='geomap-legend-symbol'></div><span class='geomap-legend-symbol-text'><small>"+q+"</small></span></div></li>",o.push({id:j,feature:n,symbolizer:e}));for(a("#sb_"+m).html("<ul class='list-unstyled'>"+p+"</ul>"),f=0,h=o.length;f!==h;f+=1){var s=o[f];k.getSymbol(s.id,s.feature,s.symbolizer)}}},r.prototype.getSymbol=function(a,b,c){var d,e,f,g,h=u(),i=b&&b.getGeometry()?b.getGeometry().getType():"Polygon",j=c.fillOpacity?c.fillOpacity:c.graphicOpacity?c.graphicOpacity:1,k=c.fillColor?B(c.fillColor,j):h.transparent,l=c.pointRadius?c.pointRadius:5,m=c.strokeColor?B(c.strokeColor):h.transparent,n=c.strokeWidth?c.strokeWidth:1,o=c.strokeDash?c.strokeDash:[1,0],p=c.externalGraphic?c.externalGraphic:null,q=c.graphicName?c.graphicName:null,r=c.graphicHeight?c.graphicHeight:30,s=c.graphicWidth?c.graphicWidth:30,v=2*l>r?2*l:r,C=2*l>s?2*l:s;switch(i){case"Polygon":d=new ol.Feature({geometry:new ol.geom.Polygon([[[-10,-7],[10,-7],[10,7],[-10,7]]])}),g=z({fill:new ol.style.Fill({color:k}),stroke:new ol.style.Stroke({color:m,width:n,lineDash:o})}),d.setStyle(g);break;case"Point":d=new ol.Feature({geometry:new ol.geom.Point([0,0])}),g=q?w({symbol:q,fill:new ol.style.Fill({color:k}),stroke:new ol.style.Stroke({color:m,lineDash:o}),radius:l}):p?x({src:p,opacity:j,size:[s,r]}):y({radius:l,fill:new ol.style.Fill({color:k}),stroke:new ol.style.Stroke({color:m,width:n,lineDash:o})}),d.setStyle(g);break;case"LineString":d=new ol.Feature({geometry:new ol.geom.LineString([[-9,-4],[-4,4],[4,-4],[9,4]])}),g=A({stroke:new ol.style.Stroke({color:m,width:n,lineDash:o})}),d.setStyle(g);break;default:d=new ol.Feature({geometry:new ol.geom.Polygon([[[-10,-7],[10,-7],[10,7],[-10,7]]])}),g=z({fill:new ol.style.Fill({color:k}),stroke:new ol.style.Stroke({color:m,width:n,lineDash:o})}),d.setStyle(g)}e=new ol.Map({controls:[],interactions:[],layers:[new ol.layer.Vector({source:new ol.source.Vector})]}),e&&(this.symbolMapArray.push(e),f=e.getLayers().item(0).getSource(),f.clear(),f.addFeature(d)),e.setTarget(a),t(a,e,d,C,v)},r.prototype.refresh=function(){if(0!==this.symbolMapArray.length){var b,c;for(b=this.symbolMapArray.length-1;-1!==b;b-=1)c=this.symbolMapArray[b],a("#"+c.getTarget()).is(":visible")&&c.updateSize()}},ol.inherits(O,ol.control.Control),ol.inherits(M,ol.control.Control),ol.inherits(N,ol.control.Control),d.doc.on("submit",".wb-geomap-filter",function(b){b.preventDefault();var d=a(this),e=c.getElementById(d.data("bind-to")).geomap;d.find("select[data-filter]").each(function(){var b=a(this),c=b.find("option:selected"),d=c.val(),f=b.attr("data-filter");"aoi"===f&&e.zoomAOI(d),"layer"===f&&e.showLayer(d,!0)})}),d.doc.on("click",".wb-geomap-filter [type=reset]",function(){var b=a(this.form),d=c.getElementById(b.data("bind-to")).geomap,e=d.map,f=e.getView();e.getView().fit(f.calculateExtent(e.getSize()),e.getSize()),b.find("select[data-filter=layer] option").each(function(){this.defaultSelected&&d.showLayer(this.value,!0)}),b.find("select[data-filter=aoi] option").each(function(){this.defaultSelected&&d.zoomAOI(this.value)})})}(jQuery,window,document,wb);