3 lines
76 KiB
JavaScript
3 lines
76 KiB
JavaScript
|
function toWKT(e){var t,r,a=[];if(e instanceof L.Polygon||e instanceof L.Polyline){for(var n=e.getLatLngs(),i=0;i<n.length;i++)n[i],a.push(n[i].lng+" "+n[i].lat),0===i&&(t=n[i].lng,r=n[i].lat);if(e instanceof L.Polygon)return"POLYGON(("+a.join(",")+","+t+" "+r+"))";if(e instanceof L.Polyline)return"LINESTRING("+a.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,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
|
||
|
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.unique_id=uniqId("cl"),t.drawing=1,layerDialog(t),renderLayer(t),t.section_id=jQuery("#dd_section_id").val(),selectedLayers.push(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-to
|
||
|
},v.isNaN=function(e){return v.isNumber(e)&&e!==+e},v.isBoolean=function(e){return e===!0||e===!1||"[object Boolean]"===y.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&&d.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=Q,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={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},E=v.invert(O),G=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=G(O),v.unescape=G(E),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 B=0;v.uniqueId=function(e){var t=++B+"";return e?e+t:t},v.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var $=/(.)^/,A={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},F=/\\|'|\r|\n|\u2028|\u2029/g,D=function(e){return"\\"+A[e]};v.template=function(e,t,r){!t&&r&&(t=r),t=v.defaults({},t,v.templateSettings);var a=RegExp([(t.escape||$).source,(t.interpolate||$).source,(t.evaluate||$).source].join("|")+"|$","g"),n=0,i="__p+='";e.replace(a,function(t,r,a,o,s){return i+=e.slice(n,s).replace(F,D),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 P=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),P(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],P(this,r)}}),v.each(["concat","join","slice"],function(e){var t=o[e];v.prototype[e]=function(){return P(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);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()),r=this._map.getSize(),a=this.wmsParams.layer_type,n="application/json";4==a&&(n="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:r.y,width:r.x,layers:this.wmsParams.layers,query_layers:this.wmsParams.layers,info_format:n};return i["1.3.0"===i.version?"i":"x"]=t.x,i["1.3.0"===i.version
|