Y-SLD/assets/playkit/js/group-maps.js

2 lines
45 KiB
JavaScript

function toWKT(e){var t,n,r=[];if(e instanceof L.Polygon||e instanceof L.Polyline){for(var a=e.getLatLngs(),i=0;i<a.length;i++)a[i],r.push(a[i].lng+" "+a[i].lat),0===i&&(t=a[i].lng,n=a[i].lat);if(e instanceof L.Polygon)return"POLYGON(("+r.join(",")+","+t+" "+n+"))";if(e instanceof L.Polyline)return"LINESTRING("+r.join(",")+")"}else if(e instanceof L.Marker)return"POINT("+e.getLatLng().lng+" "+e.getLatLng().lat+")"}function renderLayer(e,t){if("undefined"==typeof featureGroup[e.unique_id]&&(featureGroup[e.unique_id]=new Array),2==e.type&&"undefined"!=typeof e.cluster&&1==e.cluster?featureGroup[e.unique_id][e.name]=new L.MarkerClusterGroup:featureGroup[e.unique_id][e.name]=new L.FeatureGroup,"undefined"!=typeof e.settings?1==e.settings.active?(add_current_layer_text(e),featureGroup[e.unique_id][e.name].addTo(mymap)):e.settings.active=0:(featureGroup[e.unique_id][e.name].addTo(mymap),e.settings=new Object,e.settings.active=1),1==e.settings.active&&(activeLayers.push({id:e._id,order:0}),order_current_active_layers()),"phantom"==page&&($.inArray(e._id,active_ids)!==-1?featureGroup[e.unique_id][e.name].addTo(mymap):1==e.settings.active&&mymap.removeLayer(featureGroup[e.unique_id][e.name])),"undefined"!=typeof page&&"user_farm"==page&&1==e.settings.active&&jQuery("#chk_"+e.unique_id).prop("checked","checked"),"undefined"!=typeof page&&"manage"==page&&(jQuery("#active-layers-container").append(Mustache.render(tmpl.activeLayer,{t:e,type:layerType[e.type]})),0==e.settings.active&&jQuery("#at-"+e.unique_id+" a.dropdown-toggle span").addClass("label-danger").removeClass("label-primary"),jQuery(".help-active-popup-hover").popover({title:"Active & In-Active",content:'<div class="row"><div class="col-md-12"><p>This feature allows you to initially hide a layer. This can be used to achieve a desired layer presentation as well as to provide faster map loading for larger layers.</p></div></div>',html:!0,trigger:"hover",container:"body"}),jQuery(".at_active_chk").bootstrapSwitch({size:"mini",onSwitchChange:function(t,n){t.preventDefault();var r=jQuery(this).parents("ul:first"),a=r.attr("data-id"),i=getIndex(selectedLayers,"unique_id",a);selectedLayers[i].settings||"undefined"!=typeof selectedLayers[i].settings||(selectedLayers[i].settings=new Object),n===!0?(selectedLayers[i].settings.active=1,jQuery("#at-"+e.unique_id+" a.dropdown-toggle span").removeClass("label-danger").addClass("label-primary"),mymap.addLayer(featureGroup[a][selectedLayers[i].name])):(selectedLayers[i].settings.active=0,jQuery("#at-"+e.unique_id+" a.dropdown-toggle span").addClass("label-danger").removeClass("label-primary"),mymap.removeLayer(featureGroup[a][selectedLayers[i].name])),calculateBounds()}})),1==e.type||4==e.type){var n={format:"image/png",layers:e.Name,transparent:!0,crs:L.CRS.EPSG4326,unique_id:e.unique_id,srs1:e.SRS,layer_type:e.type};"undefined"!=typeof e.geometry_area&&(n.geometry=e.geometry_area),"undefined"!=typeof e.time&&(n.time=e.time),L.tileLayer.betterWms(e.url,n).addTo(featureGroup[e.unique_id][e.name])}else 2==e.type?""==t?"phantom"==page?filterGlobalData():(e.cache_timer||"undefined"!=typeof e.cache_timer||(e.cache_timer=15),t={datasource:e.connection_id,sql_layer_name:e.name,query_box:e.query,_token:jQuery('[name="_token"]').val(),cache_key:e.cache_key,cache_timer:e.cache_timer,type:2,map_id:map.id},ajaxRequest("map/layer/json","post","json",t,function(t){"200"==t.status?processSQLJSON(t,e):showMsg(t.status,t.msg)})):processSQLJSON(t,e):3==e.type;overlayers_controls(e),overlays[e.name]=featureGroup[e.unique_id][e.name],layerSelector.addOverlay(featureGroup[e.unique_id][e.name],e.name),3==e.type&&jQuery("#at-"+e.unique_id).find(".style-at-layer").remove(),calculateBounds()}function getPopupContent(e,t){return $.each(e.features,function(e,n){$.each(n.properties,function(e,n){t=t.replace("&lt;"+e+"&gt;",n)})}),t}function processSQLJSON(e,t){t=defaultLayerStyle(t),3==e.more_data.sql_type?processheatmapJSON(e,t):(clearLayersAndControls(e,t),jQuery.each(e.result,function(e,n){L.geoJson(n,{onEachFeature:function(e,n){if(n instanceof L.Marker){var r=!1;"nr"==t.style.type?$.each(t.style.custom,function(a,i){if(between(e.properties[t.style.field],i.val))return r=!0,custom_marker_icon(i.style,n),!1}):"g"==t.style.type&&$.each(t.style.custom,function(a,i){if(e.properties[t.style.field]==i.val)return r=!0,custom_marker_icon(i.style,n),!1}),0==r&&custom_marker_icon(t.style.marker,n)}n.on("click",function(r){var a=getSQLPopupContent(e.properties,t.pc);n.bindPopup(a)})},style:function(e,n){return t.style.polygon}}).addTo(featureGroup[t.unique_id][t.name])}),1==t.settings.active&&add_sql_legend(t,!0),"phantom"==page&&add_sql_legend(t,!0))}function initLayer(){selectedLayers.sort(sort_value_layer),selectedBaseLayers.length>0&&jQuery("#visiable-layers").find(".baselayers-control").removeClass("hide"),jQuery.each(selectedBaseLayers,function(e,t){if(layerSelector.addBaseLayer(baseLayers.mymap[t.name],t.name),baselayers_controls(t.name),"undefined"!=typeof page&&"manage"==page){var n=jQuery("#base_layer_selection").find('input:checkbox[data-name="'+t.name+'"]');n.length>0&&(n.prop("checked","checked"),baseLayerMap(n,!1))}}),jQuery.each(selectedLayers,function(e,t){renderLayer(t,"")});var e={type:5,id:map.id,_token:jQuery('[name="_token"]').val()};ajaxRequest("map/layer/json","post","json",e,function(e){"200"==e.status?processFreeHand(e):showMsg(e.status,e.msg)});var e={type:6,id:map.id,_token:jQuery('[name="_token"]').val()};ajaxRequest("map/layer/json","post","json",e,function(e){"200"==e.status?processFreeHand(e):showMsg(e.status,e.msg)});var e={type:3,id:map.id,_token:jQuery('[name="_token"]').val()};ajaxRequest("map/layer/json","post","json",e,function(e){"200"==e.status?processFreeHand(e):showMsg(e.status,e.msg)});var e={type:"farm_boundary",id:map.id,_token:jQuery('[name="_token"]').val()};if(ajaxRequest("map/layer/json","post","json",e,function(e){"200"==e.status?isEmpty(e.result)||custom_boundary(e,"farm","boundary"):showMsg(e.status,e.msg)}),"undefined"!=typeof page&&"user_farm"==page){var e={type:"draw_boundary",id:map.id,_token:jQuery('[name="_token"]').val()};ajaxRequest("map/layer/json","post","json",e,function(e){"200"==e.status?isEmpty(e.result)||custom_boundary(e,"draw",e.name):showMsg(e.status,e.msg)})}}function processFreeHand(e){jQuery.each(e.result,function(e,n){index=getIndex(selectedLayers,"unique_id",e),t=selectedLayers[index],"undefined"==typeof featureGroup[t.unique_id]&&(featureGroup[t.unique_id]=new Array),featureGroup[t.unique_id][t.name]=new L.FeatureGroup,"undefined"!=typeof t.settings?1==t.settings.active?featureGroup[t.unique_id][t.name].addTo(mymap):t.settings.active=0:(featureGroup[t.unique_id][t.name].addTo(mymap),t.settings=new Object,t.settings.active=1),L.geoJson(n,{onEachFeature:function(e,n){selectedLayers[index].layer=n,1==t.settings.active&&drawingGroup.addLayer(n),featureGroup[t.unique_id][t.name].addLayer(n),n instanceof L.Marker&&n.setIcon(L.AwesomeMarkers.icon(selectedLayers[index].style.marker)),n.bindPopup(selectedLayers[index].pc)},style:function(e,n){return t.style.polygon},pointToLayer:function(e,n){return"undefined"!=typeof t.radius?L.circle(n,parseInt(t.radius,10)):L.marker(n)}})}),calculateBounds()}function custom_boundary(e,t,n){featureGroup[t]=new Array,featureGroup[t][n]=new L.FeatureGroup,"manage"==page&&featureGroup[t][n].addTo(mymap),jQuery.each(e.result,function(e,r){L.geoJson(r,{onEachFeature:function(e,r){featureGroup[t][n].addLayer(r)},style:function(e,t){return e.style},pointToLayer:function(e,t){return"undefined"!=typeof e.properties.radius?L.circle(t,parseInt(e.properties.radius,10)):L.marker(t)}})}),"boundary"==n&&mymap.fitBounds(featureGroup[t][n].getBounds())}function calculateBounds(){}function extend_bounds(e){}function getLayersIndex(e){var t=selectedLayers.length;for(i=0;i<t;i++)if(selectedLayers[i].unique_id==e)return i}function getIndex(e,t,n){var r=e.length;for(i=0;i<r;i++)if(e[i][t]==n)return i}function getSQLPopupContent(e,t){return $.each(e,function(e,n){"image"==e?(n='<a href="'+baseURL+n+'" target="_blank"><img src="'+baseURL+n+'" style="width:50px" /></a>',t=t.replace("&lt;"+e+"&gt;",n)):t=t.replace("&lt;"+e+"&gt;",n)}),t}function defaultSettings(){map.settings=""!=map.settings?JSON.parse(map.settings):new Object,"undefined"==typeof map.settings.width&&(map.settings.width=500),"undefined"==typeof map.settings.height&&(map.settings.height=500),"undefined"==typeof map.settings.zoom&&(map.settings.zoom=6),"undefined"==typeof map.settings.fullscreen&&(map.settings.fullscreen=1),"undefined"==typeof map.settings.https&&(map.settings.https=1)}function assingSettings(){}function saveMapData(e,t){var n=selectedLayers.length,r=new Array;for(i=0;i<n;i++){var a=jQuery.extend(!0,{},selectedLayers[i]);3!=a.type&&5!=a.type&&6!=a.type||(a.layer instanceof L.Circle&&(a.radius=a.layer.getRadius()),"undefined"!=typeof a.layer&&(a.layer=a.layer.toGeoJSON())),r.push(a)}var o={selectedLayers:r,selectedBaseLayers:selectedBaseLayers};jQuery("#action_type").val(e);var u=JSON.stringify(o);jQuery("#layer_json").val(u),jQuery("#section_id_hidden").val(jQuery("#dd_section_id").val());var s=jQuery("#layer-form, #map-settings-form").serialize();ajaxRequest("/developer/map/save","post","json",s,function(e){200==e.status?(jQuery("#map_id").val(e.map_id),t(e)):showMsg("error",e.msg)})}function sortLayers(){var e=new Array;$("#visiable-layers div.dropdown-menu .custom-control-layers").find("li").each(function(t){var n=$(this).attr("data-key");e[t]=n,t++}),$.each(e,function(e,t){var n=getIndex(selectedLayers,"unique_id",t);selectedLayers[n].order=e+1})}function overlayers_controls(e){var t="map-overlayer-controls-tmpl";"undefined"!=typeof ct_theme&&(t=ct_theme+t);var n=document.getElementById(t).innerHTML;Mustache.parse(n),(2!=e.type||"nr"!=e.style.type&&"g"!=e.style.type)&&("undefined"!=typeof page&&"user_farm"==page||$("<li/>").attr("data-key",e.unique_id).attr("data-name",e.name).addClass("overlay_control_"+e.unique_id).html(Mustache.render(n,e)).appendTo("#visiable-layers div.dropdown-menu .custom-control-layers").find('input[type="checkbox"]').bootstrapSwitch({size:"mini",onSwitchChange:function(e,t){e.preventDefault();var n=jQuery(this).parents("li:first"),r=n.attr("data-key"),a=n.attr("data-name"),i=getIndex(selectedLayers,"unique_id",r);selectedLayers[i];t===!0?mymap.addLayer(featureGroup[r][a]):mymap.removeLayer(featureGroup[r][a])}})),"undefined"!=typeof page&&"manage"==page&&$("#visiable-layers div.dropdown-menu .custom-control-layers").sortable({stop:sortLayers}).disableSelection()}function addSubOverLayer(e){var t=jQuery('li[data-key="'+e.unique_id+'"]'),n=document.getElementById("map-overlayer-sub-controls-tmpl").innerHTML;$.each(e.style.custom,function(r,a){$("<li/>").attr("data-key",e.unique_id).attr("data-name",e.name).attr("data-val",a.val).html(Mustache.render(n,{val:a.val,t:e})).appendTo(t.find("ul")).find('input[type="checkbox"]').bootstrapSwitch({size:"mini",onSwitchChange:function(e,t){e.preventDefault();var n=jQuery(this).parents("li:first"),r=n.attr("data-key"),a=n.attr("data-name"),i=n.attr("data-val"),o=getIndex(selectedLayers,"unique_id",r),u=selectedLayers[o],s=featureGroup[r][a].getLayers();$.each(s,function(e,n){n.eachLayer(function(e){"nr"==u.style.type?between(e.feature.properties[u.style.field],i)&&(t===!0?mymap.addLayer(e):mymap.removeLayer(e)):"g"==u.style.type&&e.feature.properties[u.style.field]==i&&(t===!0?mymap.addLayer(e):mymap.removeLayer(e))})})}})}),jQuery(".subcontrol-layer-action").slimScroll({alwaysVisible:!0,height:100}),jQuery(".submenu-overlay-controls").click(function(e){e.preventDefault();var t=jQuery(this);t.toggleClass("in");var n=$(t.attr("href"));return n.hasClass("in")?n.collapse("hide"):n.collapse("show"),!1})}function baselayers_controls(e){var t=document.getElementById("map-baselayer-controls-tmpl").innerHTML;Mustache.parse(t),$("<li/>").attr("data-name",e).addClass("baselayer_control_"+e).html(Mustache.render(t,{name:e})).prependTo("#visiable-layers div.dropdown-menu .baselayers-control-layers").find('input[type="radio"]').bootstrapSwitch({size:"mini",onSwitchChange:function(e,t){e.preventDefault();var n=jQuery(this).parents("li:first"),r=n.attr("data-name");$.each(baseLayers.mymap,function(e,t){mymap.removeLayer(baseLayers.mymap[e])}),t===!0&&mymap.addLayer(baseLayers.mymap[r])}})}function removeOverlayerControl(e){jQuery("#visiable-layers").find(".overlay_control_"+e).remove()}function applyLiveStyle(e){var t=jQuery('#map-sidebar-container [name="my_unique_id"]').val(),n=getIndex(selectedLayers,"unique_id",t),r={};jQuery("#layer-polygon-styling input").each(function(){var e=jQuery(this);r[e.attr("name")]=e.val()});var a={};if(jQuery("#layer-marker-styling .default-marker-style select").each(function(){var e=jQuery(this);a[e.attr("data-name")]=e.val()}),2==selectedLayers[n].type){var i=featureGroup[selectedLayers[n].unique_id][selectedLayers[n].name].getLayers();$.each(i,function(e,t){t.eachLayer(function(e){e instanceof L.Marker?custom_marker_icon(a,e):(e instanceof L.Polyline||e instanceof L.Polygon||e instanceof L.Rectangle||e instanceof L.Circle)&&e.setStyle(r)})})}else if(3==selectedLayers[n].type){var o=selectedLayers[n].layer;o instanceof L.Marker?custom_marker_icon(a,o):(o instanceof L.Polyline||o instanceof L.Polygon||o instanceof L.Rectangle||o instanceof L.Circle)&&o.setStyle(r)}selectedLayers[n].style.polygon=r,selectedLayers[n].style.marker=a}function defaultLayerStyle(e){var t=new Object,n=new Object;"undefined"==typeof e.style&&(e.style=new Object),"undefined"!=typeof e.style.polygon?t=e.style.polygon:e.style.polygon=new Object,"undefined"!=typeof e.style.marker?n=e.style.marker:e.style.marker=new Object,"undefined"==typeof t.color&&(t.color="#ccc"),"undefined"==typeof t.opacity&&(t.opacity=1),"undefined"==typeof t.fillOpacity&&(t.fillOpacity=1),"undefined"==typeof t.fillColor&&(t.fillColor="#ccc"),"undefined"==typeof t.weight&&(t.weight=1),"undefined"==typeof n.icon&&(n.icon=""),"undefined"==typeof n.color&&(n.color="blue"),e.style.polygon=t,e.style.marker=n;var r=getIndex(selectedLayers,"unique_id",e.unique_id);return selectedLayers[r].style=e.style,e}function getLayerIndex1(e){var t=selectedLayers.length;for(i=0;i<t;i++)if(3==selectedLayers[i].type&&selectedLayers[i].layer==e)return i}function between(e,t){e=parseFloat(e);var n=t.split("-");return e>=n[0]&&e<=n[1]}function getMarkerStyle(e){if(""==e.markerColor){var t=jQuery("#default_style_marker_color").val();""!=t?e.markerColor=t:e.markerColor="blue"}if(""==e.icon){var n=jQuery("#default_style_marker_icon").val();""!=n?e.icon=n:e.icon=""}return e}function isEmpty(e){if(null==e)return!0;if(e.length>0)return!1;if(0===e.length)return!0;if("object"!=typeof e)return!0;for(var t in e)if(hasOwnProperty.call(e,t))return!1;return!0}function custom_marker_icon(e,t){var n=e.icon;if(n.indexOf(".png")!==-1){var r=baseURL+"assets/img/markers/"+e.markerColor+"-"+e.icon,a=L.Icon.extend({options:{iconUrl:r}});t.setIcon(new a)}else t.setIcon(L.AwesomeMarkers.icon(e))}function tinyMCEInit_Popup(e){tinyMCE.init({selector:e,theme:"modern",plugins:[],toolbar1:"insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image jbimages",toolbar2:"print preview media | forecolor backcolor emoticons | mapshapes",image_advtab:!0,relative_urls:!1,remove_script_host:!1,convert_urls:!0,autosave_ask_before_unload:!1,extended_valid_elements:"a[onclick|style|href|title|id|class|target]",setup:function(e){e.on("change",function(t){var n=jQuery(e.targetElm),r=getIndex(selectedLayers,"unique_id",n.attr("data-uniqueid"));selectedLayers[r].pc=e.getContent()})}})}function runFilterElementJS(){if(jQuery(".datepicker").length>0&&jQuery(".datepicker").datepicker({format:"yyyy-mm-dd",autoclose:!0}),jQuery(".input-daterange").length>0&&$(".input-daterange input.form-control").each(function(){$self1=$(this),$self1.daterangepicker({format:"YYYY-MM-DD",autoclose:!0,ranges:{Today:[moment(),moment()],Yesterday:[moment().subtract(1,"days"),moment().subtract(1,"days")],"Last 7 Days":[moment().subtract(6,"days"),moment()],"Last 30 Days":[moment().subtract(29,"days"),moment()],"This Month":[moment().startOf("month"),moment().endOf("month")],"Last Month":[moment().subtract(1,"month").startOf("month"),moment().subtract(1,"month").endOf("month")]}}).on("apply.daterangepicker",function(e,t){var n=$self1.attr("data-startname"),r=$self1.attr("data-endname");$self1.parents(".input-daterange:first").find('[name="'+n+'"]').val(t.startDate.format("YYYY-MM-DD")),$self1.parents(".input-daterange:first").find('[name="'+r+'"]').val(t.endDate.format("YYYY-MM-DD"))})}),jQuery(".dbisunique").length>0){var e=jQuery("select.dbisunique");e.each(function(){jQuery(this).select2({placeholder:"Select Filter",width:"100%"})})}}function filterGlobalData(){$.each(selectedLayers,function(e,t){if(2==t.type){var n=jQuery("#global_filter").serializeArray();n.push({name:"type",value:2}),n.push({name:"datasource",value:t.connection_id}),n.push({name:"layer_id",value:t._id}),n.push({name:"map_id",value:map.id}),n.push({name:"_token",value:jQuery('[name="_token"]').val()}),n.push({name:"sql_layer_name",value:t.name}),n.push({name:"query_box",value:t.query}),n.push({name:"cache_key",value:t.cache_key}),n.push({name:"cache_timer",value:0}),ajaxRequest("map/layer/json","post","json",n,function(e){"200"==e.status?processSQLJSON(e,t):showMsg(e.status,e.msg)})}})}function clearLayersAndControls(e,t){layer=featureGroup[t.unique_id][t.name],layer&&layer.clearLayers()}function getSQLFeatureData(e){var t=featureGroup[e.unique_id][e.name].getLayers(),n=new Array,r=0;return $.each(t,function(t,a){"undefined"!=typeof e.cluster&&1==e.cluster?n[r++]=a.feature.properties:a.eachLayer(function(e){n[r++]=e.feature.properties})}),n}function processheatmapJSON(e,t){"undefined"==typeof heatmap[t.unique_id]?heatmap[t.unique_id]=L.heatLayer(e.result,{radius:30}).addTo(featureGroup[t.unique_id][t.name]):heatmap[t.unique_id].setLatLngs(e.result).setOptions({radius:30}).redraw()}function deleteLayer(e){var t=getLayersIndex(e);3==selectedLayers[t].type&&drawingGroup.removeLayer(selectedLayers[t].layer),jQuery("#at-"+e).remove(),selectedLayers.splice(t,1),saveMapData("map",function(e){showMsg("success","Map saved successfully.")}),featureGroup[selectedLayers[t].unique_id][selectedLayers[t].name].clearLayers(),layerSelector.removeLayer(featureGroup[selectedLayers[t].unique_id][selectedLayers[t].name])}function add_sql_legend(e,t){1==t&&(2!=e.type||"nr"!=e.style.type&&"g"!=e.style.type||(legend[e.unique_id]=L.control({position:"bottomright"}),legend[e.unique_id].onAdd=function(t){var n=L.DomUtil.create("div","info mapfig-legend");return n.innerHTML+='<h6 class="map-legend-title">'+e.name+"</h6>",$.each(e.style.custom,function(e,t){var r=t.style.icon;if(r.indexOf(".png")!==-1){var a=baseURL+"assets/img/markers/"+t.style.markerColor+"-"+t.style.icon;n.innerHTML+='<div class="map-legend"><img src="'+a+'" height="20"/><div class="legend-text">'+t.val+"</div></div>"}else n.innerHTML+='<div class="map-legend"><i class="fa fa-map-marker" style="color:'+t.style.markerColor+' !important"></i><div class="legend-text">'+t.val+"</div></div>"}),n},mymap.addControl(legend[e.unique_id])))}function user_sidebar_chk(){"undefined"!=typeof page&&"user_farm"==page&&jQuery(".custom-theme-sidebar,#current-active-layer").on("change",'input[type="checkbox"]',function(e){e.preventDefault();var t=jQuery(this),n=t.is(":checked"),r=t.parents("li:first"),a=r.attr("data-key"),i=r.attr("data-name"),o=getIndex(selectedLayers,"unique_id",a),u=selectedLayers[o];if("undefined"==typeof u)return void(n===!0?mymap.addLayer(featureGroup[a][i]):mymap.removeLayer(featureGroup[a][i]));if(n===!0)activeLayers.push({id:u._id,order:0}),order_current_active_layers(),t.hasClass("active-layer-chk")||add_current_layer_text(u),mymap.addLayer(featureGroup[u.unique_id][u.name]),featureGroup[u.unique_id][u.name].bringToFront(),add_sql_legend(u,!0);else{var o=getIndex(activeLayers,"id",u._id);activeLayers.splice(o,1),t.hasClass("active-layer-chk")||jQuery("#user-farm-at-layers-"+u.unique_id).remove(),mymap.removeLayer(featureGroup[u.unique_id][u.name]),"undefined"!=typeof legend[a]&&legend[u.unique_id].removeFrom(mymap)}})}function add_current_layer_text(e){if("undefined"!=typeof page&&"user_farm"==page){var t=document.getElementById("user-farm-active-layers-tmpl").innerHTML;Mustache.parse(t),jQuery("#current-active-layer ul").prepend(Mustache.render(t,e))}}function order_current_active_layers(){activeLayers.sort(sort_value_layer);var e=activeLayers.length;for(i=0;i<e;i++)activeLayers[i].order=activeLayers[i].order+1}function fromWKT2Json(e){var t={},n=function(e){var t=[],n=e.replace(/\)|\(/gi,"").split(",");return n.forEach(function(e){var n=e.trim().split(" "),r=parseFloat(n[0],10),a=parseFloat(n[1],10);t[t.length]=[r,a]}),t};t.POINT=function(e){var t=e.replace(/\)|\(/gi,"").trim().split(" ");return{type:"point",x:parseFloat(t[0],10),y:parseFloat(t[1],10)}},t.MULTILINESTRING=function(e){e=e.replace(/(\(\()|(\)\))/gi,"");var t=[],r=e.split("),");return r.forEach(function(e){t[t.length]=n(e)}),{type:"polyline",paths:t}},t.POLYGON=function(e){var n=t.MULTILINESTRING(e);return{type:"polygon",rings:n.paths}},t.MULTIPOLYGON=function(e){},t.MULTIPOINT=function(e){return{type:"multipoint",points:n(e)}},t.LINESTRING=function(e){return t.MULTIPOINT(e)};var r=e.split("("),a=r.shift().trim(),i="("+r.join("(").trim();return t[a](i)}function field_form_collection(e){var t={farm_id:farm_id,field_id:e};ajaxRequest("user/field/task/form","get","html",t,function(e){jQuery("#field-task-form-container .card-block").html(e),field_tasks_init()})}function calculateWindow(){var e=jQuery(window);jQuery(".map-container").height(e.height()),jQuery(".map-container").width(e.width()),jQuery("#mapid").height(e.height()),jQuery("#mapid").width(e.width())}!function(e,t){"object"==typeof exports&&exports&&"string"!=typeof exports.nodeName?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):(e.Mustache={},t(e.Mustache))}(this,function(e){function t(e){return"function"==typeof e}function n(e){return m(e)?"array":typeof e}function r(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function a(e,t){return null!=e&&"object"==typeof e&&t in e}function i(e,t){return h.call(e,t)}function o(e){return!i(v,e)}function u(e){return String(e).replace(/[&<>"'`=\/]/g,function(e){return g[e]})}function s(t,n){function a(){if(v&&!g)for(;h.length;)delete y[h.pop()];else h=[];v=!1,g=!1}function i(e){if("string"==typeof e&&(e=e.split(L,2)),!m(e)||2!==e.length)throw new Error("Invalid tags: "+e);u=new RegExp(r(e[0])+"\\s*"),s=new RegExp("\\s*"+r(e[1])),p=new RegExp("\\s*"+r("}"+e[1]))}if(!t)return[];var u,s,p,d=[],y=[],h=[],v=!1,g=!1;i(n||e.tags);for(var k,x,q,S,M,Q,O=new f(t);!O.eos();){if(k=O.pos,q=O.scanUntil(u))for(var I=0,T=q.length;I<T;++I)S=q.charAt(I),o(S)?h.push(y.length):g=!0,y.push(["text",S,k,k+1]),k+=1,"\n"===S&&a();if(!O.scan(u))break;if(v=!0,x=O.scan(j)||"name",O.scan(_),"="===x?(q=O.scanUntil(b),O.scan(b),O.scanUntil(s)):"{"===x?(q=O.scanUntil(p),O.scan(w),O.scanUntil(s),x="&"):q=O.scanUntil(s),!O.scan(s))throw new Error("Unclosed tag at "+O.pos);if(M=[x,q,k,O.pos],y.push(M),"#"===x||"^"===x)d.push(M);else if("/"===x){if(Q=d.pop(),!Q)throw new Error('Unopened section "'+q+'" at '+k);if(Q[1]!==q)throw new Error('Unclosed section "'+Q[1]+'" at '+k)}else"name"===x||"{"===x||"&"===x?g=!0:"="===x&&i(q)}if(Q=d.pop())throw new Error('Unclosed section "'+Q[1]+'" at '+O.pos);return c(l(y))}function l(e){for(var t,n,r=[],a=0,i=e.length;a<i;++a)t=e[a],t&&("text"===t[0]&&n&&"text"===n[0]?(n[1]+=t[1],n[3]=t[3]):(r.push(t),n=t));return r}function c(e){for(var t,n,r=[],a=r,i=[],o=0,u=e.length;o<u;++o)switch(t=e[o],t[0]){case"#":case"^":a.push(t),i.push(t),a=t[4]=[];break;case"/":n=i.pop(),n[5]=t[2],a=i.length>0?i[i.length-1][4]:r;break;default:a.push(t)}return r}function f(e){this.string=e,this.tail=e,this.pos=0}function p(e,t){this.view=e,this.cache={".":this.view},this.parent=t}function d(){this.cache={}}var y=Object.prototype.toString,m=Array.isArray||function(e){return"[object Array]"===y.call(e)},h=RegExp.prototype.test,v=/\S/,g={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"},_=/\s*/,L=/\s+/,b=/\s*=/,w=/\s*\}/,j=/#|\^|\/|>|\{|&|=|!/;f.prototype.eos=function(){return""===this.tail},f.prototype.scan=function(e){var t=this.tail.match(e);if(!t||0!==t.index)return"";var n=t[0];return this.tail=this.tail.substring(n.length),this.pos+=n.length,n},f.prototype.scanUntil=function(e){var t,n=this.tail.search(e);switch(n){case-1:t=this.tail,this.tail="";break;case 0:t="";break;default:t=this.tail.substring(0,n),this.tail=this.tail.substring(n)}return this.pos+=t.length,t},p.prototype.push=function(e){return new p(e,this)},p.prototype.lookup=function(e){var n,r=this.cache;if(r.hasOwnProperty(e))n=r[e];else{for(var i,o,u=this,s=!1;u;){if(e.indexOf(".")>0)for(n=u.view,i=e.split("."),o=0;null!=n&&o<i.length;)o===i.length-1&&(s=a(n,i[o])),n=n[i[o++]];else n=u.view[e],s=a(u.view,e);if(s)break;u=u.parent}r[e]=n}return t(n)&&(n=n.call(this.view)),n},d.prototype.clearCache=function(){this.cache={}},d.prototype.parse=function(e,t){var n=this.cache,r=n[e];return null==r&&(r=n[e]=s(e,t)),r},d.prototype.render=function(e,t,n){var r=this.parse(e),a=t instanceof p?t:new p(t);return this.renderTokens(r,a,n,e)},d.prototype.renderTokens=function(e,t,n,r){for(var a,i,o,u="",s=0,l=e.length;s<l;++s)o=void 0,a=e[s],i=a[0],"#"===i?o=this.renderSection(a,t,n,r):"^"===i?o=this.renderInverted(a,t,n,r):">"===i?o=this.renderPartial(a,t,n,r):"&"===i?o=this.unescapedValue(a,t):"name"===i?o=this.escapedValue(a,t):"text"===i&&(o=this.rawValue(a)),void 0!==o&&(u+=o);return u},d.prototype.renderSection=function(e,n,r,a){function i(e){return o.render(e,n,r)}var o=this,u="",s=n.lookup(e[1]);if(s){if(m(s))for(var l=0,c=s.length;l<c;++l)u+=this.renderTokens(e[4],n.push(s[l]),r,a);else if("object"==typeof s||"string"==typeof s||"number"==typeof s)u+=this.renderTokens(e[4],n.push(s),r,a);else if(t(s)){if("string"!=typeof a)throw new Error("Cannot use higher-order sections without the original template");s=s.call(n.view,a.slice(e[3],e[5]),i),null!=s&&(u+=s)}else u+=this.renderTokens(e[4],n,r,a);return u}},d.prototype.renderInverted=function(e,t,n,r){var a=t.lookup(e[1]);if(!a||m(a)&&0===a.length)return this.renderTokens(e[4],t,n,r)},d.prototype.renderPartial=function(e,n,r){if(r){var a=t(r)?r(e[1]):r[e[1]];return null!=a?this.renderTokens(this.parse(a),n,r,a):void 0}},d.prototype.unescapedValue=function(e,t){var n=t.lookup(e[1]);if(null!=n)return n},d.prototype.escapedValue=function(t,n){var r=n.lookup(t[1]);if(null!=r)return e.escape(r)},d.prototype.rawValue=function(e){return e[1]},e.name="mustache.js",e.version="2.2.1",e.tags=["{{","}}"];var k=new d;e.clearCache=function(){return k.clearCache()},e.parse=function(e,t){return k.parse(e,t)},e.render=function(e,t,r){if("string"!=typeof e)throw new TypeError('Invalid template! Template should be a "string" but "'+n(e)+'" was given as the first argument for mustache#render(template, view, partials)');return k.render(e,t,r)},e.to_html=function(n,r,a,i){var o=e.render(n,r,a);return t(i)?void i(o):o},e.escape=u,e.Scanner=f,e.Context=p,e.Writer=d}),function(){function e(e){function t(t,n,r,a,i,o){for(;i>=0&&o>i;i+=e){var u=a?a[i]:i;r=n(r,t[u],u,t)}return r}return function(n,r,a,i){r=_(r,i,4);var o=!q(n)&&g.keys(n),u=(o||n).length,s=e>0?0:u-1;return arguments.length<3&&(a=n[o?o[s]:s],s+=e),t(n,r,a,o,s,u)}}function t(e){return function(t,n,r){n=L(n,r);for(var a=x(t),i=e>0?0:a-1;i>=0&&a>i;i+=e)if(n(t[i],i,t))return i;return-1}}function n(e,t,n){return function(r,a,i){var o=0,u=x(r);if("number"==typeof i)e>0?o=i>=0?i:Math.max(i+u,o):u=i>=0?Math.min(i+1,u):i+u+1;else if(n&&i&&u)return i=n(r,a),r[i]===a?i:-1;if(a!==a)return i=t(c.call(r,o,u),g.isNaN),i>=0?i+o:-1;for(i=e>0?o:u-1;i>=0&&u>i;i+=e)if(r[i]===a)return i;return-1}}function r(e,t){var n=I.length,r=e.constructor,a=g.isFunction(r)&&r.prototype||u,i="constructor";for(g.has(e,i)&&!g.contains(t,i)&&t.push(i);n--;)i=I[n],i in e&&e[i]!==a[i]&&!g.contains(t,i)&&t.push(i)}var a=this,i=a._,o=Array.prototype,u=Object.prototype,s=Function.prototype,l=o.push,c=o.slice,f=u.toString,p=u.hasOwnProperty,d=Array.isArray,y=Object.keys,m=s.bind,h=Object.create,v=function(){},g=function(e){return e instanceof g?e:this instanceof g?void(this._wrapped=e):new g(e)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=g),exports._=g):a._=g,g.VERSION="1.8.3";var _=function(e,t,n){if(void 0===t)return e;switch(null==n?3:n){case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,a){return e.call(t,n,r,a)};case 4:return function(n,r,a,i){return e.call(t,n,r,a,i)}}return function(){return e.apply(t,arguments)}},L=function(e,t,n){return null==e?g.identity:g.isFunction(e)?_(e,t,n):g.isObject(e)?g.matcher(e):g.property(e)};g.iteratee=function(e,t){return L(e,t,1/0)};var b=function(e,t){return function(n){var r=arguments.length;if(2>r||null==n)return n;for(var a=1;r>a;a++)for(var i=arguments[a],o=e(i),u=o.length,s=0;u>s;s++){var l=o[s];t&&void 0!==n[l]||(n[l]=i[l])}return n}},w=function(e){if(!g.isObject(e))return{};if(h)return h(e);v.prototype=e;var t=new v;return v.prototype=null,t},j=function(e){return function(t){return null==t?void 0:t[e]}},k=Math.pow(2,53)-1,x=j("length"),q=function(e){var t=x(e);return"number"==typeof t&&t>=0&&k>=t};g.each=g.forEach=function(e,t,n){t=_(t,n);var r,a;if(q(e))for(r=0,a=e.length;a>r;r++)t(e[r],r,e);else{var i=g.keys(e);for(r=0,a=i.length;a>r;r++)t(e[i[r]],i[r],e)}return e},g.map=g.collect=function(e,t,n){t=L(t,n);for(var r=!q(e)&&g.keys(e),a=(r||e).length,i=Array(a),o=0;a>o;o++){var u=r?r[o]:o;i[o]=t(e[u],u,e)}return i},g.reduce=g.foldl=g.inject=e(1),g.reduceRight=g.foldr=e(-1),g.find=g.detect=function(e,t,n){var r;return r=q(e)?g.findIndex(e,t,n):g.findKey(e,t,n),void 0!==r&&r!==-1?e[r]:void 0},g.filter=g.select=function(e,t,n){var r=[];return t=L(t,n),g.each(e,function(e,n,a){t(e,n,a)&&r.push(e)}),r},g.reject=function(e,t,n){return g.filter(e,g.negate(L(t)),n)},g.every=g.all=function(e,t,n){t=L(t,n);for(var r=!q(e)&&g.keys(e),a=(r||e).length,i=0;a>i;i++){var o=r?r[i]:i;if(!t(e[o],o,e))return!1}return!0},g.some=g.any=function(e,t,n){t=L(t,n);for(var r=!q(e)&&g.keys(e),a=(r||e).length,i=0;a>i;i++){var o=r?r[i]:i;if(t(e[o],o,e))return!0}return!1},g.contains=g.includes=g.include=function(e,t,n,r){return q(e)||(e=g.values(e)),("number"!=typeof n||r)&&(n=0),g.indexOf(e,t,n)>=0},g.invoke=function(e,t){var n=c.call(arguments,2),r=g.isFunction(t);return g.map(e,function(e){var a=r?t:e[t];return null==a?a:a.apply(e,n)})},g.pluck=function(e,t){return g.map(e,g.property(t))},g.where=function(e,t){return g.filter(e,g.matcher(t))},g.findWhere=function(e,t){return g.find(e,g.matcher(t))},g.max=function(e,t,n){var r,a,i=-1/0,o=-1/0;if(null==t&&null!=e){e=q(e)?e:g.values(e);for(var u=0,s=e.length;s>u;u++)r=e[u],r>i&&(i=r)}else t=L(t,n),g.each(e,function(e,n,r){a=t(e,n,r),(a>o||a===-1/0&&i===-1/0)&&(i=e,o=a)});return i},g.min=function(e,t,n){var r,a,i=1/0,o=1/0;if(null==t&&null!=e){e=q(e)?e:g.values(e);for(var u=0,s=e.length;s>u;u++)r=e[u],i>r&&(i=r)}else t=L(t,n),g.each(e,function(e,n,r){a=t(e,n,r),(o>a||1/0===a&&1/0===i)&&(i=e,o=a)});return i},g.shuffle=function(e){for(var t,n=q(e)?e:g.values(e),r=n.length,a=Array(r),i=0;r>i;i++)t=g.random(0,i),t!==i&&(a[i]=a[t]),a[t]=n[i];return a},g.sample=function(e,t,n){return null==t||n?(q(e)||(e=g.values(e)),e[g.random(e.length-1)]):g.shuffle(e).slice(0,Math.max(0,t))},g.sortBy=function(e,t,n){return t=L(t,n),g.pluck(g.map(e,function(e,n,r){return{value:e,index:n,criteria:t(e,n,r)}}).sort(function(e,t){var n=e.criteria,r=t.criteria;
if(n!==r){if(n>r||void 0===n)return 1;if(r>n||void 0===r)return-1}return e.index-t.index}),"value")};var S=function(e){return function(t,n,r){var a={};return n=L(n,r),g.each(t,function(r,i){var o=n(r,i,t);e(a,r,o)}),a}};g.groupBy=S(function(e,t,n){g.has(e,n)?e[n].push(t):e[n]=[t]}),g.indexBy=S(function(e,t,n){e[n]=t}),g.countBy=S(function(e,t,n){g.has(e,n)?e[n]++:e[n]=1}),g.toArray=function(e){return e?g.isArray(e)?c.call(e):q(e)?g.map(e,g.identity):g.values(e):[]},g.size=function(e){return null==e?0:q(e)?e.length:g.keys(e).length},g.partition=function(e,t,n){t=L(t,n);var r=[],a=[];return g.each(e,function(e,n,i){(t(e,n,i)?r:a).push(e)}),[r,a]},g.first=g.head=g.take=function(e,t,n){return null==e?void 0:null==t||n?e[0]:g.initial(e,e.length-t)},g.initial=function(e,t,n){return c.call(e,0,Math.max(0,e.length-(null==t||n?1:t)))},g.last=function(e,t,n){return null==e?void 0:null==t||n?e[e.length-1]:g.rest(e,Math.max(0,e.length-t))},g.rest=g.tail=g.drop=function(e,t,n){return c.call(e,null==t||n?1:t)},g.compact=function(e){return g.filter(e,g.identity)};var M=function(e,t,n,r){for(var a=[],i=0,o=r||0,u=x(e);u>o;o++){var s=e[o];if(q(s)&&(g.isArray(s)||g.isArguments(s))){t||(s=M(s,t,n));var l=0,c=s.length;for(a.length+=c;c>l;)a[i++]=s[l++]}else n||(a[i++]=s)}return a};g.flatten=function(e,t){return M(e,t,!1)},g.without=function(e){return g.difference(e,c.call(arguments,1))},g.uniq=g.unique=function(e,t,n,r){g.isBoolean(t)||(r=n,n=t,t=!1),null!=n&&(n=L(n,r));for(var a=[],i=[],o=0,u=x(e);u>o;o++){var s=e[o],l=n?n(s,o,e):s;t?(o&&i===l||a.push(s),i=l):n?g.contains(i,l)||(i.push(l),a.push(s)):g.contains(a,s)||a.push(s)}return a},g.union=function(){return g.uniq(M(arguments,!0,!0))},g.intersection=function(e){for(var t=[],n=arguments.length,r=0,a=x(e);a>r;r++){var i=e[r];if(!g.contains(t,i)){for(var o=1;n>o&&g.contains(arguments[o],i);o++);o===n&&t.push(i)}}return t},g.difference=function(e){var t=M(arguments,!0,!0,1);return g.filter(e,function(e){return!g.contains(t,e)})},g.zip=function(){return g.unzip(arguments)},g.unzip=function(e){for(var t=e&&g.max(e,x).length||0,n=Array(t),r=0;t>r;r++)n[r]=g.pluck(e,r);return n},g.object=function(e,t){for(var n={},r=0,a=x(e);a>r;r++)t?n[e[r]]=t[r]:n[e[r][0]]=e[r][1];return n},g.findIndex=t(1),g.findLastIndex=t(-1),g.sortedIndex=function(e,t,n,r){n=L(n,r,1);for(var a=n(t),i=0,o=x(e);o>i;){var u=Math.floor((i+o)/2);n(e[u])<a?i=u+1:o=u}return i},g.indexOf=n(1,g.findIndex,g.sortedIndex),g.lastIndexOf=n(-1,g.findLastIndex),g.range=function(e,t,n){null==t&&(t=e||0,e=0),n=n||1;for(var r=Math.max(Math.ceil((t-e)/n),0),a=Array(r),i=0;r>i;i++,e+=n)a[i]=e;return a};var Q=function(e,t,n,r,a){if(!(r instanceof t))return e.apply(n,a);var i=w(e.prototype),o=e.apply(i,a);return g.isObject(o)?o:i};g.bind=function(e,t){if(m&&e.bind===m)return m.apply(e,c.call(arguments,1));if(!g.isFunction(e))throw new TypeError("Bind must be called on a function");var n=c.call(arguments,2),r=function(){return Q(e,r,t,this,n.concat(c.call(arguments)))};return r},g.partial=function(e){var t=c.call(arguments,1),n=function(){for(var r=0,a=t.length,i=Array(a),o=0;a>o;o++)i[o]=t[o]===g?arguments[r++]:t[o];for(;r<arguments.length;)i.push(arguments[r++]);return Q(e,n,this,this,i)};return n},g.bindAll=function(e){var t,n,r=arguments.length;if(1>=r)throw new Error("bindAll must be passed function names");for(t=1;r>t;t++)n=arguments[t],e[n]=g.bind(e[n],e);return e},g.memoize=function(e,t){var n=function(r){var a=n.cache,i=""+(t?t.apply(this,arguments):r);return g.has(a,i)||(a[i]=e.apply(this,arguments)),a[i]};return n.cache={},n},g.delay=function(e,t){var n=c.call(arguments,2);return setTimeout(function(){return e.apply(null,n)},t)},g.defer=g.partial(g.delay,g,1),g.throttle=function(e,t,n){var r,a,i,o=null,u=0;n||(n={});var s=function(){u=n.leading===!1?0:g.now(),o=null,i=e.apply(r,a),o||(r=a=null)};return function(){var l=g.now();u||n.leading!==!1||(u=l);var c=t-(l-u);return r=this,a=arguments,0>=c||c>t?(o&&(clearTimeout(o),o=null),u=l,i=e.apply(r,a),o||(r=a=null)):o||n.trailing===!1||(o=setTimeout(s,c)),i}},g.debounce=function(e,t,n){var r,a,i,o,u,s=function(){var l=g.now()-o;t>l&&l>=0?r=setTimeout(s,t-l):(r=null,n||(u=e.apply(i,a),r||(i=a=null)))};return function(){i=this,a=arguments,o=g.now();var l=n&&!r;return r||(r=setTimeout(s,t)),l&&(u=e.apply(i,a),i=a=null),u}},g.wrap=function(e,t){return g.partial(t,e)},g.negate=function(e){return function(){return!e.apply(this,arguments)}},g.compose=function(){var e=arguments,t=e.length-1;return function(){for(var n=t,r=e[t].apply(this,arguments);n--;)r=e[n].call(this,r);return r}},g.after=function(e,t){return function(){return--e<1?t.apply(this,arguments):void 0}},g.before=function(e,t){var n;return function(){return--e>0&&(n=t.apply(this,arguments)),1>=e&&(t=null),n}},g.once=g.partial(g.before,2);var O=!{toString:null}.propertyIsEnumerable("toString"),I=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];g.keys=function(e){if(!g.isObject(e))return[];if(y)return y(e);var t=[];for(var n in e)g.has(e,n)&&t.push(n);return O&&r(e,t),t},g.allKeys=function(e){if(!g.isObject(e))return[];var t=[];for(var n in e)t.push(n);return O&&r(e,t),t},g.values=function(e){for(var t=g.keys(e),n=t.length,r=Array(n),a=0;n>a;a++)r[a]=e[t[a]];return r},g.mapObject=function(e,t,n){t=L(t,n);for(var r,a=g.keys(e),i=a.length,o={},u=0;i>u;u++)r=a[u],o[r]=t(e[r],r,e);return o},g.pairs=function(e){for(var t=g.keys(e),n=t.length,r=Array(n),a=0;n>a;a++)r[a]=[t[a],e[t[a]]];return r},g.invert=function(e){for(var t={},n=g.keys(e),r=0,a=n.length;a>r;r++)t[e[n[r]]]=n[r];return t},g.functions=g.methods=function(e){var t=[];for(var n in e)g.isFunction(e[n])&&t.push(n);return t.sort()},g.extend=b(g.allKeys),g.extendOwn=g.assign=b(g.keys),g.findKey=function(e,t,n){t=L(t,n);for(var r,a=g.keys(e),i=0,o=a.length;o>i;i++)if(r=a[i],t(e[r],r,e))return r},g.pick=function(e,t,n){var r,a,i={},o=e;if(null==o)return i;g.isFunction(t)?(a=g.allKeys(o),r=_(t,n)):(a=M(arguments,!1,!1,1),r=function(e,t,n){return t in n},o=Object(o));for(var u=0,s=a.length;s>u;u++){var l=a[u],c=o[l];r(c,l,o)&&(i[l]=c)}return i},g.omit=function(e,t,n){if(g.isFunction(t))t=g.negate(t);else{var r=g.map(M(arguments,!1,!1,1),String);t=function(e,t){return!g.contains(r,t)}}return g.pick(e,t,n)},g.defaults=b(g.allKeys,!0),g.create=function(e,t){var n=w(e);return t&&g.extendOwn(n,t),n},g.clone=function(e){return g.isObject(e)?g.isArray(e)?e.slice():g.extend({},e):e},g.tap=function(e,t){return t(e),e},g.isMatch=function(e,t){var n=g.keys(t),r=n.length;if(null==e)return!r;for(var a=Object(e),i=0;r>i;i++){var o=n[i];if(t[o]!==a[o]||!(o in a))return!1}return!0};var T=function(e,t,n,r){if(e===t)return 0!==e||1/e===1/t;if(null==e||null==t)return e===t;e instanceof g&&(e=e._wrapped),t instanceof g&&(t=t._wrapped);var a=f.call(e);if(a!==f.call(t))return!1;switch(a){case"[object RegExp]":case"[object String]":return""+e==""+t;case"[object Number]":return+e!==+e?+t!==+t:0===+e?1/+e===1/t:+e===+t;case"[object Date]":case"[object Boolean]":return+e===+t}var i="[object Array]"===a;if(!i){if("object"!=typeof e||"object"!=typeof t)return!1;var o=e.constructor,u=t.constructor;if(o!==u&&!(g.isFunction(o)&&o instanceof o&&g.isFunction(u)&&u instanceof u)&&"constructor"in e&&"constructor"in t)return!1}n=n||[],r=r||[];for(var s=n.length;s--;)if(n[s]===e)return r[s]===t;if(n.push(e),r.push(t),i){if(s=e.length,s!==t.length)return!1;for(;s--;)if(!T(e[s],t[s],n,r))return!1}else{var l,c=g.keys(e);if(s=c.length,g.keys(t).length!==s)return!1;for(;s--;)if(l=c[s],!g.has(t,l)||!T(e[l],t[l],n,r))return!1}return n.pop(),r.pop(),!0};g.isEqual=function(e,t){return T(e,t)},g.isEmpty=function(e){return null==e||(q(e)&&(g.isArray(e)||g.isString(e)||g.isArguments(e))?0===e.length:0===g.keys(e).length)},g.isElement=function(e){return!(!e||1!==e.nodeType)},g.isArray=d||function(e){return"[object Array]"===f.call(e)},g.isObject=function(e){var t=typeof e;return"function"===t||"object"===t&&!!e},g.each(["Arguments","Function","String","Number","Date","RegExp","Error"],function(e){g["is"+e]=function(t){return f.call(t)==="[object "+e+"]"}}),g.isArguments(arguments)||(g.isArguments=function(e){return g.has(e,"callee")}),"function"!=typeof/./&&"object"!=typeof Int8Array&&(g.isFunction=function(e){return"function"==typeof e||!1}),g.isFinite=function(e){return isFinite(e)&&!isNaN(parseFloat(e))},g.isNaN=function(e){return g.isNumber(e)&&e!==+e},g.isBoolean=function(e){return e===!0||e===!1||"[object Boolean]"===f.call(e)},g.isNull=function(e){return null===e},g.isUndefined=function(e){return void 0===e},g.has=function(e,t){return null!=e&&p.call(e,t)},g.noConflict=function(){return a._=i,this},g.identity=function(e){return e},g.constant=function(e){return function(){return e}},g.noop=function(){},g.property=j,g.propertyOf=function(e){return null==e?function(){}:function(t){return e[t]}},g.matcher=g.matches=function(e){return e=g.extendOwn({},e),function(t){return g.isMatch(t,e)}},g.times=function(e,t,n){var r=Array(Math.max(0,e));t=_(t,n,1);for(var a=0;e>a;a++)r[a]=t(a);return r},g.random=function(e,t){return null==t&&(t=e,e=0),e+Math.floor(Math.random()*(t-e+1))},g.now=Date.now||function(){return(new Date).getTime()};var G={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},A=g.invert(G),C=function(e){var t=function(t){return e[t]},n="(?:"+g.keys(e).join("|")+")",r=RegExp(n),a=RegExp(n,"g");return function(e){return e=null==e?"":""+e,r.test(e)?e.replace(a,t):e}};g.escape=C(G),g.unescape=C(A),g.result=function(e,t,n){var r=null==e?void 0:e[t];return void 0===r&&(r=n),g.isFunction(r)?r.call(e):r};var E=0;g.uniqueId=function(e){var t=++E+"";return e?e+t:t},g.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var F=/(.)^/,P={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},N=/\\|'|\r|\n|\u2028|\u2029/g,R=function(e){return"\\"+P[e]};g.template=function(e,t,n){!t&&n&&(t=n),t=g.defaults({},t,g.templateSettings);var r=RegExp([(t.escape||F).source,(t.interpolate||F).source,(t.evaluate||F).source].join("|")+"|$","g"),a=0,i="__p+='";e.replace(r,function(t,n,r,o,u){return i+=e.slice(a,u).replace(N,R),a=u+t.length,n?i+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'":r?i+="'+\n((__t=("+r+"))==null?'':__t)+\n'":o&&(i+="';\n"+o+"\n__p+='"),t}),i+="';\n",t.variable||(i="with(obj||{}){\n"+i+"}\n"),i="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+i+"return __p;\n";try{var o=new Function(t.variable||"obj","_",i)}catch(u){throw u.source=i,u}var s=function(e){return o.call(this,e,g)},l=t.variable||"obj";return s.source="function("+l+"){\n"+i+"}",s},g.chain=function(e){var t=g(e);return t._chain=!0,t};var $=function(e,t){return e._chain?g(t).chain():t};g.mixin=function(e){g.each(g.functions(e),function(t){var n=g[t]=e[t];g.prototype[t]=function(){var e=[this._wrapped];return l.apply(e,arguments),$(this,n.apply(g,e))}})},g.mixin(g),g.each(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=o[e];g.prototype[e]=function(){var n=this._wrapped;return t.apply(n,arguments),"shift"!==e&&"splice"!==e||0!==n.length||delete n[0],$(this,n)}}),g.each(["concat","join","slice"],function(e){var t=o[e];g.prototype[e]=function(){return $(this,t.apply(this._wrapped,arguments))}}),g.prototype.value=function(){return this._wrapped},g.prototype.valueOf=g.prototype.toJSON=g.prototype.value,g.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return g})}.call(this);var legend=new Array,activeLayers=new Array;jQuery(document).ready(function(){L.TileLayer.BetterWMS=L.TileLayer.WMS.extend({onAdd:function(e){L.TileLayer.WMS.prototype.onAdd.call(this,e)},onRemove:function(e){L.TileLayer.WMS.prototype.onRemove.call(this,e),e.off("click",this.getFeatureInfo,this)},getFeatureInfo:function(e){},getFeatureInfoUrl:function(e){var t=this._map.latLngToContainerPoint(e,this._map.getZoom()),n=this._map.getSize(),r=this.wmsParams.layer_type,a="application/json";4==r&&(a="text/html");var i={request:"GetFeatureInfo",service:"WMS",srs:"EPSG:4326",styles:this.wmsParams.styles,transparent:this.wmsParams.transparent,version:this.wmsParams.version,format:this.wmsParams.format,height:n.y,width:n.x,layers:this.wmsParams.layers,query_layers:this.wmsParams.layers,info_format:a};return i["1.3.0"===i.version?"i":"x"]=t.x,i["1.3.0"===i.version?"j":"y"]=t.y,this._url+L.Util.getParamString(i,this._url,!0)},showGetFeatureInfo:function(e,t,n){if("undefined"!=n){var r=getIndex(selectedLayers,"unique_id",this.wmsParams.unique_id),a="";if(1==selectedLayers[r].type){if(!n.features||0==n.features.length)return;a=getPopupContent(n,selectedLayers[r].pc)}else{if(jQuery(n).find("tr").length<2)return;a=n}L.popup({maxWidth:"auto"}).setLatLng(t).setContent(a).openOn(this._map)}}}),L.tileLayer.betterWms=function(e,t){return new L.TileLayer.BetterWMS(e,t)},L.Icon.Default.imagePath=baseURL+"/assets/plugins/leaflet/images",L.AwesomeMarkers.Icon.prototype.options.prefix="fa"});var heatmap=new Array,pgsql_tmpl,featureGroup=new Array,bounds,layerSelector=new Array,overlays=new Array,mymap,currentBaseMap=new Array,marker_content_tmpl,popupContentId=new Array,drawingGroup;jQuery(document).ready(function(){drawingGroup=new L.FeatureGroup;var e=maps.length;for(calculateWindow(),mymap=L.map("mapid",{}).setView([51.505,-.09],13),currentBaseMap=isGoogle()?L.tileLayer("https://{s}.google.com/vt/lyrs=s&x={x}&y={y}&z={z}",{maxZoom:20,subdomains:["mt0","mt1","mt2","mt3"]}).addTo(mymap):L.tileLayer(baseLayers.mymap[layername]._url,{maxZoom:18,attribution:baseLayers.mymap[layername].options.attribution,id:baseLayers.mymap[layername].options.id}).addTo(mymap),layerSelector=L.control.layers({},{}),mymap.addControl(layerSelector),s=0;s<e;s++)map=maps[s],mapid=map.id,defaultSettings(),selectedLayers=maps[s].info.selectedLayers,selectedBaseLayers=maps[s].info.selectedBaseLayers,initLayer(),assingSettings()});