text: (function(k){k(window.jQuery,window._,window.ol)})(function(k,u,e){var q=0;k.widget("s3.showMap",{options:{id:"default_map",i18n:{loading:"Loading",requires_login:"Requires Login"},lat:0,lon:0,zoom:0,layers_osm:[]},_create:function(){this.id=q;q+=1;this.eventNamespace=".s3Map";this.proxyHost=S3.Ap.concat("/gis/proxy?url=")},_init:function(b){this.refresh()},_destroy:function(){k.Widget.prototype.destroy.call(this)},refresh:function(){var b=this.options,c=this.addLayers();this.map=b=new e.Map({layers:c,
  target:b.id,view:new e.View({center:e.proj.fromLonLat([b.lon,b.lat]),zoom:b.zoom})});this.tooltip=c=k("#"+this.options.id+" .s3-gis-tooltip");c=new e.Overlay({element:c[0],positioning:"bottom-center",stopEvent:!1,offset:[0,-15]});b.addOverlay(c);this.tooltip_ol=c;this._bindEvents(b)},addLayers:function(){var b=[];this.addLayersOSM(b);this.addLayersGeoJSON(b);return b},addLayersOSM:function(b){for(var c,a,d=this.options.layers_osm||[],l,h,g=0;g<d.length;g++)a=d[g],c=void 0!=a.attribution?[a.attribution]:
  [e.source.OSM.ATTRIBUTION],l=void 0!=a.maxZoom?a.maxZoom:19,h=void 0!=a.base?a.base:!0,a=void 0!=a.url?a.url:"https://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png",c={attributions:c,maxZoom:l,opaque:h,url:a},b.push(new e.layer.Tile({source:new e.source.OSM(c)}))},addLayersGeoJSON:function(b){var c=this.options,a=c.layers_feature||[];var d=c.layers_geojson||[];var l=c.layers_georss||[];var h=c.layers_shapefile||[];var g=c.layers_theme||[];c=(c.feature_queries||[]).concat(c.feature_resources||[]).concat(a).concat(d).concat(l).concat(h).concat(g);
  for(a=0;a<c.length;a++)d=c[a],h=void 0!=d.projection?new e.format.GeoJSON({dataProjection:"EPSG:"+d.projection}):new e.format.GeoJSON({dataProjection:"EPSG:4326"}),l=this.layerStyle(d),g=d.url,h=new e.source.Vector({url:g,format:h}),l=new e.layer.Vector({source:h,style:l}),void 0!=d.popup_format&&(l.s3_popup_format=d.popup_format),d=void 0!=d.type?d.type:"feature",l.s3_layer_type=d,b.push(l)},layerStyle:function(b){if(void 0!==b.marker)b=new e.style.Style({image:new e.style.Icon({src:S3.Ap.concat("/static/img/markers/"+
  b.marker.i)})});else if(void 0!==b.marker)b=b.style;else{b=new e.style.Fill({color:"rgba(255,255,255,0.4)"});var c=new e.style.Stroke({color:"#3399CC",width:1.25}),a=new e.style.Icon({src:S3.Ap.concat("/static/img/markers/"+this.options.marker)}),d={Point:new e.style.Style({image:a}),LineString:new e.style.Style({stroke:c}),MultiLineString:new e.style.Style({stroke:c}),MultiPoint:new e.style.Style({image:a}),MultiPolygon:new e.style.Style({stroke:c,fill:b}),Polygon:new e.style.Style({stroke:c,fill:b}),
  GeometryCollection:new e.style.Style({stroke:c,fill:b,image:a}),Circle:new e.style.Style({stroke:c,fill:b})};b=function(c){return d[c.getGeometry().getType()]}}return b},addPopup:function(b,c,a,d,l){var h=this.map;c=this.id+"_"+c.ol_uid+"_"+b.get("id")+"_popup";l&&a?(0===a.indexOf("http://")&&(a=this.proxyHost+encodeURIComponent(a)),d='<iframe src="'+a+'" onload="S3.gis.popupLoaded(\''+c+'\')" class="loading" marginWidth="0" marginHeight="0" frameBorder="0"></iframe>'):void 0==d&&(d=this.options.i18n.loading+
  '...<div class="throbber"></div>');k("#"+this.options.id).append('<div id="'+c+'" class="s3-gis-popup"><div class="s3-gis-popup-close"></div><div class="s3-gis-popup-content"></div></div>');var g=k("#"+c),m=new e.Overlay({element:g[0],positioning:"bottom-center",offset:[0,-12]});h.addOverlay(m);b=b.getGeometry().getCoordinates();m.setPosition(b);k("#"+c+" .s3-gis-popup-content").html(d);g.show();k("#"+c+" .s3-gis-popup-close").on("click",{id:c,map:h,overlay:m},this.removePopup);l||void 0==a||this._loadDetails(a,
  c,g)},removePopup:function(b){b.data.map.removeOverlay(b.data.overlay);k("#"+b.data.id).remove();b.preventDefault()},_loadDetails:function(b,c,a){var d=this;0===b.indexOf("http://")&&(b=this.proxyHost+encodeURIComponent(b));k.ajaxS3({url:b,dataType:"html",success:function(b){try{k("#"+c+" .s3-gis-popup-content").html(b),k("#"+c+" a.btn.iframe").click(function(){var b=k(this).attr("href");0===b.indexOf("http://")&&(b=d.proxyHost+encodeURIComponent(b));b='<iframe src="'+b+'" onload="S3.gis.popupLoaded(\''+
  c+'\')" class="loading" marginWidth="0" marginHeight="0" frameBorder="0"></iframe>';k("#"+c+" .s3-gis-popup-content").html(b);return!1})}catch(h){}},error:function(b,a,g){msg="UNAUTHORIZED"==g?d.options.i18n.requires_login:b.responseText;k("#"+c+" .s3-gis-popup-content").html(msg)}})},_deserialize:function(){},_bindEvents:function(b){var c=this,a,d,e,h,g,m,r,n,v,t,q;b.on("pointermove",function(f){if(f.dragging)c.tooltip.hide();else if(t=b.forEachFeatureAtPixel(f.pixel,function(b,c){return{feature:b,
  layer:c}})){g=t.feature;n=t.layer;e=g.getGeometry().getCoordinates();c.tooltip_ol.setPosition(e);if(void 0!=n.s3_popup_format){u.templateSettings={interpolate:/\{(.+?)\}/g};v=n.s3_popup_format;q=u.template(v);a={};h={};r=v.split("{");for(f=0;f<r.length;f++)m=r[f].split("}")[0],a[m]=g.get(m),h[m]="";u.defaults(a,h);d=q(a)}else void 0!=a.popup?d=g.get("popup"):void 0!=g.get("name")?d=g.get("name"):void 0!=n.title&&(f=g.get(n.title),d="object"==typeof f?f.value:f);c.tooltip.html(d).show()}else c.tooltip.hide()});
  b.on("click",function(f){if(t=b.forEachFeatureAtPixel(f.pixel,function(a,b){return{feature:a,layer:b}})){c.tooltip.hide();g=t.feature;n=t.layer;var a=g.getProperties();f=n.s3_layer_type;if("kml"==f){f=void 0!=n.title?n.title:"name";if(void 0!=g.style.balloonStyle)var d=g.style.balloonStyle.replace(/{([^{}]*)}/g,function(b,c){c=a[c];return"string"===typeof c||"number"===typeof c?c:b});else{var e=typeof a[f];f="object"==e?a[f].value:a[f];d="<h3>"+f+"</h3>";f=n.body.split(" ");for(var h,l,p=0;p<f.length;p++)e=
  typeof a[f[p]],"object"==e?(e=a[f[p]].displayName,""===e&&(e=f[p]),l=a[f[p]].value,h='<div class="gis_popup_row"><div class="gis_popup_label">'+e+':</div><div class="gis_popup_cell">'+l+"</div></div>"):h=void 0!=a[f[p]]?'<div class="gis_popup_row">'+a[f[p]]+"</div>":"",d+=h}-1!=d.search("<script")&&(d="Content contained Javascript! Escaped content below.<br />"+d.replace(/</g,"<"))}else if("gpx"!=f)if("shapefile"==f||"geojson"==f)d="<div>",k.each(a,function(a,b){"id_orig"==a&&(a="id");h='<div class="gis_popup_row"><div class="gis_popup_label">'+
  a+':</div><div class="gis_popup_cell">'+b+"</div></div>";d+=h}),d+="</div>";else if("wfs"==f)f=void 0!=n.title?n.title:"name",f=a[f],d="<h3>"+f+"</h3>",k.each(a,function(a,b){h='<div class="gis_popup_row"><div class="gis_popup_label">'+a+':</div><div class="gis_popup_val">'+b+"</div></div>";d+=h});else if(void 0!=a.url)var m=a.url;else if(void 0!=n.s3_url_format)u.templateSettings={interpolate:/\{(.+?)\}/g},m=u.template(n.s3_url_format),a.id.constructor===Array&&(a.id=a.id[0]),m=m(a);else{name=void 0==
  a.name?"":"<h3>"+a.name+"</h3>";f=void 0==a.description?"":"<p>"+a.description+"</p>";p=void 0==a.link?"":'<a href="'+a.link+'" target="_blank">'+a.link+"</a>";if(void 0==a.data)e="";else if(0===a.data.indexOf("http://")){var q=!0;var r=S3.uid();e='<div id="'+r+'">'+c.options.i18n.loading+"...<div class='throbber'></div></div>"}else e="<p>"+a.data+"</p>";l=void 0==a.image?"":0===a.image.indexOf("http://")?'<img src="'+a.image+'" height=300 width=300>':"";d=name+f+p+e+l}m=c.addPopup(g,n,m,d);q&&c._loadDetails(a.data,
  r,m)}})},_unbindEvents:function(){return!0}})});
  