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,r,a=[];if(e instanceof L.Polygon||e instanceof L.Polyline){for(var n=e.getLatLngs(),i=0;i

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.

',html:!0,trigger:"hover",container:"body"}),jQuery(".at_active_chk").bootstrapSwitch({size:"mini",onSwitchChange:function(t,r){t.preventDefault();var a=jQuery(this).parents("ul:first"),n=a.attr("data-id"),i=getIndex(selectedLayers,"unique_id",n);selectedLayers[i].settings||"undefined"!=typeof selectedLayers[i].settings||(selectedLayers[i].settings=new Object),r===!0?(selectedLayers[i].settings.active=1,jQuery("#at-"+e.unique_id+" a.dropdown-toggle span").removeClass("label-danger").addClass("label-primary"),mymap.addLayer(featureGroup[n][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[n][selectedLayers[i].name])),calculateBounds()}})),1==e.type||4==e.type){var r={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&&(r.geometry=e.geometry_area),"undefined"!=typeof e.time&&(r.time=e.time),L.tileLayer.betterWms(e.url,r).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,r){$.each(r.properties,function(e,r){t=t.replace("<"+e+">",r)})}),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,r){L.geoJson(r,{onEachFeature:function(e,r){if(r instanceof L.Marker){var a=!1;"nr"==t.style.type?$.each(t.style.custom,function(n,i){if(between(e.properties[t.style.field],i.val))return a=!0,custom_marker_icon(i.style,r),!1}):"g"==t.style.type&&$.each(t.style.custom,function(n,i){if(e.properties[t.style.field]==i.val)return a=!0,custom_marker_icon(i.style,r),!1}),0==a&&custom_marker_icon(t.style.marker,r)}r.on("click",function(a){var n=getSQLPopupContent(e.properties,t.pc);r.bindPopup(n)})},style:function(e,r){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 r=jQuery("#base_layer_selection").find('input:checkbox[data-name="'+t.name+'"]');r.length>0&&(r.prop("checked","checked"),baseLayerMap(r,!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,r){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(r,{onEachFeature:function(e,r){selectedLayers[index].layer=r,1==t.settings.active&&drawingGroup.addLayer(r),featureGroup[t.unique_id][t.name].addLayer(r),r instanceof L.Marker&&r.setIcon(L.AwesomeMarkers.icon(selectedLayers[index].style.marker)),r.bindPopup(selectedLayers[index].pc)},style:function(e,r){return t.style.polygon},pointToLayer:function(e,r){return"undefined"!=typeof t.radius?L.circle(r,parseInt(t.radius,10)):L.marker(r)}})}),calculateBounds()}function custom_boundary(e,t,r){featureGroup[t]=new Array,featureGroup[t][r]=new L.FeatureGroup,"manage"==page&&featureGroup[t][r].addTo(mymap),jQuery.each(e.result,function(e,a){L.geoJson(a,{onEachFeature:function(e,a){featureGroup[t][r].addLayer(a)},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"==r&&mymap.fitBounds(featureGroup[t][r].getBounds())}function calculateBounds(){}function extend_bounds(e){}function getLayersIndex(e){var t=selectedLayers.length;for(i=0;i',t=t.replace("<"+e+">",r)):t=t.replace("<"+e+">",r)}),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 r=selectedLayers.length,a=new Array;for(i=0;i").attr("data-key",e.unique_id).attr("data-name",e.name).addClass("overlay_control_"+e.unique_id).html(Mustache.render(r,e)).appendTo("#visiable-layers div.dropdown-menu .custom-control-layers").find('input[type="checkbox"]').bootstrapSwitch({size:"mini",onSwitchChange:function(e,t){e.preventDefault();var r=jQuery(this).parents("li:first"),a=r.attr("data-key"),n=r.attr("data-name"),i=getIndex(selectedLayers,"unique_id",a);selectedLayers[i];t===!0?mymap.addLayer(featureGroup[a][n]):mymap.removeLayer(featureGroup[a][n])}})),"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+'"]'),r=document.getElementById("map-overlayer-sub-controls-tmpl").innerHTML;$.each(e.style.custom,function(a,n){$("
  • ").attr("data-key",e.unique_id).attr("data-name",e.name).attr("data-val",n.val).html(Mustache.render(r,{val:n.val,t:e})).appendTo(t.find("ul")).find('input[type="checkbox"]').bootstrapSwitch({size:"mini",onSwitchChange:function(e,t){e.preventDefault();var r=jQuery(this).parents("li:first"),a=r.attr("data-key"),n=r.attr("data-name"),i=r.attr("data-val"),o=getIndex(selectedLayers,"unique_id",a),s=selectedLayers[o],l=featureGroup[a][n].getLayers();$.each(l,function(e,r){r.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 r=$(t.attr("href"));return r.hasClass("in")?r.collapse("hide"):r.collapse("show"),!1})}function baselayers_controls(e){var t=document.getElementById("map-baselayer-controls-tmpl").innerHTML;Mustache.parse(t),$("
  • ").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 r=jQuery(this).parents("li:first"),a=r.attr("data-name");$.each(baseLayers.mymap,function(e,t){mymap.removeLayer(baseLayers.mymap[e])}),t===!0&&mymap.addLayer(baseLayers.mymap[a])}})}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(),r=getIndex(selectedLayers,"unique_id",t),a={};jQuery("#layer-polygon-styling input").each(function(){var e=jQuery(this);a[e.attr("name")]=e.val()});var n={};if(jQuery("#layer-marker-styling .default-marker-style select").each(function(){var e=jQuery(this);n[e.attr("data-name")]=e.val()}),2==selectedLayers[r].type){var i=featureGroup[selectedLayers[r].unique_id][selectedLayers[r].name].getLayers();$.each(i,function(e,t){t.eachLayer(function(e){e instanceof L.Marker?custom_marker_icon(n,e):(e instanceof L.Polyline||e instanceof L.Polygon||e instanceof L.Rectangle||e instanceof L.Circle)&&e.setStyle(a)})})}else if(3==selectedLayers[r].type){var o=selectedLayers[r].layer;o instanceof L.Marker?custom_marker_icon(n,o):(o instanceof L.Polyline||o instanceof L.Polygon||o instanceof L.Rectangle||o instanceof L.Circle)&&o.setStyle(a)}selectedLayers[r].style.polygon=a,selectedLayers[r].style.marker=n}function defaultLayerStyle(e){var t=new Object,r=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?r=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 r.icon&&(r.icon=""),"undefined"==typeof r.color&&(r.color="blue"),e.style.polygon=t,e.style.marker=r;var a=getIndex(selectedLayers,"unique_id",e.unique_id);return selectedLayers[a].style=e.style,e}function getLayerIndex1(e){var t=selectedLayers.length;for(i=0;i=r[0]&&e<=r[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 r=jQuery("#default_style_marker_icon").val();""!=r?e.icon=r: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 r=e.icon;if(r.indexOf(".png")!==-1){var a=baseURL+"assets/img/markers/"+e.markerColor+"-"+e.icon,n=L.Icon.extend({options:{iconUrl:a}});t.setIcon(new n)}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 r=jQuery(e.targetElm),a=getIndex(selectedLayers,"unique_id",r.attr("data-uniqueid"));selectedLayers[a].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 r=$self1.attr("data-startname"),a=$self1.attr("data-endname");$self1.parents(".input-daterange:first").find('[name="'+r+'"]').val(t.startDate.format("YYYY-MM-DD")),$self1.parents(".input-daterange:first").find('[name="'+a+'"]').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 r=jQuery("#global_filter").serializeArray();r.push({name:"type",value:2}),r.push({name:"datasource",value:t.connection_id}),r.push({name:"layer_id",value:t._id}),r.push({name:"map_id",value:map.id}),r.push({name:"_token",value:jQuery('[name="_token"]').val()}),r.push({name:"sql_layer_name",value:t.name}),r.push({name:"query_box",value:t.query}),r.push({name:"cache_key",value:t.cache_key}),r.push({name:"cache_timer",value:0}),ajaxRequest("map/layer/json","post","json",r,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(),r=new Array,a=0;return $.each(t,function(t,n){"undefined"!=typeof e.cluster&&1==e.cluster?r[a++]=n.feature.properties:n.eachLayer(function(e){r[a++]=e.feature.properties})}),r}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 r=L.DomUtil.create("div","info mapfig-legend");return r.innerHTML+='
    '+e.name+"
    ",$.each(e.style.custom,function(e,t){var a=t.style.icon;if(a.indexOf(".png")!==-1){var n=baseURL+"assets/img/markers/"+t.style.markerColor+"-"+t.style.icon;r.innerHTML+='
    '+t.val+"
    "}else r.innerHTML+='
    '+t.val+"
    "}),r},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),r=t.is(":checked"),a=t.parents("li:first"),n=a.attr("data-key"),i=a.attr("data-name"),o=getIndex(selectedLayers,"unique_id",n),s=selectedLayers[o];if("undefined"==typeof s)return void(r===!0?mymap.addLayer(featureGroup[n][i]):mymap.removeLayer(featureGroup[n][i]));if(r===!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[n]&&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;i1?s.url+c[0]+"/wms":s.url+"/wms":s.url;var d=l.l_id;if(e.is(":checked"))1==r&&(t=l,t.id=s.id,t.unique_id=d,t.type=a,t.name=l.Title,t.url=u,t.pc="",t.section_id=jQuery("#dd_section_id").val(),selectedLayers.push(t)),renderLayer(t,"");else{jQuery("#at-"+d).remove();var o=getLayersIndex(d);selectedLayers.splice(o,1),featureGroup[d][l.Title].clearLayers(),layerSelector.removeLayer(featureGroup[d][l.Title]),removeOverlayerControl(d)}calculateBounds()}function clearMap(){jQuery.each(selectedLayers,function(e,t){$self=jQuery("#layer_selection_"+t.gs.id).find('input:checkbox[data-layername="'+t.gs.layers.Name+'"]');var r=$self.attr("data-gsid"),a=$self.attr("data-layername"),n=getDetailsByAttr(layers,"id",r);n=n[0];var i=getDetailsByAttr(n.layers,"Name",a);i=i[0];var o="gs_"+i.Name+"_"+n.id;layerSelector.removeLayer(featureGroup[o][i.Title]),featureGroup[o][i.Title].clearLayers()})}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 r=jQuery(e.targetElm),a=getIndex(selectedLayers,"unique_id",r.attr("data-uniqueid"));selectedLayers[a].pc=e.getContent()})}})}function baseLayerMap(e,t){var r=e.attr("data-name"),a=e.val();if(e.is(":checked")){if(t===!0){layerSelector.addBaseLayer(baseLayers.mymap[r],r);var n=new Object;n.id=a,n.name=r,selectedBaseLayers.push(n),baselayers_controls(r)}}else{layerSelector.removeLayer(baseLayers.mymap[r]);var i=getIndex(selectedBaseLayers,"id",a);selectedBaseLayers.splice(i,1),jQuery('#custom_layers [data-name="'+r+'"]').remove()}selectedBaseLayers.length>0&&jQuery("#visiable-layers").find(".baselayers-control").removeClass("hide")}function makeFasterTree(e){var t=new Array;$.each(db.columns,function(e,r){var a=new Object;a.text=e,a.href=e,a.tags=r.length,a.nodes=new Array,$.each(r,function(e,t){var r=new Object;r.text=t.column_name,r.href=t.column_name,a.nodes.push(r)}),t.push(a)});var r={bootstrap2:!1,showTags:!1,levels:1,data:t,onNodeSelected:function(e,t){"undefined"==typeof t.parentId?$(this).treeview("toggleNodeExpanded",[t.nodeId,{silent:!0}]):jQuery("#query_box").val(jQuery("#query_box").val()+" "+t.href)}};$("#"+e).treeview(r),jQuery("#table_tree_container").slimScroll({height:400}),jQuery("#query-help-text-btn").slimScroll({height:400})}function getGeoLayer(e,t){var r=e.attr("data-id"),a=e.attr("data-wk");e.find(".loading").removeClass("hide"),0==e.find("ul").length&&ajaxRequest("developer/geoserver/layers/json","get","json",{id:r,type:t,wk:a},function(a){if(e.find(".loading").addClass("hide"),200==a.status){gslayers[t+"_"+r]=a.result;var n=document.getElementById("geoserver-layers-tmpl").innerHTML;Mustache.parse(n),e.find(".box-body").html(Mustache.render(n,{geolayers:a.result}));var i=getIndex(DBLayerType,"tmpl",t),o=getDetailsByType(selectedLayers,"id",r,"type",DBLayerType[i].id),s=jQuery("#"+t+'-container [data-id="'+r+'"]');jQuery.each(o,function(e,t){s.find('[data-layername="'+t.Name+'"]').prop("checked",!0)}),jQuery(".scroller").slimScroll({railVisible:!0,alwaysVisible:!0}),$('.gs-collapse input[type="checkbox"].layer_chk').each(function(){jQuery(this).bootstrapSwitch({size:"mini",onSwitchChange:function(e,t){var r=jQuery(e.target);WMSLayers(r,!0,1)}})}),$('.wms-collapse input[type="checkbox"].layer_chk').each(function(){jQuery(this).bootstrapSwitch({size:"mini",onSwitchChange:function(e,t){var r=jQuery(e.target);WMSLayers(r,!0,4)}})})}else showMsg(a.error,a.msg)})}function editATLayer(e){var t=getLayersIndex(e);currentIndex=t,1==selectedLayers[t].type||4==selectedLayers[t].type?layerDialog(selectedLayers[t]):2==selectedLayers[t].type?layerDialog(selectedLayers[t]):3==selectedLayers[t].type&&layerDialog(selectedLayers[t])}function editSQLATLayer(e){var t=getLayersIndex(e);if(currentIndex=t,1==selectedLayers[t].type)layerDialog(selectedLayers[t]);else if(2==selectedLayers[t].type){var r=document.getElementById("sql-layer-modal-tmpl").innerHTML;Mustache.parse(r),jQuery("#sql_layer_form").html(Mustache.render(r,{ds:ds})),jQuery("#sql-layer-modal").modal("show"),jQuery("#query_box").val(selectedLayers[t].query),jQuery("#query_box").val(selectedLayers[t].query),jQuery("#sql_layer_name").val(selectedLayers[t].name),jQuery("#sql_datasource").val(selectedLayers[t].connection_id),jQuery("#sql_unique_id").val(selectedLayers[t].unique_id),jQuery("#sql_datasource").trigger("change"),validateForm(jQuery("#sql_layer_form")),sqlFormChange=!1,SQLModeModal(selectedLayers[t].sqlMode)}else 3==selectedLayers[t].type&&layerDialog(selectedLayers[t])}function editCacheLayer(e){var t=getLayersIndex(e);currentIndex=t;var r=jQuery("#cache_settings_form");if(1==selectedLayers[t].type||3==selectedLayers[t].type){var a="Cache settings not avaliable for Geoserver layers.";3==selectedLayers[t].type&&(a="Cache settings not avaliable for FreeHand layers.");var n=document.getElementById("no-settings-msg-modal-tmpl").innerHTML;Mustache.parse(n),r.html(Mustache.render(n,{msg:a})),jQuery("#cache-settings-modal").modal("show"),jQuery("#cache-settings-modal .btn.btn-success").addClass("hide")}else if(2==selectedLayers[t].type){var i=document.getElementById("sql-layer-cache-modal-tmpl").innerHTML;Mustache.parse(i),r.html(Mustache.render(i,{ds:ds})),jQuery("#cache-settings-modal").modal("show"),r.find('[name="cache_timer"]').val(selectedLayers[t].cache_timer),r.find('[name="unique_id"]').val(selectedLayers[t].unique_id),validateForm(jQuery("#cache_settings_form")),jQuery("#cache-settings-modal .btn.btn-success").removeClass("hide")}}function editStyleLayer(e){var t=getLayersIndex(e);currentIndex=t;var r=jQuery("#style_settings_form");if(1==selectedLayers[t].type){var a=document.getElementById("geoserver-style-modal-tmpl").innerHTML;Mustache.parse(a),r.html(Mustache.render(a)),jQuery("#style-settings-modal").modal("show"),jQuery("#style-settings-modal .btn.btn-success").addClass("hide")}else if(2==selectedLayers[t].type){var n=document.getElementById("sql-layer-style-modal-tmpl").innerHTML;return Mustache.parse(n),jQuery("#map-sidebar-container").html(Mustache.render(n,{t:selectedLayers[t]})),jQuery(".control-sidebar").toggleClass("control-sidebar-open"),jQuery("#layer_polygon_fill_color,#layer_polygon_color").colorpicker({theme:"bootstrap"}).on("changeColor",function(e){applyLiveStyle()}),jQuery("#layer-polygon-styling input").change(function(){applyLiveStyle()}),jQuery("#layer-marker-styling select").change(function(){applyLiveStyle()}),void jQuery(".sidebar_hide").toggleClass("hide")}else 3==selectedLayers[t].type&&(jQuery("#layer_polygon_fill_color,#layer_polygon_color").colorpicker({theme:"bootstrap"}).on("changeColor",function(e){applyLiveStyle()}),jQuery("#layer-polygon-styling input").change(function(){applyLiveStyle()}))}function sqlFormEvent(){jQuery(".sql-layers-btn").click(function(){currentIndex=-1;var e=(jQuery(this).val(),document.getElementById("sql-layer-modal-tmpl").innerHTML);Mustache.parse(e),jQuery("#sql_layer_form").html(Mustache.render(e,{ds:ds})),jQuery("#sql-layer-modal").modal("show"),validateForm(jQuery("#sql_layer_form")),SQLModeModal()}),jQuery("#sql-layer-modal").on("change","#sql_datasource",function(){var e=jQuery(this).val();currentIndex!=-1&&selectedLayers[currentIndex].connection_id!=e&&setupEditor(),ajaxRequest("db/table/"+e,"get","json",{},function(e){200==e.status?(db.tables=e.tables,db.columns=e.columns,makeFasterTree("tree_5"),jQuery("#drag_table").html(""),jQuery("#drag_table").append(Mustache.render(table_tmpl,e)),currentIndex!=-1&&(jQuery("#drag_table").val(selectedLayers[currentIndex].table_name),jQuery("#drag_table").trigger("change")),jQuery("#drag_table").select2({width:"100%"})):showMsg("error",e.error)})}),jQuery("#sql-layer-modal").on("change","#drag_table",function(){var e=jQuery(this).val();if(jQuery("#drag_geometry_column").html(Mustache.render(column_tmpl,{columns:db.columns[e]})),jQuery("#drag_other_column").html(Mustache.render(column_tmpl,{columns:db.columns[e]})),currentIndex!=-1&&(jQuery("#drag_geometry_column").val(selectedLayers[currentIndex].geometry_col),"undefined"!=typeof selectedLayers[currentIndex].other_col&&selectedLayers[currentIndex].other_col.length>0))for(var t in selectedLayers[currentIndex].other_col){var r=selectedLayers[currentIndex].other_col[t];$("#drag_other_column").find("option[value="+r+"]").prop("selected","selected")}jQuery("#drag_other_column, #drag_geometry_column").select2({width:"100%"})}),jQuery("#sql-layer-modal").on("change","#geohelm_tags",function(){var e=jQuery(this).val();jQuery("#query_box").val(jQuery("#query_box").val()+e)}),jQuery("#sql-layer-save-btn").click(function(e){e.preventDefault();var r=jQuery(this);if(jQuery("#sql_layer_form").validate().form())if(sqlFormChange===!0){r.button("loading");var a=jQuery("#sql_layer_form").serialize();ajaxRequest("developer/map/sql/layer/save","post","json",a,function(e){if(r.button("reset"),200==e.status){sqlMode=jQuery("#sql-mode-switch").bootstrapSwitch("state");var a=jQuery("#sql_unique_id").val(),n=-1;""!=a?(n=getLayersIndex(a),t=selectedLayers[n]):(t=new Object,t.unique_id=uniqId("pg"),t.pc="",t.type=2,t.cache_timer=15),t.connection_id=jQuery("#sql_datasource").val(),t.section_id=jQuery("#dd_section_id").val(),1==sqlMode?(t.query=jQuery("#query_box").val(),t.sqlMode=!0):t.query=e.query, t.table_name=jQuery("#drag_table").val(),t.geometry_col=jQuery("#drag_geometry_column").val(),t.other_col=jQuery("#drag_other_column").val(),t.name=jQuery("#sql_layer_name").val(),t.properties=e.columns,n!=-1?(selectedLayers[n]=t,mymap.removeLayer(featureGroup[t.unique_id][t.name]),mymap.addLayer(featureGroup[t.unique_id][t.name]),processSQLJSON(e,t)):(selectedLayers.push(t),renderLayer(t,e)),jQuery("#sql-layer-modal").modal("hide")}else showMsg(e.status,e.msg)})}else jQuery("#sql-layer-modal").modal("hide")}),jQuery("#geoserver-layer-save-btn").click(function(e){e.preventDefault();jQuery(this);if(jQuery("#geoserver_layer_form").validate().form()){var r=jQuery("#geoserver_unique_id").val(),a=-1;""!=r?(a=getLayersIndex(r),t=selectedLayers[a]):(t=new Object,t.unique_id=uniqId("pg"),t.pc="",t.type=2),t.name=jQuery("#geoserver_layer_name").val(),a!=-1?(selectedLayers[a]=t,jQuery("#at-"+t.unique_id+" span").html(t.name)):(selectedLayers.push(t),renderLayer(t,data)),jQuery("#geoserver-layer-modal").modal("hide")}}),jQuery("#sql-layer-modal").on("change","#sql_datasource, #drag_sql_datasource",function(){sqlFormChange=!0}),jQuery("#sql-layer-modal").on("change","#query_box, #drag_geometry_column,#drag_other_column,#drag_table",function(){sqlFormChange=!0})}function SQLModeModal(e){jQuery("#drag_sql_datasource,#sql_datasource").select2({width:"100%"}),$("#sql-mode-switch").on("switchChange.bootstrapSwitch",function(e,t){sqlFormChange=!0,e.preventDefault(),jQuery("#sql_mode").val(!0),t===!0?(jQuery("#sql-mode-container").show(),jQuery("#drag-drop-container").hide()):(jQuery("#sql-mode-container").hide(),jQuery("#drag-drop-container").show())}),jQuery("#sql-mode-switch").bootstrapSwitch("state",e,!1)}function setupEditor(){jQuery("#query_box").val(""),jQuery("#drag_table").val(""),jQuery("#drag_geometry_column").val(""),jQuery("#drag_other_column").val("")}function drawing_event(){var e=function(){mymap.on("draw:drawstart",function(e){draw_editStart(e)}),mymap.on("draw:deletestart",function(e){draw_editStart(e)}),mymap.on("draw:editstop",function(e){draw_editStop(e)}),mymap.on("draw:drawstop",function(e){draw_editStop(e)}),mymap.on("draw:deletestop",function(e){draw_editStop(e)}),mymap.on("moveend",function(e){updateMapCenter()}),mymap.on("draw:created",function(e){var t=new Object;t.lt=e.layerType;var r=e.layer;drawingGroup.addLayer(r),r.on("click",function(){var e=getLayerIndex1(r);editMode?(layerDialog(selectedLayers[e]),setTimeout(function(){mymap.closePopup()},50)):r.bindPopup(selectedLayers[e].pc)}),style={};r instanceof L.Marker?(style.marker=new Object,style.marker.icon="",style.marker.color="",t.marker=!0,t.polygon=!1):(r instanceof L.MultiPolygon||r instanceof L.Polyline||r instanceof L.Rectangle||r instanceof L.Circle)&&(style.polygon=new Object,style.polygon.color="#ff0000",style.polygon.opacity=.5,style.polygon.weight=5,style.polygon.fillColor="#ff0000",style.polygon.fillOpacity=.5,r.setStyle(style.polygon),t.marker=!1,t.polygon=!0),t.layer=r,t.style=style,t.type=3,t.name="Layer Name",t.location="",t.pc="",t.section_id=jQuery("#dd_section_id").val(),t.unique_id=uniqId("cl"),selectedLayers.push(t),layerDialog(t),renderLayer(t)}),mymap.on("draw:editstart",function(e){draw_editStart(),editMode=!0}),mymap.on("draw:editstop",function(e){editMode=!1,draw_editStop(e)}),mymap.on("draw:deleted",function(e){var t=e.layers;t.eachLayer(function(e){(e instanceof L.MultiPolygon||e instanceof L.Polyline||e instanceof L.Rectangle||e instanceof L.Circle||e instanceof L.Marker)&&deleteLayer(e.feature.properties.unique_id)})})};e(),$(".leaflet-draw.leaflet-control").hide(),$("#mapid > #data").show(),$("#draw-polyline,#draw-polygon,#draw-rectangle,#draw-marker, #edit-edit,#edit-remove, #draw-circle").click(function(e){if("#"==$(this).attr("href")){e.preventDefault();var t=$(this).attr("id");$(".leaflet-draw-"+t)[0].click()}})}function draw_editStart(e){var t=0;setTimeout(function(){info=$(".leaflet-draw-tooltip").text().replace("Click cancel to undo changes.",""),$("#control-tip-info").html(info),$("#control-tip-buttons").text(""),$(".leaflet-draw-actions li").each(function(e){var r=$(this);if("block"==r.parent().css("display")){var a=r.text(),n="";n=/cancel/i.test(a)?"remove":/save/i.test(a)?"save":"trash",Actions=' '+r.text()+"",$("#control-tip-buttons").prepend(Actions)}})},100)}function draw_editStop(e){$("#control-tip-info").html('Select the Shape to draw on Map or click here to import gpx, json or kml.'),$("#control-tip-buttons").text("")}function updateMapCenter(){canter=mymap.getCenter(),$("input[name=latitude]").val(canter.lat),$("input[name=longitude]").val(canter.lng),$("#mapcenter").val("["+canter.lat+","+canter.lng+"]")}function layerDialog(e){var t=document.getElementById("cl-style-modal-tmpl").innerHTML;if(Mustache.parse(t),jQuery("#map-sidebar-container").html(Mustache.render(t,{t:e,type:layerType[e.type]})),jQuery(".sidebar_hide").hasClass("hide")||(jQuery(".sidebar_hide").toggleClass("hide"),jQuery(".control-sidebar").toggleClass("control-sidebar-open")),"undefined"!=typeof e.cluster&&1==e.cluster&&jQuery("#clustering_option").prop("checked","checked"),tinyMCEInit_Popup('#cs-layer-popup [name="pc"]'),2==e.type||3==e.type){if("nr"==e.style.type||"g"==e.style.type)if(featuredata=getSQLFeatureData(e),"nr"==e.style.type){var r=_.max(featuredata,function(t){return t[e.style.field]}),a=document.getElementById(e.style.type+"-style-selection").innerHTML;Mustache.parse(a),jQuery("#style_column_name").val(e.style.field),jQuery("#style_data_type").val(e.style.type),jQuery("#attribute-input-field").html(Mustache.render(a,{max:r[e.style.field]}));$.each(e.style.custom,function(t,r){var a=document.getElementById(e.style.type+"-column-style-selection").innerHTML;Mustache.parse(a);var n=Mustache.render(a,{});jQuery("#attribute-input-field table tbody").append(n);var i=jQuery("#attribute-input-field table tbody tr:last");i.find("input").val(r.val),i.find('select[data-name="markerColor"]').val(r.style.markerColor),i.find('select[data-name="icon"]').val(r.style.icon)})}else if("g"==e.style.type){var r=_.groupBy(featuredata,function(t){return parseFloat(t[e.style.field])}),a=document.getElementById(e.style.type+"-style-selection").innerHTML;Mustache.parse(a),jQuery("#style_column_name").val(e.style.field),jQuery("#style_data_type").val(e.style.type),jQuery("#attribute-input-field").html(Mustache.render(a,{max:r[e.style.field]}));$.each(e.style.custom,function(t,r){var a=document.getElementById(e.style.type+"-column-style-selection").innerHTML;Mustache.parse(a);var n=Mustache.render(a,{});jQuery("#attribute-input-field table tbody").append(n);var i=jQuery("#attribute-input-field table tbody tr:last");i.find("input").val(r.val),i.find('select[data-name="markerColor"]').val(r.style.markerColor),i.find('select[data-name="icon"]').val(r.style.icon)})}jQuery("#layer_polygon_fill_color,#layer_polygon_color").colorpicker({theme:"bootstrap"}).on("changeColor",function(e){applyLiveStyle()}),jQuery("#clustering_option").change(function(){var e=jQuery('#map-sidebar-container [name="my_unique_id"]').val(),t=getIndex(selectedLayers,"unique_id",e);jQuery(this).is(":checked")?selectedLayers[t].cluster=1:selectedLayers[t].cluster=0}),jQuery("#layer-polygon-styling input").change(function(){applyLiveStyle()}),jQuery("#layer-marker-styling .default-marker-style select").change(function(){applyLiveStyle()}),jQuery("#layer-marker-styling").on("click",".numeric-range",function(){var e=jQuery(this).parents("tr:first"),t=e.clone();t.find("input").val(""),e.after(t)}),jQuery("#layer-marker-styling .custom-marker-style #style_data_type, #layer-marker-styling .custom-marker-style #style_column_name").change(function(){var e=jQuery("#style_column_name").val(),t=jQuery("#style_data_type").val();if(""!=e&&""!=t){jQuery("#attribute-input-field").html("");var r=jQuery('#map-sidebar-container [name="my_unique_id"]').val(),a=getIndex(selectedLayers,"unique_id",r);if(featuredata=getSQLFeatureData(selectedLayers[a]),"nr"==t){var n=_.max(featuredata,function(t){return parseFloat(t[e])}),i=document.getElementById(t+"-style-selection").innerHTML;if(Mustache.parse(i),jQuery("#attribute-input-field").html(Mustache.render(i,{max:n[e]})),0==jQuery("#attribute-input-field table tboday tr").length){var i=document.getElementById("nr-column-style-selection").innerHTML;Mustache.parse(i);var o=Mustache.render(i,{});jQuery("#attribute-input-field table tbody").append(o)}}else{var n=_.groupBy(featuredata,function(t){return t[e]}),i=document.getElementById(t+"-style-selection").innerHTML;Mustache.parse(i),jQuery("#attribute-input-field").html(Mustache.render(i,{max:n[e]})),$.each(n,function(e,t){var r=document.getElementById("g-column-style-selection").innerHTML;Mustache.parse(r);var a=Mustache.render(r,{attr:e});jQuery("#attribute-input-field table tbody").append(a)})}}});var n=new Array,i=0;jQuery("#attribute-input-field").on("change","table input, table select",function(){var e=jQuery('#map-sidebar-container [name="my_unique_id"]').val(),t=getIndex(selectedLayers,"unique_id",e),r=featureGroup[selectedLayers[t].unique_id][selectedLayers[t].name].getLayers(),a=jQuery("#style_column_name").val(),o=jQuery("#style_data_type").val();n=new Array,i=0,jQuery("#attribute-numeric-table tbody tr").each(function(){var e=jQuery(this),s=e.find("input:text").val(),l={};e.find("select").each(function(){l[jQuery(this).attr("data-name")]=jQuery(this).val()}),n[i]=new Object,n[i].val=s,n[i].style=l,i++,l=getMarkerStyle(l),"undefined"!=typeof selectedLayers[t].cluster&&1==selectedLayers[t].cluster?$.each(r,function(e,t){if("nr"==o){if(between(t.feature.properties[a],s)){var r={};r.style=l,custom_marker_icon(r.style,t)}}else if("g"==o&&t.feature.properties[a]==s){var r={};r.style=l,custom_marker_icon(r.style,t)}}):$.each(r,function(e,t){t.eachLayer(function(e){if("nr"==o){if(between(e.feature.properties[a],s)){var t={};t.style=l,custom_marker_icon(t.style,e)}}else if("g"==o&&e.feature.properties[a]==s){var t={};t.style=l,custom_marker_icon(t.style,e)}})})}),"undefined"==typeof selectedLayers[t].style.custom&&(selectedLayers[t].style.custom=new Object),selectedLayers[t].style.custom=n,selectedLayers[t].style.type=o,selectedLayers[t].style.field=a}),e.style.marker&&"undefined"!=typeof e.style.marker&&(jQuery('#layer-marker-styling select[name="marker_color"]').val(e.style.marker.markerColor),jQuery('#layer-marker-styling select[name="marker_icon"]').val(e.style.marker.icon))}jQuery('#cs-layer-info input[type="text"]').change(function(){var e=jQuery(this),t=jQuery('#map-sidebar-container [name="my_unique_id"]').val(),r=getIndex(selectedLayers,"unique_id",t);selectedLayers[r][e.attr("name")]=e.val(),jQuery("#at-"+selectedLayers[r].unique_id+" span.at-text").html(selectedLayers[r].name)}),3==e.type&&(autocomplete=new google.maps.places.Autocomplete(document.getElementById("autoFillAddress"),{types:["geocode"]}),google.maps.event.addListener(autocomplete,"place_changed",function(e){lat=autocomplete.getPlace().geometry.location.lat(),lng=autocomplete.getPlace().geometry.location.lng();var t=jQuery("#style_settings_form").find('[name="my_unique_id"]').val(),r=getIndex(selectedLayers,"unique_id",t);selectedLayers[r].layer.setLatLng([lat,lng]),selectedLayers[r].location=jQuery("#autoFillAddress").val(),mymap.setView([lat,lng],mymap.getZoom())}))}function tipButtonsclick(e){var t=void 0;return $(".leaflet-draw-actions").each(function(e){"block"==$(this).css("display")&&(t=$(this))}),t&&t.find("a")[e].click(),!1}function getDetailsByType(e,t,r,a,n){var o=[],s=e.length;for(i=0;i"'`=\/]/g,function(e){return v[e]})}function l(t,r){function n(){if(g&&!v)for(;h.length;)delete f[h.pop()];else h=[];g=!1,v=!1}function i(e){if("string"==typeof e&&(e=e.split(L,2)),!m(e)||2!==e.length)throw new Error("Invalid tags: "+e);s=new RegExp(a(e[0])+"\\s*"),l=new RegExp("\\s*"+a(e[1])),y=new RegExp("\\s*"+a("}"+e[1]))}if(!t)return[];var s,l,y,p=[],f=[],h=[],g=!1,v=!1;i(r||e.tags);for(var Q,k,x,M,q,S,I=new d(t);!I.eos();){if(Q=I.pos,x=I.scanUntil(s))for(var C=0,T=x.length;C0?i[i.length-1][4]:a;break;default:n.push(t)}return a}function d(e){this.string=e,this.tail=e,this.pos=0}function y(e,t){this.view=e,this.cache={".":this.view},this.parent=t}function p(){this.cache={}}var f=Object.prototype.toString,m=Array.isArray||function(e){return"[object Array]"===f.call(e)},h=RegExp.prototype.test,g=/\S/,v={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="},_=/\s*/,L=/\s+/,b=/\s*=/,j=/\s*\}/,w=/#|\^|\/|>|\{|&|=|!/;d.prototype.eos=function(){return""===this.tail},d.prototype.scan=function(e){var t=this.tail.match(e);if(!t||0!==t.index)return"";var r=t[0];return this.tail=this.tail.substring(r.length),this.pos+=r.length,r},d.prototype.scanUntil=function(e){var t,r=this.tail.search(e);switch(r){case-1:t=this.tail,this.tail="";break;case 0:t="";break;default:t=this.tail.substring(0,r),this.tail=this.tail.substring(r)}return this.pos+=t.length,t},y.prototype.push=function(e){return new y(e,this)},y.prototype.lookup=function(e){var r,a=this.cache;if(a.hasOwnProperty(e))r=a[e];else{for(var i,o,s=this,l=!1;s;){if(e.indexOf(".")>0)for(r=s.view,i=e.split("."),o=0;null!=r&&o"===i?o=this.renderPartial(n,t,r,a):"&"===i?o=this.unescapedValue(n,t):"name"===i?o=this.escapedValue(n,t):"text"===i&&(o=this.rawValue(n)),void 0!==o&&(s+=o);return s},p.prototype.renderSection=function(e,r,a,n){function i(e){return o.render(e,r,a)}var o=this,s="",l=r.lookup(e[1]);if(l){if(m(l))for(var u=0,c=l.length;u=0&&o>i;i+=e){var s=n?n[i]:i;a=r(a,t[s],s,t)}return a}return function(r,a,n,i){a=_(a,i,4);var o=!x(r)&&v.keys(r),s=(o||r).length,l=e>0?0:s-1;return arguments.length<3&&(n=r[o?o[l]:l],l+=e),t(r,a,n,o,l,s)}}function t(e){return function(t,r,a){r=L(r,a);for(var n=k(t),i=e>0?0:n-1;i>=0&&n>i;i+=e)if(r(t[i],i,t))return i;return-1}}function r(e,t,r){return function(a,n,i){var o=0,s=k(a);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(r&&i&&s)return i=r(a,n),a[i]===n?i:-1;if(n!==n)return i=t(c.call(a,o,s),v.isNaN),i>=0?i+o:-1;for(i=e>0?o:s-1;i>=0&&s>i;i+=e)if(a[i]===n)return i;return-1}}function a(e,t){var r=C.length,a=e.constructor,n=v.isFunction(a)&&a.prototype||s,i="constructor";for(v.has(e,i)&&!v.contains(t,i)&&t.push(i);r--;)i=C[r],i in e&&e[i]!==n[i]&&!v.contains(t,i)&&t.push(i)}var n=this,i=n._,o=Array.prototype,s=Object.prototype,l=Function.prototype,u=o.push,c=o.slice,d=s.toString,y=s.hasOwnProperty,p=Array.isArray,f=Object.keys,m=l.bind,h=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):n._=v,v.VERSION="1.8.3";var _=function(e,t,r){if(void 0===t)return e;switch(null==r?3:r){case 1:return function(r){return e.call(t,r)};case 2:return function(r,a){return e.call(t,r,a)};case 3:return function(r,a,n){return e.call(t,r,a,n)};case 4:return function(r,a,n,i){return e.call(t,r,a,n,i)}}return function(){return e.apply(t,arguments)}},L=function(e,t,r){return null==e?v.identity:v.isFunction(e)?_(e,t,r):v.isObject(e)?v.matcher(e):v.property(e)};v.iteratee=function(e,t){return L(e,t,1/0)};var b=function(e,t){return function(r){var a=arguments.length;if(2>a||null==r)return r;for(var n=1;a>n;n++)for(var i=arguments[n],o=e(i),s=o.length,l=0;s>l;l++){var u=o[l];t&&void 0!==r[u]||(r[u]=i[u])}return r}},j=function(e){if(!v.isObject(e))return{};if(h)return h(e);g.prototype=e;var t=new g;return g.prototype=null,t},w=function(e){return function(t){return null==t?void 0:t[e]}},Q=Math.pow(2,53)-1,k=w("length"),x=function(e){var t=k(e);return"number"==typeof t&&t>=0&&Q>=t};v.each=v.forEach=function(e,t,r){t=_(t,r);var a,n;if(x(e))for(a=0,n=e.length;n>a;a++)t(e[a],a,e);else{var i=v.keys(e);for(a=0,n=i.length;n>a;a++)t(e[i[a]],i[a],e)}return e},v.map=v.collect=function(e,t,r){t=L(t,r);for(var a=!x(e)&&v.keys(e),n=(a||e).length,i=Array(n),o=0;n>o;o++){var s=a?a[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,r){var a;return a=x(e)?v.findIndex(e,t,r):v.findKey(e,t,r),void 0!==a&&a!==-1?e[a]:void 0},v.filter=v.select=function(e,t,r){var a=[];return t=L(t,r),v.each(e,function(e,r,n){t(e,r,n)&&a.push(e)}),a},v.reject=function(e,t,r){return v.filter(e,v.negate(L(t)),r)},v.every=v.all=function(e,t,r){t=L(t,r);for(var a=!x(e)&&v.keys(e),n=(a||e).length,i=0;n>i;i++){var o=a?a[i]:i;if(!t(e[o],o,e))return!1}return!0},v.some=v.any=function(e,t,r){t=L(t,r);for(var a=!x(e)&&v.keys(e),n=(a||e).length,i=0;n>i;i++){var o=a?a[i]:i;if(t(e[o],o,e))return!0}return!1},v.contains=v.includes=v.include=function(e,t,r,a){return x(e)||(e=v.values(e)),("number"!=typeof r||a)&&(r=0),v.indexOf(e,t,r)>=0},v.invoke=function(e,t){var r=c.call(arguments,2),a=v.isFunction(t);return v.map(e,function(e){var n=a?t:e[t];return null==n?n:n.apply(e,r)})},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,r){var a,n,i=-1/0,o=-1/0;if(null==t&&null!=e){e=x(e)?e:v.values(e);for(var s=0,l=e.length;l>s;s++)a=e[s],a>i&&(i=a)}else t=L(t,r),v.each(e,function(e,r,a){n=t(e,r,a),(n>o||n===-1/0&&i===-1/0)&&(i=e,o=n)});return i},v.min=function(e,t,r){var a,n,i=1/0,o=1/0;if(null==t&&null!=e){e=x(e)?e:v.values(e);for(var s=0,l=e.length;l>s;s++)a=e[s],i>a&&(i=a)}else t=L(t,r),v.each(e,function(e,r,a){n=t(e,r,a),(o>n||1/0===n&&1/0===i)&&(i=e,o=n)});return i},v.shuffle=function(e){for(var t,r=x(e)?e:v.values(e),a=r.length,n=Array(a),i=0;a>i;i++)t=v.random(0,i),t!==i&&(n[i]=n[t]),n[t]=r[i];return n},v.sample=function(e,t,r){return null==t||r?(x(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,r){return t=L(t,r),v.pluck(v.map(e,function(e,r,a){return{value:e,index:r,criteria:t(e,r,a)}}).sort(function(e,t){var r=e.criteria,a=t.criteria;if(r!==a){if(r>a||void 0===r)return 1;if(a>r||void 0===a)return-1}return e.index-t.index}),"value")};var M=function(e){return function(t,r,a){var n={};return r=L(r,a),v.each(t,function(a,i){var o=r(a,i,t);e(n,a,o)}),n}};v.groupBy=M(function(e,t,r){v.has(e,r)?e[r].push(t):e[r]=[t]}),v.indexBy=M(function(e,t,r){e[r]=t}),v.countBy=M(function(e,t,r){v.has(e,r)?e[r]++:e[r]=1}),v.toArray=function(e){return e?v.isArray(e)?c.call(e):x(e)?v.map(e,v.identity):v.values(e):[]},v.size=function(e){return null==e?0:x(e)?e.length:v.keys(e).length},v.partition=function(e,t,r){t=L(t,r);var a=[],n=[];return v.each(e,function(e,r,i){(t(e,r,i)?a:n).push(e)}),[a,n]},v.first=v.head=v.take=function(e,t,r){ return null==e?void 0:null==t||r?e[0]:v.initial(e,e.length-t)},v.initial=function(e,t,r){return c.call(e,0,Math.max(0,e.length-(null==t||r?1:t)))},v.last=function(e,t,r){return null==e?void 0:null==t||r?e[e.length-1]:v.rest(e,Math.max(0,e.length-t))},v.rest=v.tail=v.drop=function(e,t,r){return c.call(e,null==t||r?1:t)},v.compact=function(e){return v.filter(e,v.identity)};var q=function(e,t,r,a){for(var n=[],i=0,o=a||0,s=k(e);s>o;o++){var l=e[o];if(x(l)&&(v.isArray(l)||v.isArguments(l))){t||(l=q(l,t,r));var u=0,c=l.length;for(n.length+=c;c>u;)n[i++]=l[u++]}else r||(n[i++]=l)}return n};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,r,a){v.isBoolean(t)||(a=r,r=t,t=!1),null!=r&&(r=L(r,a));for(var n=[],i=[],o=0,s=k(e);s>o;o++){var l=e[o],u=r?r(l,o,e):l;t?(o&&i===u||n.push(l),i=u):r?v.contains(i,u)||(i.push(u),n.push(l)):v.contains(n,l)||n.push(l)}return n},v.union=function(){return v.uniq(q(arguments,!0,!0))},v.intersection=function(e){for(var t=[],r=arguments.length,a=0,n=k(e);n>a;a++){var i=e[a];if(!v.contains(t,i)){for(var o=1;r>o&&v.contains(arguments[o],i);o++);o===r&&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,k).length||0,r=Array(t),a=0;t>a;a++)r[a]=v.pluck(e,a);return r},v.object=function(e,t){for(var r={},a=0,n=k(e);n>a;a++)t?r[e[a]]=t[a]:r[e[a][0]]=e[a][1];return r},v.findIndex=t(1),v.findLastIndex=t(-1),v.sortedIndex=function(e,t,r,a){r=L(r,a,1);for(var n=r(t),i=0,o=k(e);o>i;){var s=Math.floor((i+o)/2);r(e[s])i;i++,e+=r)n[i]=e;return n};var S=function(e,t,r,a,n){if(!(a instanceof t))return e.apply(r,n);var i=j(e.prototype),o=e.apply(i,n);return v.isObject(o)?o:i};v.bind=function(e,t){if(m&&e.bind===m)return m.apply(e,c.call(arguments,1));if(!v.isFunction(e))throw new TypeError("Bind must be called on a function");var r=c.call(arguments,2),a=function(){return S(e,a,t,this,r.concat(c.call(arguments)))};return a},v.partial=function(e){var t=c.call(arguments,1),r=function(){for(var a=0,n=t.length,i=Array(n),o=0;n>o;o++)i[o]=t[o]===v?arguments[a++]:t[o];for(;a=a)throw new Error("bindAll must be passed function names");for(t=1;a>t;t++)r=arguments[t],e[r]=v.bind(e[r],e);return e},v.memoize=function(e,t){var r=function(a){var n=r.cache,i=""+(t?t.apply(this,arguments):a);return v.has(n,i)||(n[i]=e.apply(this,arguments)),n[i]};return r.cache={},r},v.delay=function(e,t){var r=c.call(arguments,2);return setTimeout(function(){return e.apply(null,r)},t)},v.defer=v.partial(v.delay,v,1),v.throttle=function(e,t,r){var a,n,i,o=null,s=0;r||(r={});var l=function(){s=r.leading===!1?0:v.now(),o=null,i=e.apply(a,n),o||(a=n=null)};return function(){var u=v.now();s||r.leading!==!1||(s=u);var c=t-(u-s);return a=this,n=arguments,0>=c||c>t?(o&&(clearTimeout(o),o=null),s=u,i=e.apply(a,n),o||(a=n=null)):o||r.trailing===!1||(o=setTimeout(l,c)),i}},v.debounce=function(e,t,r){var a,n,i,o,s,l=function(){var u=v.now()-o;t>u&&u>=0?a=setTimeout(l,t-u):(a=null,r||(s=e.apply(i,n),a||(i=n=null)))};return function(){i=this,n=arguments,o=v.now();var u=r&&!a;return a||(a=setTimeout(l,t)),u&&(s=e.apply(i,n),i=n=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 r=t,a=e[t].apply(this,arguments);r--;)a=e[r].call(this,a);return a}},v.after=function(e,t){return function(){return--e<1?t.apply(this,arguments):void 0}},v.before=function(e,t){var r;return function(){return--e>0&&(r=t.apply(this,arguments)),1>=e&&(t=null),r}},v.once=v.partial(v.before,2);var I=!{toString:null}.propertyIsEnumerable("toString"),C=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];v.keys=function(e){if(!v.isObject(e))return[];if(f)return f(e);var t=[];for(var r in e)v.has(e,r)&&t.push(r);return I&&a(e,t),t},v.allKeys=function(e){if(!v.isObject(e))return[];var t=[];for(var r in e)t.push(r);return I&&a(e,t),t},v.values=function(e){for(var t=v.keys(e),r=t.length,a=Array(r),n=0;r>n;n++)a[n]=e[t[n]];return a},v.mapObject=function(e,t,r){t=L(t,r);for(var a,n=v.keys(e),i=n.length,o={},s=0;i>s;s++)a=n[s],o[a]=t(e[a],a,e);return o},v.pairs=function(e){for(var t=v.keys(e),r=t.length,a=Array(r),n=0;r>n;n++)a[n]=[t[n],e[t[n]]];return a},v.invert=function(e){for(var t={},r=v.keys(e),a=0,n=r.length;n>a;a++)t[e[r[a]]]=r[a];return t},v.functions=v.methods=function(e){var t=[];for(var r in e)v.isFunction(e[r])&&t.push(r);return t.sort()},v.extend=b(v.allKeys),v.extendOwn=v.assign=b(v.keys),v.findKey=function(e,t,r){t=L(t,r);for(var a,n=v.keys(e),i=0,o=n.length;o>i;i++)if(a=n[i],t(e[a],a,e))return a},v.pick=function(e,t,r){var a,n,i={},o=e;if(null==o)return i;v.isFunction(t)?(n=v.allKeys(o),a=_(t,r)):(n=q(arguments,!1,!1,1),a=function(e,t,r){return t in r},o=Object(o));for(var s=0,l=n.length;l>s;s++){var u=n[s],c=o[u];a(c,u,o)&&(i[u]=c)}return i},v.omit=function(e,t,r){if(v.isFunction(t))t=v.negate(t);else{var a=v.map(q(arguments,!1,!1,1),String);t=function(e,t){return!v.contains(a,t)}}return v.pick(e,t,r)},v.defaults=b(v.allKeys,!0),v.create=function(e,t){var r=j(e);return t&&v.extendOwn(r,t),r},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 r=v.keys(t),a=r.length;if(null==e)return!a;for(var n=Object(e),i=0;a>i;i++){var o=r[i];if(t[o]!==n[o]||!(o in n))return!1}return!0};var T=function(e,t,r,a){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 n=d.call(e);if(n!==d.call(t))return!1;switch(n){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]"===n;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}r=r||[],a=a||[];for(var l=r.length;l--;)if(r[l]===e)return a[l]===t;if(r.push(e),a.push(t),i){if(l=e.length,l!==t.length)return!1;for(;l--;)if(!T(e[l],t[l],r,a))return!1}else{var u,c=v.keys(e);if(l=c.length,v.keys(t).length!==l)return!1;for(;l--;)if(u=c[l],!v.has(t,u)||!T(e[u],t[u],r,a))return!1}return r.pop(),a.pop(),!0};v.isEqual=function(e,t){return T(e,t)},v.isEmpty=function(e){return null==e||(x(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=p||function(e){return"[object Array]"===d.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 d.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]"===d.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&&y.call(e,t)},v.noConflict=function(){return n._=i,this},v.identity=function(e){return e},v.constant=function(e){return function(){return e}},v.noop=function(){},v.property=w,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,r){var a=Array(Math.max(0,e));t=_(t,r,1);for(var n=0;e>n;n++)a[n]=t(n);return a},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 O={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},F=v.invert(O),B=function(e){var t=function(t){return e[t]},r="(?:"+v.keys(e).join("|")+")",a=RegExp(r),n=RegExp(r,"g");return function(e){return e=null==e?"":""+e,a.test(e)?e.replace(n,t):e}};v.escape=B(O),v.unescape=B(F),v.result=function(e,t,r){var a=null==e?void 0:e[t];return void 0===a&&(a=r),v.isFunction(a)?a.call(e):a};var E=0;v.uniqueId=function(e){var t=++E+"";return e?e+t:t},v.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var G=/(.)^/,D={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},A=/\\|'|\r|\n|\u2028|\u2029/g,P=function(e){return"\\"+D[e]};v.template=function(e,t,r){!t&&r&&(t=r),t=v.defaults({},t,v.templateSettings);var a=RegExp([(t.escape||G).source,(t.interpolate||G).source,(t.evaluate||G).source].join("|")+"|$","g"),n=0,i="__p+='";e.replace(a,function(t,r,a,o,s){return i+=e.slice(n,s).replace(A,P),n=s+t.length,r?i+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'":a?i+="'+\n((__t=("+a+"))==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 l=function(e){return o.call(this,e,v)},u=t.variable||"obj";return l.source="function("+u+"){\n"+i+"}",l},v.chain=function(e){var t=v(e);return t._chain=!0,t};var $=function(e,t){return e._chain?v(t).chain():t};v.mixin=function(e){v.each(v.functions(e),function(t){var r=v[t]=e[t];v.prototype[t]=function(){var e=[this._wrapped];return u.apply(e,arguments),$(this,r.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 r=this._wrapped;return t.apply(r,arguments),"shift"!==e&&"splice"!==e||0!==r.length||delete r[0],$(this,r)}}),v.each(["concat","join","slice"],function(e){var t=o[e];v.prototype[e]=function(){return $(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 r=this._circle=this._createCanvas(),a=r.getContext("2d"),n=this._r=e+t;return r.width=r.height=2*n,a.shadowOffsetX=a.shadowOffsetY=2*n,a.shadowBlur=t,a.shadowColor="black",a.beginPath(),a.arc(-n,-n,e,0,2*Math.PI,!0),a.closePath(),a.fill(),this},resize:function(){this._width=this._canvas.width,this._height=this._canvas.height},gradient:function(e){var t=this._createCanvas(),r=t.getContext("2d"),a=r.createLinearGradient(0,0,0,256);t.width=1,t.height=256;for(var n in e)a.addColorStop(+n,e[n]);return r.fillStyle=a,r.fillRect(0,0,1,256),this._grad=r.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 r,a=0,n=this._data.length;athis._max&&(this._max=a[2])}for(this._heat.max(this._max),e=0,t=p.length;e Processing...…'},$(".gs-collapse").on("expanded",function(){var e=jQuery(this);getGeoLayer(e,"gs")}),$(".wms-collapse").on("expanded",function(){var e=jQuery(this);getGeoLayer(e,"wms")}),drawingGroup=new L.FeatureGroup,marker_content_tmpl=document.getElementById("marker-content-tmpl").innerHTML,Mustache.parse(marker_content_tmpl),tmpl.activeLayer=document.getElementById("active-layers-tmpl").innerHTML,Mustache.parse(tmpl.activeLayer),defaultSettings(),mymap=L.map("mapid",{}).setView([51.505,-.09],13);var e=new L.Control.Draw({edit:{featureGroup:drawingGroup}});e.addTo(mymap),drawingGroup.addTo(mymap),drawing_event(),selectedBaseLayers.length>0?layername=selectedBaseLayers[0].name:$.each(baseLayers.mymap,function(e,t){layername=e}),$("#share-modal").on("shown.bs.modal",function(){var e=baseURL;map.settings.https||1==map.settings.https||(e=baseURL.replace("s://","://"));var t='';jQuery("#ds_iframe_code").val(t),jQuery("#ds_share_url").val(e+"map/share/"+map.random_token),jQuery("#ds_json_url").val(e+"map/json/"+map.random_token)}),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.on("baselayerchange",function(e,t){}),mymap.addControl(layerSelector),jQuery("#active-layers-container").on("click",".delete-at-layer",function(){var e=jQuery(this);swal({title:"Are you sure?",text:"This will remove layer from current map.",type:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"Yes, delete it!",cancelButtonText:"No, cancel plx!",closeOnConfirm:!0,closeOnCancel:!0},function(t){if(t){var r=e.parents("ul:first").attr("data-id");deleteLayer(r)}})}),jQuery("#active-layers-container").on("click",".geometry-area-limit",function(){var e=jQuery(this),t=e.parents("ul:first").attr("data-id"),r=document.getElementById("geometry-area-limit-tmpl").innerHTML;Mustache.parse(r);var a=getIndex(selectedLayers,"unique_id",t),n=_.where(selectedLayers,{type:3});jQuery("#geometry-area-limit-form-body").html(Mustache.render(r,{unique_id:t,t:a,f:n})),jQuery("#geometry-area-limit-modal").modal("show"),validateForm(jQuery("#geometry-area-limit-form")),jQuery("#geometry_area_dd").click(function(){var e=jQuery(this).val();"custom"==e?jQuery("#cg_area").show():jQuery("#cg_area").hide()}),jQuery("#geometry-area-limit-submit").click(function(){var e=jQuery("#geometry-area-limit-form");if(e.validate().form()){var t=e.find('[name="unique_id"]').val(),r=getIndex(selectedLayers,"unique_id",t),a=e.find('[name="geometry_area"]').val();if("custom"==a){var n=getIndex(selectedLayers,"unique_id",a);selectedLayers[r].geometry_area=jQuery("#custom_geometry_area").val()}else{var n=getIndex(selectedLayers,"unique_id",a),i=selectedLayers[n].layer.getBounds();selectedLayers[r].bouding_box=i._southWest.lat+","+i._southWest.lng+",",selectedLayers[r].bouding_box+=i._northEast.lat+","+i._northEast.lng,selectedLayers[r].geometry_area=toWKT(selectedLayers[n].layer)}jQuery("#geometry-area-limit-modal").modal("hide")}})}),jQuery("#active-layers-container").on("click",".edit-at-layer",function(){var e=jQuery(this),t=e.parents("ul:first").attr("data-id");editATLayer(t)}),jQuery("#active-layers-container").on("click",".edit-query-at-layer",function(){var e=jQuery(this),t=e.parents("ul:first").attr("data-id");editSQLATLayer(t)}),jQuery("#active-layers-container").on("click",".cache-at-layer",function(){var e=jQuery(this),t=e.parents("ul:first").attr("data-id");editCacheLayer(t)}),jQuery("#active-layers-container").on("click",".style-at-layer",function(e){var t=jQuery(this),r=t.parents("ul:first").attr("data-id");editStyleLayer(r)}),jQuery("#cache-settings-modal").on("click","#cache-settings-save-btn",function(e){e.preventDefault();var t=jQuery("#cache_settings_form");if(t.validate().form()){var r=t.find('[name="unique_id"]').val(),a=getIndex(selectedLayers,"unique_id",r),n=t.find('[name="cache_timer"]').val();selectedLayers[a].cache_timer=n,jQuery("#cahe-settings-modal").modal("hide"),saveMapData("settings",function(){showMsg("success","Cache settings save successfully.")})}}),jQuery("#layer-tmpl").change(function(){var e=jQuery(this).val(),e=document.getElementById(e).innerHTML;Mustache.parse(e),jQuery("#layer-render-tmpl").html(Mustache.render(e))}),jQuery(".layer_chk").change(function(){var e=jQuery(this);WMSLayers(e,!0)}),jQuery("#layer-submit").click(function(){var e=jQuery("#layer-form").serialize();ajaxRequest("/developer/connection/save","post","json",e,function(e){if(200==e.status&&""==e.table_name){var t=document.getElementById("table-tmpl").innerHTML;Mustache.parse(t),jQuery("#tables_div").html(Mustache.render(t,{tables:e.result}))}else 200==e.status&&""!=e.table_name&&(jQuery.each(e.result,function(e,t){featureGroup=new L.FeatureGroup,featureGroup.addTo(mymap),L.geoJson(t,{onEachFeature:function(e,t){}}).addTo(featureGroup),mymap.fitBounds(featureGroup.getBounds())}),jQuery("#layer-modal").modal("hide"))})}),jQuery("#save-your-map").click(function(e){e.preventDefault();var t=jQuery(this);t.button("loading"),saveMapData("map",function(e){t.button("reset"),window.location=baseURL+"/developer/map/edit/"+e.map_id})}),jQuery(".close-right-sidebar").click(function(){jQuery(".sidebar_hide").hasClass("hide")&&(jQuery(".sidebar_hide").toggleClass("hide"),jQuery(".control-sidebar").toggleClass("control-sidebar-open"))}),jQuery("#settings-menu-open").click(function(e){e.stopPropagation(),e.preventDefault();var t=document.getElementById("map-settings-sidebar-tmpl").innerHTML;Mustache.parse(t),jQuery("#map-sidebar-container").html(Mustache.render(t,{}));var r=document.getElementById("map-settings-tmpl").innerHTML;Mustache.parse(r),jQuery("#setting_tab_2").html(Mustache.render(r,{settings:map.settings,bg_layers:bglayersrow})),"undefined"!=typeof map.settings.base_layer&&jQuery("#map_base_layers").val(map.settings.base_layer),jQuery(".sidebar_hide").hasClass("hide")||(jQuery(".sidebar_hide").toggleClass("hide"),jQuery(".control-sidebar").toggleClass("control-sidebar-open")),tinyMCEInit_Popup(".popup-content-textarea");var a=jQuery("#map-settings-form");validateForm(a),map.settings.fullscreen&&1==map.settings.fullscreen&&a.find('[name="fullscreen"]').prop("checked",!0),map.settings.https&&1==map.settings.https&&a.find('[name="https"]').prop("checked",!0),jQuery(".map_settings_chk").bootstrapSwitch({size:"small"})}),jQuery(".control-sidebar").on("click","#save-settings-btn",function(e){if(jQuery("#map-settings-form").validate().form()){e.preventDefault();var t=jQuery(this);t.button("loading"),saveMapData("settings",function(e){t.button("reset"),map.settings=e.settings,showMsg("success","Settings saved successfully.")})}}),jQuery(".control-sidebar").on("click",".save-settings",function(e){e.preventDefault();var t=jQuery(this);jQuery("#style_settings_form").validate().form()&&(t.button("loading"),saveMapData("style",function(e){t.button("reset"),showMsg("success","Style saved successfully.")}))}),jQuery(".control-sidebar").on("click","#save_popup_content",function(){var e=jQuery("#layer-form").serialize();ajaxRequest("/developer/map/save","post","json",e,function(e){200==e.status?(jQuery("#map_id").val(e.map_id),window.location=baseURL+"/developer/map/edit/"+e.map_id):showMsg("error",e.msg)})}),sqlFormEvent(),assingSettings(),manage_custom_layers(),global_filter_event()}),jQuery(document).ready(function(){jQuery("#main-loader").removeClass("hide"),initLayer(),$('input[type="checkbox"].bg_layer_chk').each(function(){jQuery(this).bootstrapSwitch({size:"mini",onSwitchChange:function(e,t){e.preventDefault();var r=jQuery(e.target);baseLayerMap(r,!0)}})}),jQuery(".make-switch").bootstrapSwitch({size:"mini"});var e=getDetailsByAttr(selectedLayers,"type",2);0==e.length&&ajaxLoadSucess()}).ajaxStop(function(){ajaxLoadSucess()});var sqlFormChange=!1,autocomplete,globalLastFileFormat="",global_filtering_tbl="";