Y-SLD/assets/playkit/js/map-p-d2b142c48a.js

2 lines
54 KiB
JavaScript

function simpleheat(e){return this instanceof simpleheat?(this._canvas=e="string"==typeof e?document.getElementById(e):e,this._ctx=e.getContext("2d"),this._width=e.width,this._height=e.height,this._max=1,void(this._data=[])):new simpleheat(e)}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 s=JSON.stringify(o);jQuery("#layer_json").val(s),jQuery("#section_id_hidden").val(jQuery("#dd_section_id").val());var u=jQuery("#layer-form, #map-settings-form").serialize();ajaxRequest("/developer/map/save","post","json",u,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),s=selectedLayers[o],u=featureGroup[r][a].getLayers();$.each(u,function(e,n){n.eachLayer(function(e){"nr"==s.style.type?between(e.feature.properties[s.style.field],i)&&(t===!0?mymap.addLayer(e):mymap.removeLayer(e)):"g"==s.style.type&&e.feature.properties[s.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),s=selectedLayers[o];if("undefined"==typeof s)return void(n===!0?mymap.addLayer(featureGroup[a][i]):mymap.removeLayer(featureGroup[a][i]));if(n===!0)activeLayers.push({id:s._id,order:0}),order_current_active_layers(),t.hasClass("active-layer-chk")||add_current_layer_text(s),mymap.addLayer(featureGroup[s.unique_id][s.name]),featureGroup[s.unique_id][s.name].bringToFront(),add_sql_legend(s,!0);else{var o=getIndex(activeLayers,"id",s._id);activeLayers.splice(o,1),t.hasClass("active-layer-chk")||jQuery("#user-farm-at-layers-"+s.unique_id).remove(),mymap.removeLayer(featureGroup[s.unique_id][s.name]),"undefined"!=typeof legend[a]&&legend[s.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 ajaxLoadSucess(){setTimeout(function(){window.status="done",jQuery("#ajax-load-check").html("ajax-load-done")},2e3)}toGeoJSON=function(){"use strict";function e(e){if(!e||!e.length)return 0;for(var t=0,n=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t)|0;return n}function t(e,t){return e.getElementsByTagName(t)}function n(e,t){return e.getAttribute(t)}function r(e,t){return parseFloat(n(e,t))}function a(e,n){var r=t(e,n);return r.length?r[0]:null}function i(e){return e.normalize&&e.normalize(),e}function o(e){for(var t=0,n=[];t<e.length;t++)n[t]=parseFloat(e[t]);return n}function s(e){var t={};for(var n in e)e[n]&&(t[n]=e[n]);return t}function u(e){return e&&i(e),e&&e.firstChild&&e.firstChild.nodeValue||""}function l(e){return o(e.replace(h,"").split(","))}function c(e){for(var t=e.replace(m,"").split(g),n=[],r=0;r<t.length;r++)n.push(l(t[r]));return n}function f(e){var t=[r(e,"lon"),r(e,"lat")],n=a(e,"ele");return n&&t.push(parseFloat(u(n))),t}function p(){return{type:"FeatureCollection",features:[]}}function d(e){return y.serializeToString(e)}var y,h=/\s*/g,m=/^\s*|\s*$/g,g=/\s+/;"undefined"!=typeof XMLSerializer?y=new XMLSerializer:"object"!=typeof exports||"object"!=typeof process||process.browser||(y=new(require("xmldom").XMLSerializer));var v={kml:function(r,i){function s(e){var t,n;return e=e||"","#"===e.substr(0,1)&&(e=e.substr(1)),6!==e.length&&3!==e.length||(t=e),8===e.length&&(n=parseInt(e.substr(0,2),16)/255,t=e.substr(2)),[t,isNaN(n)?void 0:n]}function f(e){return o(e.split(" "))}function y(e){for(var n=t(e,"coord","gx"),r=[],a=0;a<n.length;a++)r.push(f(u(n[a])));return r}function h(e){var n,r,i,o,s,f=[];if(a(e,"MultiGeometry"))return h(a(e,"MultiGeometry"));if(a(e,"MultiTrack"))return h(a(e,"MultiTrack"));for(i=0;i<_.length;i++)if(r=t(e,_[i]))for(o=0;o<r.length;o++)if(n=r[o],"Point"==_[i])f.push({type:"Point",coordinates:l(u(a(n,"coordinates")))});else if("LineString"==_[i])f.push({type:"LineString",coordinates:c(u(a(n,"coordinates")))});else if("Polygon"==_[i]){var p=t(n,"LinearRing"),d=[];for(s=0;s<p.length;s++)d.push(c(u(a(p[s],"coordinates"))));f.push({type:"Polygon",coordinates:d})}else"Track"==_[i]&&f.push({type:"LineString",coordinates:y(n)});return f}function m(e){var n,r=h(e),i={},o=u(a(e,"name")),l=u(a(e,"styleUrl")),c=u(a(e,"description")),f=a(e,"TimeSpan"),p=a(e,"ExtendedData"),d=a(e,"LineStyle"),y=a(e,"PolyStyle");if(!r.length)return[];if(o&&(i.name=o),l&&v[l]&&(i.styleUrl=l,i.styleHash=v[l]),c&&(i.description=c),f){var m=u(a(f,"begin")),g=u(a(f,"end"));i.timespan={begin:m,end:g}}if(d){var _=s(u(a(d,"color"))),L=_[0],w=_[1],b=parseFloat(u(a(d,"width")));L&&(i.stroke=L),isNaN(w)||(i["stroke-opacity"]=w),isNaN(b)||(i["stroke-width"]=b)}if(y){var j=s(u(a(y,"color"))),k=j[0],x=j[1],S=u(a(y,"fill")),M=u(a(y,"outline"));k&&(i.fill=k),isNaN(x)||(i["fill-opacity"]=x),S&&(i["fill-opacity"]="1"===S?1:0),M&&(i["stroke-opacity"]="1"===M?1:0)}if(p){var q=t(p,"Data"),O=t(p,"SimpleData");for(n=0;n<q.length;n++)i[q[n].getAttribute("name")]=u(a(q[n],"value"));for(n=0;n<O.length;n++)i[O[n].getAttribute("name")]=u(O[n])}return[{type:"Feature",geometry:1===r.length?r[0]:{type:"GeometryCollection",geometries:r},properties:i}]}i=i||{};for(var g=p(),v={},_=["Polygon","LineString","Point","Track"],L=t(r,"Placemark"),w=t(r,"Style"),b=0;b<w.length;b++)v["#"+n(w[b],"id")]=e(d(w[b])).toString(16);for(var j=0;j<L.length;j++)g.features=g.features.concat(m(L[j]));return g},gpx:function(e,n){function r(e,n){for(var r=t(e,n),a=[],i=0;i<r.length;i++)a.push(f(r[i]));return a}function i(e){for(var n=t(e,"trkseg"),a=[],i=0;i<n.length;i++)a.push(r(n[i],"trkpt"));return{type:"Feature",properties:c(e),geometry:{type:1===a.length?"LineString":"MultiLineString",coordinates:1===a.length?a[0]:a}}}function o(e){return{type:"Feature",properties:c(e),geometry:{type:"LineString",coordinates:r(e,"rtept")}}}function l(e){var t=c(e);return t.sym=u(a(e,"sym")),{type:"Feature",properties:t,geometry:{type:"Point",coordinates:f(e)}}}function c(e){var t,n=["name","desc","author","copyright","link","time","keywords"],r={};for(t=0;t<n.length;t++)r[n[t]]=u(a(e,n[t]));return s(r)}var d,y=t(e,"trk"),h=t(e,"rte"),m=t(e,"wpt"),g=p();for(d=0;d<y.length;d++)g.features.push(i(y[d]));for(d=0;d<h.length;d++)g.features.push(o(h[d]));for(d=0;d<m.length;d++)g.features.push(l(m[d]));return g}};return v}(),"undefined"!=typeof module&&(module.exports=toGeoJSON),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 h(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 m.call(e,t)}function o(e){return!i(g,e)}function s(e){return String(e).replace(/[&<>"'`=\/]/g,function(e){return v[e]})}function u(t,n){function a(){if(g&&!v)for(;m.length;)delete y[m.pop()];else m=[];g=!1,v=!1}function i(e){if("string"==typeof e&&(e=e.split(L,2)),!h(e)||2!==e.length)throw new Error("Invalid tags: "+e);s=new RegExp(r(e[0])+"\\s*"),u=new RegExp("\\s*"+r(e[1])),p=new RegExp("\\s*"+r("}"+e[1]))}if(!t)return[];var s,u,p,d=[],y=[],m=[],g=!1,v=!1;i(n||e.tags);for(var k,x,S,M,q,O,T=new f(t);!T.eos();){if(k=T.pos,S=T.scanUntil(s))for(var I=0,C=S.length;I<C;++I)M=S.charAt(I),o(M)?m.push(y.length):v=!0,y.push(["text",M,k,k+1]),k+=1,"\n"===M&&a();if(!T.scan(s))break;if(g=!0,x=T.scan(j)||"name",T.scan(_),"="===x?(S=T.scanUntil(w),T.scan(w),T.scanUntil(u)):"{"===x?(S=T.scanUntil(p),T.scan(b),T.scanUntil(u),x="&"):S=T.scanUntil(u),!T.scan(u))throw new Error("Unclosed tag at "+T.pos);if(q=[x,S,k,T.pos],y.push(q),"#"===x||"^"===x)d.push(q);else if("/"===x){if(O=d.pop(),!O)throw new Error('Unopened section "'+S+'" at '+k);if(O[1]!==S)throw new Error('Unclosed section "'+O[1]+'" at '+k)}else"name"===x||"{"===x||"&"===x?v=!0:"="===x&&i(S)}if(O=d.pop())throw new Error('Unclosed section "'+O[1]+'" at '+T.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,s=e.length;o<s;++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,h=Array.isArray||function(e){return"[object Array]"===y.call(e)},m=RegExp.prototype.test,g=/\S/,v={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"},_=/\s*/,L=/\s+/,w=/\s*=/,b=/\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,s=this,u=!1;s;){if(e.indexOf(".")>0)for(n=s.view,i=e.split("."),o=0;null!=n&&o<i.length;)o===i.length-1&&(u=a(n,i[o])),n=n[i[o++]];else n=s.view[e],u=a(s.view,e);if(u)break;s=s.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]=u(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,s="",u=0,l=e.length;u<l;++u)o=void 0,a=e[u],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&&(s+=o);return s},d.prototype.renderSection=function(e,n,r,a){function i(e){return o.render(e,n,r)}var o=this,s="",u=n.lookup(e[1]);if(u){if(h(u))for(var l=0,c=u.length;l<c;++l)s+=this.renderTokens(e[4],n.push(u[l]),r,a);else if("object"==typeof u||"string"==typeof u||"number"==typeof u)s+=this.renderTokens(e[4],n.push(u),r,a);else if(t(u)){if("string"!=typeof a)throw new Error("Cannot use higher-order sections without the original template");u=u.call(n.view,a.slice(e[3],e[5]),i),null!=u&&(s+=u)}else s+=this.renderTokens(e[4],n,r,a);return s}},d.prototype.renderInverted=function(e,t,n,r){var a=t.lookup(e[1]);if(!a||h(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=s,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 s=a?a[i]:i;r=n(r,t[s],s,t)}return r}return function(n,r,a,i){
r=_(r,i,4);var o=!S(n)&&v.keys(n),s=(o||n).length,u=e>0?0:s-1;return arguments.length<3&&(a=n[o?o[u]:u],u+=e),t(n,r,a,o,u,s)}}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,s=x(r);if("number"==typeof i)e>0?o=i>=0?i:Math.max(i+s,o):s=i>=0?Math.min(i+1,s):i+s+1;else if(n&&i&&s)return i=n(r,a),r[i]===a?i:-1;if(a!==a)return i=t(c.call(r,o,s),v.isNaN),i>=0?i+o:-1;for(i=e>0?o:s-1;i>=0&&s>i;i+=e)if(r[i]===a)return i;return-1}}function r(e,t){var n=I.length,r=e.constructor,a=v.isFunction(r)&&r.prototype||s,i="constructor";for(v.has(e,i)&&!v.contains(t,i)&&t.push(i);n--;)i=I[n],i in e&&e[i]!==a[i]&&!v.contains(t,i)&&t.push(i)}var a=this,i=a._,o=Array.prototype,s=Object.prototype,u=Function.prototype,l=o.push,c=o.slice,f=s.toString,p=s.hasOwnProperty,d=Array.isArray,y=Object.keys,h=u.bind,m=Object.create,g=function(){},v=function(e){return e instanceof v?e:this instanceof v?void(this._wrapped=e):new v(e)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=v),exports._=v):a._=v,v.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?v.identity:v.isFunction(e)?_(e,t,n):v.isObject(e)?v.matcher(e):v.property(e)};v.iteratee=function(e,t){return L(e,t,1/0)};var w=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),s=o.length,u=0;s>u;u++){var l=o[u];t&&void 0!==n[l]||(n[l]=i[l])}return n}},b=function(e){if(!v.isObject(e))return{};if(m)return m(e);g.prototype=e;var t=new g;return g.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"),S=function(e){var t=x(e);return"number"==typeof t&&t>=0&&k>=t};v.each=v.forEach=function(e,t,n){t=_(t,n);var r,a;if(S(e))for(r=0,a=e.length;a>r;r++)t(e[r],r,e);else{var i=v.keys(e);for(r=0,a=i.length;a>r;r++)t(e[i[r]],i[r],e)}return e},v.map=v.collect=function(e,t,n){t=L(t,n);for(var r=!S(e)&&v.keys(e),a=(r||e).length,i=Array(a),o=0;a>o;o++){var s=r?r[o]:o;i[o]=t(e[s],s,e)}return i},v.reduce=v.foldl=v.inject=e(1),v.reduceRight=v.foldr=e(-1),v.find=v.detect=function(e,t,n){var r;return r=S(e)?v.findIndex(e,t,n):v.findKey(e,t,n),void 0!==r&&r!==-1?e[r]:void 0},v.filter=v.select=function(e,t,n){var r=[];return t=L(t,n),v.each(e,function(e,n,a){t(e,n,a)&&r.push(e)}),r},v.reject=function(e,t,n){return v.filter(e,v.negate(L(t)),n)},v.every=v.all=function(e,t,n){t=L(t,n);for(var r=!S(e)&&v.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},v.some=v.any=function(e,t,n){t=L(t,n);for(var r=!S(e)&&v.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},v.contains=v.includes=v.include=function(e,t,n,r){return S(e)||(e=v.values(e)),("number"!=typeof n||r)&&(n=0),v.indexOf(e,t,n)>=0},v.invoke=function(e,t){var n=c.call(arguments,2),r=v.isFunction(t);return v.map(e,function(e){var a=r?t:e[t];return null==a?a:a.apply(e,n)})},v.pluck=function(e,t){return v.map(e,v.property(t))},v.where=function(e,t){return v.filter(e,v.matcher(t))},v.findWhere=function(e,t){return v.find(e,v.matcher(t))},v.max=function(e,t,n){var r,a,i=-1/0,o=-1/0;if(null==t&&null!=e){e=S(e)?e:v.values(e);for(var s=0,u=e.length;u>s;s++)r=e[s],r>i&&(i=r)}else t=L(t,n),v.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},v.min=function(e,t,n){var r,a,i=1/0,o=1/0;if(null==t&&null!=e){e=S(e)?e:v.values(e);for(var s=0,u=e.length;u>s;s++)r=e[s],i>r&&(i=r)}else t=L(t,n),v.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},v.shuffle=function(e){for(var t,n=S(e)?e:v.values(e),r=n.length,a=Array(r),i=0;r>i;i++)t=v.random(0,i),t!==i&&(a[i]=a[t]),a[t]=n[i];return a},v.sample=function(e,t,n){return null==t||n?(S(e)||(e=v.values(e)),e[v.random(e.length-1)]):v.shuffle(e).slice(0,Math.max(0,t))},v.sortBy=function(e,t,n){return t=L(t,n),v.pluck(v.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 M=function(e){return function(t,n,r){var a={};return n=L(n,r),v.each(t,function(r,i){var o=n(r,i,t);e(a,r,o)}),a}};v.groupBy=M(function(e,t,n){v.has(e,n)?e[n].push(t):e[n]=[t]}),v.indexBy=M(function(e,t,n){e[n]=t}),v.countBy=M(function(e,t,n){v.has(e,n)?e[n]++:e[n]=1}),v.toArray=function(e){return e?v.isArray(e)?c.call(e):S(e)?v.map(e,v.identity):v.values(e):[]},v.size=function(e){return null==e?0:S(e)?e.length:v.keys(e).length},v.partition=function(e,t,n){t=L(t,n);var r=[],a=[];return v.each(e,function(e,n,i){(t(e,n,i)?r:a).push(e)}),[r,a]},v.first=v.head=v.take=function(e,t,n){return null==e?void 0:null==t||n?e[0]:v.initial(e,e.length-t)},v.initial=function(e,t,n){return c.call(e,0,Math.max(0,e.length-(null==t||n?1:t)))},v.last=function(e,t,n){return null==e?void 0:null==t||n?e[e.length-1]:v.rest(e,Math.max(0,e.length-t))},v.rest=v.tail=v.drop=function(e,t,n){return c.call(e,null==t||n?1:t)},v.compact=function(e){return v.filter(e,v.identity)};var q=function(e,t,n,r){for(var a=[],i=0,o=r||0,s=x(e);s>o;o++){var u=e[o];if(S(u)&&(v.isArray(u)||v.isArguments(u))){t||(u=q(u,t,n));var l=0,c=u.length;for(a.length+=c;c>l;)a[i++]=u[l++]}else n||(a[i++]=u)}return a};v.flatten=function(e,t){return q(e,t,!1)},v.without=function(e){return v.difference(e,c.call(arguments,1))},v.uniq=v.unique=function(e,t,n,r){v.isBoolean(t)||(r=n,n=t,t=!1),null!=n&&(n=L(n,r));for(var a=[],i=[],o=0,s=x(e);s>o;o++){var u=e[o],l=n?n(u,o,e):u;t?(o&&i===l||a.push(u),i=l):n?v.contains(i,l)||(i.push(l),a.push(u)):v.contains(a,u)||a.push(u)}return a},v.union=function(){return v.uniq(q(arguments,!0,!0))},v.intersection=function(e){for(var t=[],n=arguments.length,r=0,a=x(e);a>r;r++){var i=e[r];if(!v.contains(t,i)){for(var o=1;n>o&&v.contains(arguments[o],i);o++);o===n&&t.push(i)}}return t},v.difference=function(e){var t=q(arguments,!0,!0,1);return v.filter(e,function(e){return!v.contains(t,e)})},v.zip=function(){return v.unzip(arguments)},v.unzip=function(e){for(var t=e&&v.max(e,x).length||0,n=Array(t),r=0;t>r;r++)n[r]=v.pluck(e,r);return n},v.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},v.findIndex=t(1),v.findLastIndex=t(-1),v.sortedIndex=function(e,t,n,r){n=L(n,r,1);for(var a=n(t),i=0,o=x(e);o>i;){var s=Math.floor((i+o)/2);n(e[s])<a?i=s+1:o=s}return i},v.indexOf=n(1,v.findIndex,v.sortedIndex),v.lastIndexOf=n(-1,v.findLastIndex),v.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 O=function(e,t,n,r,a){if(!(r instanceof t))return e.apply(n,a);var i=b(e.prototype),o=e.apply(i,a);return v.isObject(o)?o:i};v.bind=function(e,t){if(h&&e.bind===h)return h.apply(e,c.call(arguments,1));if(!v.isFunction(e))throw new TypeError("Bind must be called on a function");var n=c.call(arguments,2),r=function(){return O(e,r,t,this,n.concat(c.call(arguments)))};return r},v.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]===v?arguments[r++]:t[o];for(;r<arguments.length;)i.push(arguments[r++]);return O(e,n,this,this,i)};return n},v.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]=v.bind(e[n],e);return e},v.memoize=function(e,t){var n=function(r){var a=n.cache,i=""+(t?t.apply(this,arguments):r);return v.has(a,i)||(a[i]=e.apply(this,arguments)),a[i]};return n.cache={},n},v.delay=function(e,t){var n=c.call(arguments,2);return setTimeout(function(){return e.apply(null,n)},t)},v.defer=v.partial(v.delay,v,1),v.throttle=function(e,t,n){var r,a,i,o=null,s=0;n||(n={});var u=function(){s=n.leading===!1?0:v.now(),o=null,i=e.apply(r,a),o||(r=a=null)};return function(){var l=v.now();s||n.leading!==!1||(s=l);var c=t-(l-s);return r=this,a=arguments,0>=c||c>t?(o&&(clearTimeout(o),o=null),s=l,i=e.apply(r,a),o||(r=a=null)):o||n.trailing===!1||(o=setTimeout(u,c)),i}},v.debounce=function(e,t,n){var r,a,i,o,s,u=function(){var l=v.now()-o;t>l&&l>=0?r=setTimeout(u,t-l):(r=null,n||(s=e.apply(i,a),r||(i=a=null)))};return function(){i=this,a=arguments,o=v.now();var l=n&&!r;return r||(r=setTimeout(u,t)),l&&(s=e.apply(i,a),i=a=null),s}},v.wrap=function(e,t){return v.partial(t,e)},v.negate=function(e){return function(){return!e.apply(this,arguments)}},v.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}},v.after=function(e,t){return function(){return--e<1?t.apply(this,arguments):void 0}},v.before=function(e,t){var n;return function(){return--e>0&&(n=t.apply(this,arguments)),1>=e&&(t=null),n}},v.once=v.partial(v.before,2);var T=!{toString:null}.propertyIsEnumerable("toString"),I=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];v.keys=function(e){if(!v.isObject(e))return[];if(y)return y(e);var t=[];for(var n in e)v.has(e,n)&&t.push(n);return T&&r(e,t),t},v.allKeys=function(e){if(!v.isObject(e))return[];var t=[];for(var n in e)t.push(n);return T&&r(e,t),t},v.values=function(e){for(var t=v.keys(e),n=t.length,r=Array(n),a=0;n>a;a++)r[a]=e[t[a]];return r},v.mapObject=function(e,t,n){t=L(t,n);for(var r,a=v.keys(e),i=a.length,o={},s=0;i>s;s++)r=a[s],o[r]=t(e[r],r,e);return o},v.pairs=function(e){for(var t=v.keys(e),n=t.length,r=Array(n),a=0;n>a;a++)r[a]=[t[a],e[t[a]]];return r},v.invert=function(e){for(var t={},n=v.keys(e),r=0,a=n.length;a>r;r++)t[e[n[r]]]=n[r];return t},v.functions=v.methods=function(e){var t=[];for(var n in e)v.isFunction(e[n])&&t.push(n);return t.sort()},v.extend=w(v.allKeys),v.extendOwn=v.assign=w(v.keys),v.findKey=function(e,t,n){t=L(t,n);for(var r,a=v.keys(e),i=0,o=a.length;o>i;i++)if(r=a[i],t(e[r],r,e))return r},v.pick=function(e,t,n){var r,a,i={},o=e;if(null==o)return i;v.isFunction(t)?(a=v.allKeys(o),r=_(t,n)):(a=q(arguments,!1,!1,1),r=function(e,t,n){return t in n},o=Object(o));for(var s=0,u=a.length;u>s;s++){var l=a[s],c=o[l];r(c,l,o)&&(i[l]=c)}return i},v.omit=function(e,t,n){if(v.isFunction(t))t=v.negate(t);else{var r=v.map(q(arguments,!1,!1,1),String);t=function(e,t){return!v.contains(r,t)}}return v.pick(e,t,n)},v.defaults=w(v.allKeys,!0),v.create=function(e,t){var n=b(e);return t&&v.extendOwn(n,t),n},v.clone=function(e){return v.isObject(e)?v.isArray(e)?e.slice():v.extend({},e):e},v.tap=function(e,t){return t(e),e},v.isMatch=function(e,t){var n=v.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 C=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 v&&(e=e._wrapped),t instanceof v&&(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,s=t.constructor;if(o!==s&&!(v.isFunction(o)&&o instanceof o&&v.isFunction(s)&&s instanceof s)&&"constructor"in e&&"constructor"in t)return!1}n=n||[],r=r||[];for(var u=n.length;u--;)if(n[u]===e)return r[u]===t;if(n.push(e),r.push(t),i){if(u=e.length,u!==t.length)return!1;for(;u--;)if(!C(e[u],t[u],n,r))return!1}else{var l,c=v.keys(e);if(u=c.length,v.keys(t).length!==u)return!1;for(;u--;)if(l=c[u],!v.has(t,l)||!C(e[l],t[l],n,r))return!1}return n.pop(),r.pop(),!0};v.isEqual=function(e,t){return C(e,t)},v.isEmpty=function(e){return null==e||(S(e)&&(v.isArray(e)||v.isString(e)||v.isArguments(e))?0===e.length:0===v.keys(e).length)},v.isElement=function(e){return!(!e||1!==e.nodeType)},v.isArray=d||function(e){return"[object Array]"===f.call(e)},v.isObject=function(e){var t=typeof e;return"function"===t||"object"===t&&!!e},v.each(["Arguments","Function","String","Number","Date","RegExp","Error"],function(e){v["is"+e]=function(t){return f.call(t)==="[object "+e+"]"}}),v.isArguments(arguments)||(v.isArguments=function(e){return v.has(e,"callee")}),"function"!=typeof/./&&"object"!=typeof Int8Array&&(v.isFunction=function(e){return"function"==typeof e||!1}),v.isFinite=function(e){return isFinite(e)&&!isNaN(parseFloat(e))},v.isNaN=function(e){return v.isNumber(e)&&e!==+e},v.isBoolean=function(e){return e===!0||e===!1||"[object Boolean]"===f.call(e)},v.isNull=function(e){return null===e},v.isUndefined=function(e){return void 0===e},v.has=function(e,t){return null!=e&&p.call(e,t)},v.noConflict=function(){return a._=i,this},v.identity=function(e){return e},v.constant=function(e){return function(){return e}},v.noop=function(){},v.property=j,v.propertyOf=function(e){return null==e?function(){}:function(t){return e[t]}},v.matcher=v.matches=function(e){return e=v.extendOwn({},e),function(t){return v.isMatch(t,e)}},v.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},v.random=function(e,t){return null==t&&(t=e,e=0),e+Math.floor(Math.random()*(t-e+1))},v.now=Date.now||function(){return(new Date).getTime()};var G={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},Q=v.invert(G),A=function(e){var t=function(t){return e[t]},n="(?:"+v.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}};v.escape=A(G),v.unescape=A(Q),v.result=function(e,t,n){var r=null==e?void 0:e[t];return void 0===r&&(r=n),v.isFunction(r)?r.call(e):r};var P=0;v.uniqueId=function(e){var t=++P+"";return e?e+t:t},v.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var F=/(.)^/,E={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},N=/\\|'|\r|\n|\u2028|\u2029/g,R=function(e){return"\\"+E[e]};v.template=function(e,t,n){!t&&n&&(t=n),t=v.defaults({},t,v.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,s){return i+=e.slice(a,s).replace(N,R),a=s+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(s){throw s.source=i,s}var u=function(e){return o.call(this,e,v)},l=t.variable||"obj";return u.source="function("+l+"){\n"+i+"}",u},v.chain=function(e){var t=v(e);return t._chain=!0,t};var D=function(e,t){return e._chain?v(t).chain():t};v.mixin=function(e){v.each(v.functions(e),function(t){var n=v[t]=e[t];v.prototype[t]=function(){var e=[this._wrapped];return l.apply(e,arguments),D(this,n.apply(v,e))}})},v.mixin(v),v.each(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=o[e];v.prototype[e]=function(){var n=this._wrapped;return t.apply(n,arguments),"shift"!==e&&"splice"!==e||0!==n.length||delete n[0],D(this,n)}}),v.each(["concat","join","slice"],function(e){var t=o[e];v.prototype[e]=function(){return D(this,t.apply(this._wrapped,arguments))}}),v.prototype.value=function(){return this._wrapped},v.prototype.valueOf=v.prototype.toJSON=v.prototype.value,v.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return v})}.call(this),"undefined"!=typeof module&&(module.exports=simpleheat),simpleheat.prototype={defaultRadius:25,defaultGradient:{.4:"blue",.6:"cyan",.7:"lime",.8:"yellow",1:"red"},data:function(e){return this._data=e,this},max:function(e){return this._max=e,this},add:function(e){return this._data.push(e),this},clear:function(){return this._data=[],this},radius:function(e,t){t=void 0===t?15:t;var n=this._circle=this._createCanvas(),r=n.getContext("2d"),a=this._r=e+t;return n.width=n.height=2*a,r.shadowOffsetX=r.shadowOffsetY=2*a,r.shadowBlur=t,r.shadowColor="black",r.beginPath(),r.arc(-a,-a,e,0,2*Math.PI,!0),r.closePath(),r.fill(),this},resize:function(){this._width=this._canvas.width,this._height=this._canvas.height},gradient:function(e){var t=this._createCanvas(),n=t.getContext("2d"),r=n.createLinearGradient(0,0,0,256);t.width=1,t.height=256;for(var a in e)r.addColorStop(+a,e[a]);return n.fillStyle=r,n.fillRect(0,0,1,256),this._grad=n.getImageData(0,0,1,256).data,this},draw:function(e){this._circle||this.radius(this.defaultRadius),this._grad||this.gradient(this.defaultGradient);var t=this._ctx;t.clearRect(0,0,this._width,this._height);for(var n,r=0,a=this._data.length;r<a;r++)n=this._data[r],t.globalAlpha=Math.min(Math.max(n[2]/this._max,void 0===e?.05:e),1),t.drawImage(this._circle,n[0]-this._r,n[1]-this._r);var i=t.getImageData(0,0,this._width,this._height);return this._colorize(i.data,this._grad),t.putImageData(i,0,0),this},_colorize:function(e,t){for(var n,r=0,a=e.length;r<a;r+=4)n=4*e[r+3],n&&(e[r]=t[n],e[r+1]=t[n+1],e[r+2]=t[n+2])},_createCanvas:function(){return"undefined"!=typeof document?document.createElement("canvas"):new this._canvas.constructor}},L.HeatLayer=(L.Layer?L.Layer:L.Class).extend({initialize:function(e,t){this._latlngs=e,L.setOptions(this,t)},setLatLngs:function(e){return this._latlngs=e,this.redraw()},addLatLng:function(e){return this._latlngs.push(e),this.redraw()},setOptions:function(e){return L.setOptions(this,e),this._heat&&this._updateOptions(),this.redraw()},redraw:function(){return this._heat&&!this._frame&&this._map&&!this._map._animating&&(this._frame=L.Util.requestAnimFrame(this._redraw,this)),this},onAdd:function(e){this._map=e,this._canvas||this._initCanvas(),this.options.pane?this.getPane().appendChild(this._canvas):e._panes.overlayPane.appendChild(this._canvas),e.on("moveend",this._reset,this),e.options.zoomAnimation&&L.Browser.any3d&&e.on("zoomanim",this._animateZoom,this),this._reset()},onRemove:function(e){this.options.pane?this.getPane().removeChild(this._canvas):e.getPanes().overlayPane.removeChild(this._canvas),e.off("moveend",this._reset,this),e.options.zoomAnimation&&e.off("zoomanim",this._animateZoom,this)},addTo:function(e){return e.addLayer(this),this},_initCanvas:function(){var e=this._canvas=L.DomUtil.create("canvas","leaflet-heatmap-layer leaflet-layer"),t=L.DomUtil.testProp(["transformOrigin","WebkitTransformOrigin","msTransformOrigin"]);e.style[t]="50% 50%";var n=this._map.getSize();e.width=n.x,e.height=n.y;var r=this._map.options.zoomAnimation&&L.Browser.any3d;L.DomUtil.addClass(e,"leaflet-zoom-"+(r?"animated":"hide")),this._heat=simpleheat(e),this._updateOptions()},_updateOptions:function(){this._heat.radius(this.options.radius||this._heat.defaultRadius,this.options.blur),this.options.gradient&&this._heat.gradient(this.options.gradient)},_reset:function(){var e=this._map.containerPointToLayerPoint([0,0]);L.DomUtil.setPosition(this._canvas,e);var t=this._map.getSize();this._heat._width!==t.x&&(this._canvas.width=this._heat._width=t.x),this._heat._height!==t.y&&(this._canvas.height=this._heat._height=t.y),this._redraw()},_redraw:function(){if(this._map){var e,t,n,r,a,i,o,s,u=[],l=this._heat._r,c=this._map.getSize(),f=new L.Bounds(L.point([-l,-l]),c.add([l,l])),p=l/2,d=[],y=this._map._getMapPanePos(),h=y.x%p,m=y.y%p;for(this._max=1,e=0,t=this._latlngs.length;e<t;e++){n=this._map.latLngToContainerPoint(this._latlngs[e]),a=Math.floor((n.x-h)/p)+2,i=Math.floor((n.y-m)/p)+2;var g=void 0!==this._latlngs[e].alt?this._latlngs[e].alt:void 0!==this._latlngs[e][2]?+this._latlngs[e][2]:1;d[i]=d[i]||[],r=d[i][a],r?(r[0]=(r[0]*r[2]+n.x*g)/(r[2]+g),r[1]=(r[1]*r[2]+n.y*g)/(r[2]+g),r[2]+=g):(r=d[i][a]=[n.x,n.y,g],r.p=n),r[2]>this._max&&(this._max=r[2])}for(this._heat.max(this._max),e=0,t=d.length;e<t;e++)if(d[e])for(o=0,s=d[e].length;o<s;o++)r=d[e][o],r&&f.contains(r.p)&&u.push([Math.round(r[0]),Math.round(r[1]),Math.min(r[2],this._max)]);this._heat.data(u).draw(this.options.minOpacity),this._frame=null}},_animateZoom:function(e){var t=this._map.getZoomScale(e.zoom),n=this._map._getCenterOffset(e.center)._multiplyBy(-t).subtract(this._map._getMapPanePos());L.DomUtil.setTransform?L.DomUtil.setTransform(this._canvas,n,t):this._canvas.style[L.DomUtil.TRANSFORM]=L.DomUtil.getTranslateString(n)+" scale("+t+")"}}),L.heatLayer=function(e,t){return new L.HeatLayer(e,t)};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(){defaultSettings(),drawingGroup=new L.FeatureGroup,mymap=L.map("mapid").setView([51.505,-.09],13),"undefined"!=typeof map.settings.base_layer&&""!=map.settings.base_layer?layername=map.settings.base_layer:selectedBaseLayers.length>0?layername=selectedBaseLayers[0].name:$.each(baseLayers.mymap,function(e,t){layername=e}),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),assingSettings()}),jQuery(document).ready(function(){initLayer();var e=getDetailsByAttr(selectedLayers,"type",2);0==e.length&&ajaxLoadSucess()}).ajaxStop(function(){ajaxLoadSucess()});