Y-SLD/assets/playkit/js/style-map.js

2 lines
38 KiB
JavaScript
Raw Normal View History

2024-03-01 11:23:55 +00:00
function ajaxLoadSucess(){jQuery("#main-loader").addClass("hide")}function deleteLayer(e){var t=getLayersIndex(e);3==selectedLayers[t].type&&drawingGroup.removeLayer(selectedLayers[t].layer),jQuery("#at-"+e).remove(),featureGroup[selectedLayers[t].unique_id][selectedLayers[t].name].clearLayers(),selectedLayers.splice(t,1)}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 editStyleLayer(e){var t=getLayersIndex(e);currentIndex=t;var n=jQuery("#style_settings_form");if(1==selectedLayers[t].type){var r=document.getElementById("geoserver-style-modal-tmpl").innerHTML;Mustache.parse(r),n.html(Mustache.render(r)),jQuery("#style-settings-modal").modal("show"),jQuery("#style-settings-modal .btn.btn-success").addClass("hide")}else if(2==selectedLayers[t].type){var a=document.getElementById("sql-layer-style-modal-tmpl").innerHTML;return Mustache.parse(a),jQuery("#map-sidebar-container").html(Mustache.render(a,{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 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 n=e.layer;drawingGroup.addLayer(n),style={};n instanceof L.Marker?(style.marker=new Object,style.marker.icon="",style.marker.color="",style.marker.image=baseURL+"/assets/plugins/leaflet/images/marker-icon.png",t.marker=!0,t.polygon=!1):(n instanceof L.MultiPolygon||n instanceof L.Polyline||n instanceof L.Rectangle||n 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,n.setStyle(style.polygon),t.marker=!1,t.polygon=!0),t.layer=n,t.style=style,t.type=3,t.name=t.lt,t.location="",t.pc="",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 n=$(this);if("block"==n.parent().css("display")){var r=n.text(),a="";a=/cancel/i.test(r)?"remove":/save/i.test(r)?"save":"trash",Actions='<a href="#" onClick="return tipButton
if(l=c.length,g.keys(t).length!==l)return!1;for(;l--;)if(s=c[l],!g.has(t,s)||!C(e[s],t[s],n,r))return!1}return n.pop(),r.pop(),!0};g.isEqual=function(e,t){return C(e,t)},g.isEmpty=function(e){return null==e||(Q(e)&&(g.isArray(e)||g.isString(e)||g.isArguments(e))?0===e.length:0===g.keys(e).length)},g.isElement=function(e){return!(!e||1!==e.nodeType)},g.isArray=p||function(e){return"[object Array]"===y.call(e)},g.isObject=function(e){var t=typeof e;return"function"===t||"object"===t&&!!e},g.each(["Arguments","Function","String","Number","Date","RegExp","Error"],function(e){g["is"+e]=function(t){return y.call(t)==="[object "+e+"]"}}),g.isArguments(arguments)||(g.isArguments=function(e){return g.has(e,"callee")}),"function"!=typeof/./&&"object"!=typeof Int8Array&&(g.isFunction=function(e){return"function"==typeof e||!1}),g.isFinite=function(e){return isFinite(e)&&!isNaN(parseFloat(e))},g.isNaN=function(e){return g.isNumber(e)&&e!==+e},g.isBoolean=function(e){return e===!0||e===!1||"[object Boolean]"===y.call(e)},g.isNull=function(e){return null===e},g.isUndefined=function(e){return void 0===e},g.has=function(e,t){return null!=e&&f.call(e,t)},g.noConflict=function(){return a._=i,this},g.identity=function(e){return e},g.constant=function(e){return function(){return e}},g.noop=function(){},g.property=_,g.propertyOf=function(e){return null==e?function(){}:function(t){return e[t]}},g.matcher=g.matches=function(e){return e=g.extendOwn({},e),function(t){return g.isMatch(t,e)}},g.times=function(e,t,n){var r=Array(Math.max(0,e));t=L(t,n,1);for(var a=0;e>a;a++)r[a]=t(a);return r},g.random=function(e,t){return null==t&&(t=e,e=0),e+Math.floor(Math.random()*(t-e+1))},g.now=Date.now||function(){return(new Date).getTime()};var O={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},E=g.invert(O),q=function(e){var t=function(t){return e[t]},n="(?:"+g.keys(e).join("|")+")",r=RegExp(n),a=RegExp(n,"g");return function(e){return e=null==e?"":""+e,r.test(e)?e.replace(a,t):e}};g.escape=q(O),g.unescape=q(E),g.result=function(e,t,n){var r=null==e?void 0:e[t];return void 0===r&&(r=n),g.isFunction(r)?r.call(e):r};var B=0;g.uniqueId=function(e){var t=++B+"";return e?e+t:t},g.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var $=/(.)^/,F={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\u2028|\u2029/g,G=function(e){return"\\"+F[e]};g.template=function(e,t,n){!t&&n&&(t=n),t=g.defaults({},t,g.templateSettings);var r=RegExp([(t.escape||$).source,(t.interpolate||$).source,(t.evaluate||$).source].join("|")+"|$","g"),a=0,i="__p+='";e.replace(r,function(t,n,r,o,u){return i+=e.slice(a,u).replace(D,G),a=u+t.length,n?i+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'":r?i+="'+\n((__t=("+r+"))==null?'':__t)+\n'":o&&(i+="';\n"+o+"\n__p+='"),t}),i+="';\n",t.variable||(i="with(obj||{}){\n"+i+"}\n"),i="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+i+"return __p;\n";try{var o=new Function(t.variable||"obj","_",i)}catch(u){throw u.source=i,u}var l=function(e){return o.call(this,e,g)},s=t.variable||"obj";return l.source="function("+s+"){\n"+i+"}",l},g.chain=function(e){var t=g(e);return t._chain=!0,t};var R=function(e,t){return e._chain?g(t).chain():t};g.mixin=function(e){g.each(g.functions(e),function(t){var n=g[t]=e[t];g.prototype[t]=function(){var e=[this._wrapped];return s.apply(e,arguments),R(this,n.apply(g,e))}})},g.mixin(g),g.each(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=o[e];g.prototype[e]=function(){var n=this._wrapped;return t.apply(n,arguments),"shift"!==e&&"splice"!==e||0!==n.length||delete n[0],R(this,n)}}),g.each(["concat","join","slice"],function(e){var t=o[e];g.prototype[e]=function(){return R(this,t.apply(this._wrapped,arguments))}}),g.prototype.value=function(){return this._wrapped},g.prototype.valueOf=g.prototype.toJSON=g.prototype.value,g.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],functi