--- a/src/pyams_gis/resources/js/pyams_gis.min.js Mon Feb 01 13:27:46 2021 +0100
+++ b/src/pyams_gis/resources/js/pyams_gis.min.js Mon Feb 01 13:28:18 2021 +0100
@@ -1,1 +1,1 @@
-!function(e,a){"use strict";var t,i=a.MyAMS,n={RPC_ENDPOINT:"/api/gis/json",WGS_SRID:4326,_layersControlAddItem:function(a){var i,n,r=e("<div></div>").addClass("inline-group"),o=e("<label></label>").addClass(a.overlay?"checkbox":"radio"),l=e("<i></i>"),s=this._map.hasLayer(a.layer);a.overlay?((i=document.createElement("input")).type="checkbox",i.className="leaflet-control-layers-selector",i.defaultChecked=s):i=this._createRadioElement("leaflet-base-layers",s),i.layerId=t.stamp(a.layer),e(i).addClass(a.overlay?"checkbox":"radio"),t.DomEvent.on(i,"click",this._onInputClick,this),n=e("<span></span>").text(" "+a.name),o.append(i),o.append(l),o.append(n),r.append(o);var d=a.overlay?this._overlaysList:this._baseLayersList;return e(d).append(r),r},init:function(r,o,l){var s=r;i.ajax.check([a.L],["/--static--/pyams_gis/js/leaflet-1.7.1"+i.devext+".js"],(function(r){var d=[];r&&((t=a.L).Control.Layers.prototype._addItem=n._layersControlAddItem,d.push(i.getScript("/--static--/pyams_gis/js/leaflet-gesture-handling-1.2.1"+i.devext+".js")),i.getCSS("/--static--/pyams_gis/css/leaflet-1.7.1"+i.devext+".css","leaflet"),i.getCSS("/--static--/pyams_gis/css/leaflet-gesture-handling-1.2.1"+i.devext+".css","leaflet-gesture-handling")),e.when.apply(e,d).then((function(){function r(r){var c={preferCanvas:d.mapLeafletPreferCanvas||!1,attributionControl:void 0===d.mapLeafletAttributionControl?r.attributionControl:d.mapLeafletAttributionControl,zoomControl:void 0===d.mapLeafletZoomControl?r.zoomControl:d.mapLeafletZoomControl,crs:d.mapLeafletCrs||i.getObject(r.crs)||a.L.CRS.EPSG3857,center:d.mapLeafletCenter||r.center,zoom:d.mapLeafletZoom||r.zoom,gestureHandling:!0};c=e.extend({},c,o),s.trigger("map.init",[s,c,r]);var p=t.map(s.attr("id"),c),u=[];if(r.layers)for(var m=0;m<r.layers.length;m++){var g=r.layers[m];s.trigger("map.layer.init",[s,g]),u.push(n.getLayer(s,p,g))}else u.push(t.tileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{maxZoom:19,id:"osm",attribution:'© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'}));e.when.apply(e,u).then((function(...e){for(var a=0;a<e.length;a++)e[a].addTo(p);r.zoomControl&&!0!==d.mapLeafletHideZoomControl&&t.control.scale().addTo(p),r.center?p.setView(new t.LatLng(r.center.lat,r.center.lon),r.zoom||13):r.bounds&&p.fitBounds(r.bounds),s.data("leafmap",p),s.data("leafmap.config",r),s.trigger("map.finishing",[s,p,r]),l&&l(p,r),s.trigger("map.finished",[s,p,r])}))}var d=s.data(),c=d.mapConfiguration;c?r(c):i.ajax.post(d.mapConfigurationUrl||"get-map-configuration.json",{},(function(e){r(e)}))}))}))},getLayer:function(a,t,n){var r=i.getObject(n.factory);if(void 0!==r){delete n.factory;var o=[];if(n.dependsOn){for(var l in n.dependsOn)n.dependsOn.hasOwnProperty(l)&&void 0===i.getObject(l)&&o.push(i.getScript(n.dependsOn[l]));delete n.dependsOn}return o.length>0&&e.when.apply(e,o),r(a,t,n)}},factory:{GeoJSON:function(a,i,n){var r=n.url;delete n.url;var o=t.geoJSON(null,n);return a.on("map.finished",(function(a,t,i,l){e.get(r,(function(e){o.addData(e.geometry,{style:n.style}),l.fitLayer===n.name&&i.fitBounds(o.getBounds())}))})),o},TileLayer:function(e,a,i){var n=i.url;return delete i.url,t.tileLayer(n,i)},WMS:function(e,a,i){var n=i.url;return delete i.url,t.tileLayer.wms(n,i)},Geoportal:{WMS:function(e,a,n){return i.getCSS("/--static--/pyams_gis/css/leaflet-gp-3.0.2"+i.devext+".css","geoportal"),t.geoportalLayer.WMS(n)}},ESRI:{Feature:function(e,a,i){return t.esri.featureLayer(i)}},Google:function(a,n,r){var o=r.apiKey;if(delete r.apiKey,void 0===i.getObject("window.google.maps")){var l=i.getScript("https://maps.googleapis.com/maps/api/js?key="+o);e.when.apply(e,[l])}return t.gridLayer.googleMutant(r)}},callJSON:function(a,t,r){i.ajax.check(e.jsonRPC,i.baseURL+"ext/jquery-jsonrpc"+i.devext+".js",(function(){e.jsonRPC.withOptions({endPoint:n.RPC_ENDPOINT,cache:!1},(function(){e.jsonRPC.request(a,{id:(new Date).getTime(),params:t,success:r,error:i.error.show})}))}))},markers:{init:function(e,a,n){i.ajax.check([t.MarkerClusterGroup],["/--static--/pyams_gis/js/leaflet-markercluster-1.4.1"+i.devext+".js"],(function(r){r&&(i.getCSS("/--static--/pyams_gis/css/leaflet-markercluster-1.4.1"+i.devext+".css","leaflet-markercluster"),i.getCSS("/--static--/pyams_gis/css/leaflet-markercluster-default-1.4.1"+i.devext+".css","leaflet-markercluster-default"));for(var o=function(e){window.location.href=this.options.clickURL},l=function(e){this.openTooltip()},s=function(e){this.closeTooltip()},d=t.icon({iconUrl:a.icon.url,iconSize:a.icon.size,iconAnchor:a.icon.anchor}),c=new t.MarkerClusterGroup({iconCreateFunction:function(e){return t.divIcon({html:e.getChildCount(),className:a.clusterClass||"map-cluster",iconSize:null})}}),p={},u=0;u<a.markers.length;u++){var m,g=a.markers[u],f=new t.LatLng(g.point.y,g.point.x),v=new t.Marker(f,{icon:d,clickURL:g.href,markerId:g.id,alt:g.id});if(g.href&&v.addEventListener("click",o),p[g.id]=v,m=g.img?'<div><div class="marker__label p-2"> '+g.label+'</div><div class="text-center"><img src="'+g.img.src+'" width="'+g.img.w+'" height="'+g.img.h+'" alt="" /></div></div>':g.label){var y=a.tooltipClass||"map-tooltip";g.img&&(y+=" p-0"),p[g.id].bindTooltip(m,{direction:"top",offset:[0,-d.options.iconSize[1]],opacity:1,className:y}),p[g.id].addEventListener("mouseover",l),p[g.id].addEventListener("mouseout",s)}c.addLayer(p[g.id])}e.addLayer(c),"auto"===n.adjust&&(e.fitBounds(c.getBounds()),1===a.markers.length&&e.setZoom(n.zoom))}))}},position:{init:function(){var a=e(".map",e(this));void 0===a.data("leafmap")&&(a.css("height",e(window).height()-200),n.init(a,{},(function(i,r){var o=a.data(),l=t.icon({iconUrl:"/--static--/pyams_gis/img/marker-icon.png",iconSize:[25,41],iconAnchor:[12,39]}),s=t.marker();s.setIcon(l);var d=o.mapLeafletFieldname,c=e('input[name="'+d+'.widgets.longitude"]'),p=e('input[name="'+d+'.widgets.latitude"]');if(c.val()&&p.val()){var u=e('select[name="'+d+'.widgets.projection:list"]'),m={point:{longitude:parseFloat(c.val()),latitude:parseFloat(p.val())},from_srid:u.val()||n.WGS_SRID,to_srid:n.WGS_SRID};n.callJSON("transformPoint",m,(function(e){if(!e.error){var a=e.result.point;s.setLatLng({lon:a.longitude,lat:a.latitude}),s.addTo(i),i.setView(s.getLatLng(),r.zoom||13)}}))}else s.setLatLng([-90,0]),s.addTo(i);a.data("marker",s),i.on("click",n.position.onClick)})))},onClick:function(a){var t=a.target.getContainer(),i=e(t).data(),r=i.marker,o=a.latlng;r.setLatLng(o);var l=i.mapLeafletFieldname,s=e('select[name="'+l+'.widgets.projection:list"]'),d={point:{longitude:o.lng,latitude:o.lat},from_srid:n.WGS_SRID,to_srid:s.val()};n.callJSON("transformPoint",d,(function(a){if(!a.error){var i=a.result.point;e('input[name="'+l+'.widgets.longitude"]').val(i.longitude),e('input[name="'+l+'.widgets.latitude"]').val(i.latitude),e(t).trigger("marker.changed",[t,i])}}))},changedCoordinate:function(){var a=e(this),t=e(".map",a.parents("fieldset:first"));if(t.data("marker")){var i=t.data("map-leaflet-fieldname"),r=e('input[name="'+i+'.widgets.longitude"]'),o=e('input[name="'+i+'.widgets.latitude"]');if(r.val()&&o.val()){var l=e('select[name="'+i+'.widgets.projection:list"]'),s={point:{longitude:parseFloat(r.val()),latitude:parseFloat(o.val())},from_srid:l.val(),to_srid:n.WGS_SRID};n.callJSON("transformPoint",s,(function(e){if(!e.error){var a=e.result.point;t.data("marker").setLatLng({lon:a.longitude,lat:a.latitude})}}))}}},changedProjection:function(a){var t=e(this),i=e(".map",t.parents("fieldset:first")).data("map-leaflet-fieldname"),r=e('input[name="'+i+'.widgets.longitude"]'),o=e('input[name="'+i+'.widgets.latitude"]');if(a.removed){var l=a.removed.id,s=a.added.id;if(l!==s&&r.val()&&o.val()){var d={point:{longitude:parseFloat(r.val()),latitude:parseFloat(o.val())},from_srid:l,to_srid:s};n.callJSON("transformPoint",d,(function(e){if(!e.error){var a=e.result.point;r.val(a.longitude),o.val(a.latitude)}}))}}else n.position.changedCoordinate.apply(r)},clear:function(a){var t=e(this).parents("fieldset:first");e("input",t).val(null);var i=e(".map",t),n=i.data("marker");if(n){n.setLatLng([-90,0]);var r=i.data("leafmap"),o=i.data("leafmap.config");if(o.bounds)r.fitBounds(o.bounds);else{var l=i.data();r.setView(l.mapLeafletCenter||o.center,o.zoom||13)}}i.trigger("marker.cleared.position",[i])},moveMarkerTo:function(a,t,i){var r=a.data("map-leaflet-fieldname");e('input[name="'+r+'.widgets.longitude"]').val(t.lon),e('input[name="'+r+'.widgets.latitude"]').val(t.lat);var o={point:{longitude:t.lon,latitude:t.lat},from_srid:i,to_srid:4326};n.callJSON("transformPoint",o,(function(e){if(!e.error){var i=e.result.point;a.data("marker").setLatLng({lon:i.longitude,lat:i.latitude}),a.data("leafmap").setView(t)}}))}},area:{init:function(){var a=e(".map",e(this));void 0===a.data("leafmap")&&(a.css("height",e(window).height()-200),n.init(a,{},(function(r){t.Draw=t.Draw||{},t.Edit=t.Edit||{},i.ajax.check([t.Draw,t.Draw.Event,t.Map.TouchExtend,t.Edit.SimpleShape],["/--static--/pyams_gis/js/Draw/Leaflet.draw"+i.devext+".js","/--static--/pyams_gis/js/Draw/Leaflet.Draw.Event"+i.devext+".js","/--static--/pyams_gis/js/Draw/ext/TouchEvents"+i.devext+".js","/--static--/pyams_gis/js/Draw/edit/handler/Edit.SimpleShape"+i.devext+".js"],(function(){i.ajax.check(t.Edit.Rectangle,"/--static--/pyams_gis/js/Draw/edit/handler/Edit.Rectangle"+i.devext+".js",(function(){function i(e,i){var o=new t.FeatureGroup;s=t.rectangle([e,i]),o.addLayer(s),r.addLayer(o),r.fitBounds(s.getBounds()),s.editing.enable(),a.data("area",s),r.on(t.Draw.Event.EDITMOVE,n.area.changedArea),r.on(t.Draw.Event.EDITRESIZE,n.area.changedArea),r.on(t.Draw.Event.EDITVERTEX,n.area.changedArea)}var o,l,s,d=a.data().mapLeafletFieldname,c=e('input[name="'+d+'.widgets.x1"]'),p=e('input[name="'+d+'.widgets.y1"]'),u=e('input[name="'+d+'.widgets.x2"]'),m=e('input[name="'+d+'.widgets.y2"]');if(c.val()&&p.val()&&u.val()&&m.val()){var g=e('select[name="'+d+'.widgets.projection:list"]'),f={area:{x1:parseFloat(c.val()),y1:parseFloat(p.val()),x2:parseFloat(u.val()),y2:parseFloat(m.val())},from_srid:g.val(),to_srid:n.WGS_SRID};n.callJSON("transformArea",f,(function(e){if(!e.error){var a=e.result.area;o=t.latLng({lon:a.x1,lat:a.y1}),l=t.latLng({lon:a.x2,lat:a.y2}),i(o,l)}}))}else{var v=a.data("leafmap.config");v.bounds?(o=t.latLng(v.bounds[0]),l=t.latLng(v.bounds[1])):(o=t.latLng({lon:-168,lat:-56.37}),l=t.latLng({lon:191.25,lat:83.72})),i(o,l)}}))}))})))},last_event:null,changedArea:function(a){n.area.last_event=a,setTimeout((function(){if(a===n.area.last_event){var t=a.target.getContainer(),i=e(t).data(),r=i.area.getBounds(),o=i.mapLeafletFieldname,l=e('select[name="'+o+'.widgets.projection:list"]').val(),s={area:{x1:r.getWest(),y1:r.getSouth(),x2:r.getEast(),y2:r.getNorth()},from_srid:n.WGS_SRID,to_srid:l};n.callJSON("transformArea",s,(function(a){if(!a.error){var t=a.result.area;e('input[name="'+o+'.widgets.x1"]').val(t.x1),e('input[name="'+o+'.widgets.y1"]').val(t.y1),e('input[name="'+o+'.widgets.x2"]').val(t.x2),e('input[name="'+o+'.widgets.y2"]').val(t.y2)}}))}}),100)},changedCoordinate:function(){var a=e(this),i=e(".map",a.parents("fieldset:first"));if(i.data("area")){var r=i.data("map-leaflet-fieldname"),o=e('input[name="'+r+'.widgets.x1"]'),l=e('input[name="'+r+'.widgets.y1"]'),s=e('input[name="'+r+'.widgets.x2"]'),d=e('input[name="'+r+'.widgets.y2"]');if(o.val()&&l.val()&&s.val()&&d.val()){var c=e('select[name="'+r+'.widgets.projection:list"]'),p={area:{x1:parseFloat(o.val()),y1:parseFloat(l.val()),x2:parseFloat(s.val()),y2:parseFloat(d.val())},from_srid:c.val(),to_srid:4326};n.callJSON("transformArea",p,(function(e){if(!e.error){var a=e.result.area,n=i.data("area");n.editing.disable(),n.setBounds([t.latLng({lon:a.x1,lat:a.y1}),t.latLng({lon:a.x2,lat:a.y2})]),n.editing.enable()}}))}}},changedProjection:function(a){var t=e(this),i=e(".map",t.parents("fieldset:first")).data("map-leaflet-fieldname"),r=e('input[name="'+i+'.widgets.x1"]'),o=e('input[name="'+i+'.widgets.y1"]'),l=e('input[name="'+i+'.widgets.x2"]'),s=e('input[name="'+i+'.widgets.y2"]');if(a.removed){var d=a.removed.id,c=a.added.id;if(d!==c&&r.val()&&o.val()&&l.val()&&s.val()){var p={area:{x1:parseFloat(r.val()),y1:parseFloat(o.val()),x2:parseFloat(l.val()),y2:parseFloat(s.val())},from_srid:d,to_srid:c};n.callJSON("transformArea",p,(function(e){if(!e.error){var a=e.result.area;r.val(a.x1),o.val(a.y1),l.val(a.x2),s.val(a.y2)}}))}}else n.area.changedCoordinate.apply(r)},clear:function(a){var t=e(this).parents("fieldset:first");e("input",t).val(null);var i=e(".map",t);i.trigger("marker.cleared.area",[i])}}};a.PyAMS_GIS=n}(jQuery,this);
+!function(e,a){"use strict";var t,i=a.MyAMS,n={RPC_ENDPOINT:"/api/gis/json",WGS_SRID:4326,_layersControlAddItem:function(a){var i,n,r=e("<div></div>").addClass("inline-group"),o=e("<label></label>").addClass(a.overlay?"checkbox":"radio"),l=e("<i></i>"),s=this._map.hasLayer(a.layer);a.overlay?((i=document.createElement("input")).type="checkbox",i.className="leaflet-control-layers-selector",i.defaultChecked=s):i=this._createRadioElement("leaflet-base-layers",s),i.layerId=t.stamp(a.layer),e(i).addClass(a.overlay?"checkbox":"radio"),t.DomEvent.on(i,"click",this._onInputClick,this),n=e("<span></span>").text(" "+a.name),o.append(i),o.append(l),o.append(n),r.append(o);var d=a.overlay?this._overlaysList:this._baseLayersList;return e(d).append(r),r},init:function(r,o,l,s){i.ajax.check([a.L],["/--static--/pyams_gis/js/leaflet-1.7.1"+i.devext+".js"],(function(d){var c=[];d&&((t=a.L).Control.Layers.prototype._addItem=n._layersControlAddItem,c.push(i.getScript("/--static--/pyams_gis/js/leaflet-gesture-handling-1.2.1"+i.devext+".js")),i.getCSS("/--static--/pyams_gis/css/leaflet-1.7.1"+i.devext+".css","leaflet"),i.getCSS("/--static--/pyams_gis/css/leaflet-gesture-handling-1.2.1"+i.devext+".css","leaflet-gesture-handling")),e.when.apply(e,c).then((function(){function d(r,s){var d=r.data(),c={preferCanvas:d.mapLeafletPreferCanvas||!1,attributionControl:void 0===d.mapLeafletAttributionControl?s.attributionControl:d.mapLeafletAttributionControl,zoomControl:void 0===d.mapLeafletZoomControl?s.zoomControl:d.mapLeafletZoomControl,crs:d.mapLeafletCrs||i.getObject(s.crs)||a.L.CRS.EPSG3857,center:d.mapLeafletCenter||s.center,zoom:d.mapLeafletZoom||s.zoom,gestureHandling:void 0===d.mapLeafletWheelZoom?!s.scrollWheelZoom:d.mapLeafletWheelZoom,keyboard:void 0===d.mapLeafletKeyboard?s.keyboard&&!t.Browser.mobile:d.amsLeafletKeyboard};c=e.extend({},c,o),r.trigger("map.init",[r,c,s]);var p=t.map(r.attr("id"),c),u=[];if(s.layers)for(var m=0;m<s.layers.length;m++){var f=s.layers[m];r.trigger("map.layer.init",[r,f]),u.push(n.getLayer(r,p,f))}else u.push(t.tileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{maxZoom:19,id:"osm",attribution:'© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'}));e.when.apply(e,u).then((function(...e){for(var a=0;a<e.length;a++)e[a].addTo(p);s.zoomControl&&!0!==d.mapLeafletHideZoomControl&&t.control.scale().addTo(p),s.center?p.setView(new t.LatLng(s.center.lat,s.center.lon),s.zoom||13):s.bounds&&p.fitBounds(s.bounds),r.data("leafmap",p),r.data("leafmap.config",s),r.trigger("map.finishing",[r,p,s]),l&&l(p,s),r.trigger("map.finished",[r,p,s])}))}var c=e.map(r,(function(a){return new Promise((function(t,n){var r=e(a),o=r.data(),l=o.mapConfiguration;l?(d(r,l),t()):i.ajax.post(o.mapConfigurationUrl||"get-map-configuration.json",{},(function(e){d(r,e),t()}))}))}));s&&e.when.apply(e,c).then(s)}))}))},getLayer:function(a,t,n){var r=i.getObject(n.factory);if(void 0!==r){delete n.factory;var o=[];if(n.dependsOn){for(var l in n.dependsOn)n.dependsOn.hasOwnProperty(l)&&void 0===i.getObject(l)&&o.push(i.getScript(n.dependsOn[l]));delete n.dependsOn}return o.length>0&&e.when.apply(e,o),r(a,t,n)}},factory:{GeoJSON:function(a,i,n){var r=n.url;delete n.url;var o=t.geoJSON(null,n);return a.on("map.finished",(function(a,t,i,l){e.get(r,(function(e){o.addData(e.geometry,{style:n.style}),l.fitLayer===n.name&&i.fitBounds(o.getBounds())}))})),o},TileLayer:function(e,a,i){var n=i.url;return delete i.url,t.tileLayer(n,i)},WMS:function(e,a,i){var n=i.url;return delete i.url,t.tileLayer.wms(n,i)},Geoportal:{WMS:function(e,a,n){return i.getCSS("/--static--/pyams_gis/css/leaflet-gp-3.0.2"+i.devext+".css","geoportal"),t.geoportalLayer.WMS(n)}},ESRI:{Feature:function(e,a,i){return t.esri.featureLayer(i)}},Google:function(a,n,r){var o=r.apiKey;if(delete r.apiKey,void 0===i.getObject("window.google.maps")){var l=i.getScript("https://maps.googleapis.com/maps/api/js?key="+o);e.when.apply(e,[l])}return t.gridLayer.googleMutant(r)}},callJSON:function(a,t,r){i.ajax.check(e.jsonRPC,i.baseURL+"ext/jquery-jsonrpc"+i.devext+".js",(function(){e.jsonRPC.withOptions({endPoint:n.RPC_ENDPOINT,cache:!1},(function(){e.jsonRPC.request(a,{id:(new Date).getTime(),params:t,success:r,error:i.error.show})}))}))},markers:{init:function(a){i.ajax.check([t.MarkerClusterGroup],["/--static--/pyams_gis/js/leaflet-markercluster-1.4.1"+i.devext+".js"],(function(n){n&&(i.getCSS("/--static--/pyams_gis/css/leaflet-markercluster-1.4.1"+i.devext+".css","leaflet-markercluster"),i.getCSS("/--static--/pyams_gis/css/leaflet-markercluster-default-1.4.1"+i.devext+".css","leaflet-markercluster-default"));var r=function(e){window.location.href=this.options.clickURL},o=function(e){this.openTooltip()},l=function(e){this.closeTooltip()};a.each((function(a,i){for(var n=e(i),s=n.data(),d=n.data("leafmap"),c=n.data("leafmap.config"),p=s.mapMarkers,u=t.icon({iconUrl:p.icon.url,iconSize:p.icon.size,iconAnchor:p.icon.anchor}),m=new t.MarkerClusterGroup({iconCreateFunction:function(e){return t.divIcon({html:e.getChildCount(),className:p.clusterClass||"map-cluster",iconSize:null})}}),f={},g=0;g<p.markers.length;g++){var v,h=p.markers[g],y=new t.LatLng(h.point.y,h.point.x),w=new t.Marker(y,{icon:u,clickURL:h.href,markerId:h.id,alt:h.id});if(h.href&&w.addEventListener("click",r),f[h.id]=w,v=h.img?'<div><div class="marker__label p-2"> '+h.label+'</div><div class="text-center"><img src="'+h.img.src+'" width="'+h.img.w+'" height="'+h.img.h+'" alt="" /></div></div>':h.label){var L=p.tooltipClass||"map-tooltip";h.img&&(L+=" p-0"),f[h.id].bindTooltip(v,{direction:"top",offset:[0,-u.options.iconSize[1]],opacity:1,className:L}),f[h.id].addEventListener("mouseover",o),f[h.id].addEventListener("mouseout",l)}m.addLayer(f[h.id])}d.addLayer(m),"auto"===c.adjust&&(d.fitBounds(m.getBounds()),1===p.markers.length&&d.setZoom(c.zoom))}))}))}},position:{init:function(){var a=e(".map",e(this));void 0===a.data("leafmap")&&(a.css("height",e(window).height()-200),n.init(a,{},(function(i,r){var o=a.data(),l=t.icon({iconUrl:"/--static--/pyams_gis/img/marker-icon.png",iconSize:[25,41],iconAnchor:[12,39]}),s=t.marker();s.setIcon(l);var d=o.mapLeafletFieldname,c=e('input[name="'+d+'.widgets.longitude"]'),p=e('input[name="'+d+'.widgets.latitude"]');if(c.val()&&p.val()){var u=e('select[name="'+d+'.widgets.projection:list"]'),m={point:{longitude:parseFloat(c.val()),latitude:parseFloat(p.val())},from_srid:u.val()||n.WGS_SRID,to_srid:n.WGS_SRID};n.callJSON("transformPoint",m,(function(e){if(!e.error){var a=e.result.point;s.setLatLng({lon:a.longitude,lat:a.latitude}),s.addTo(i),i.setView(s.getLatLng(),r.zoom||13)}}))}else s.setLatLng([-90,0]),s.addTo(i);a.data("marker",s),i.on("click",n.position.onClick)})))},onClick:function(a){var t=a.target.getContainer(),i=e(t).data(),r=i.marker,o=a.latlng;r.setLatLng(o);var l=i.mapLeafletFieldname,s=e('select[name="'+l+'.widgets.projection:list"]'),d={point:{longitude:o.lng,latitude:o.lat},from_srid:n.WGS_SRID,to_srid:s.val()};n.callJSON("transformPoint",d,(function(a){if(!a.error){var i=a.result.point;e('input[name="'+l+'.widgets.longitude"]').val(i.longitude),e('input[name="'+l+'.widgets.latitude"]').val(i.latitude),e(t).trigger("marker.changed",[t,i])}}))},changedCoordinate:function(){var a=e(this),t=e(".map",a.parents("fieldset:first"));if(t.data("marker")){var i=t.data("map-leaflet-fieldname"),r=e('input[name="'+i+'.widgets.longitude"]'),o=e('input[name="'+i+'.widgets.latitude"]');if(r.val()&&o.val()){var l=e('select[name="'+i+'.widgets.projection:list"]'),s={point:{longitude:parseFloat(r.val()),latitude:parseFloat(o.val())},from_srid:l.val(),to_srid:n.WGS_SRID};n.callJSON("transformPoint",s,(function(e){if(!e.error){var a=e.result.point;t.data("marker").setLatLng({lon:a.longitude,lat:a.latitude})}}))}}},changedProjection:function(a){var t=e(this),i=e(".map",t.parents("fieldset:first")).data("map-leaflet-fieldname"),r=e('input[name="'+i+'.widgets.longitude"]'),o=e('input[name="'+i+'.widgets.latitude"]');if(a.removed){var l=a.removed.id,s=a.added.id;if(l!==s&&r.val()&&o.val()){var d={point:{longitude:parseFloat(r.val()),latitude:parseFloat(o.val())},from_srid:l,to_srid:s};n.callJSON("transformPoint",d,(function(e){if(!e.error){var a=e.result.point;r.val(a.longitude),o.val(a.latitude)}}))}}else n.position.changedCoordinate.apply(r)},clear:function(a){var t=e(this).parents("fieldset:first");e("input",t).val(null);var i=e(".map",t),n=i.data("marker");if(n){n.setLatLng([-90,0]);var r=i.data("leafmap"),o=i.data("leafmap.config");if(o.bounds)r.fitBounds(o.bounds);else{var l=i.data();r.setView(l.mapLeafletCenter||o.center,o.zoom||13)}}i.trigger("marker.cleared.position",[i])},moveMarkerTo:function(a,t,i){var r=a.data("map-leaflet-fieldname");e('input[name="'+r+'.widgets.longitude"]').val(t.lon),e('input[name="'+r+'.widgets.latitude"]').val(t.lat);var o={point:{longitude:t.lon,latitude:t.lat},from_srid:i,to_srid:4326};n.callJSON("transformPoint",o,(function(e){if(!e.error){var i=e.result.point;a.data("marker").setLatLng({lon:i.longitude,lat:i.latitude}),a.data("leafmap").setView(t)}}))}},area:{init:function(){var a=e(".map",e(this));void 0===a.data("leafmap")&&(a.css("height",e(window).height()-200),n.init(a,{},(function(r){t.Draw=t.Draw||{},t.Edit=t.Edit||{},i.ajax.check([t.Draw,t.Draw.Event,t.Map.TouchExtend,t.Edit.SimpleShape],["/--static--/pyams_gis/js/Draw/Leaflet.draw"+i.devext+".js","/--static--/pyams_gis/js/Draw/Leaflet.Draw.Event"+i.devext+".js","/--static--/pyams_gis/js/Draw/ext/TouchEvents"+i.devext+".js","/--static--/pyams_gis/js/Draw/edit/handler/Edit.SimpleShape"+i.devext+".js"],(function(){i.ajax.check(t.Edit.Rectangle,"/--static--/pyams_gis/js/Draw/edit/handler/Edit.Rectangle"+i.devext+".js",(function(){function i(e,i){var o=new t.FeatureGroup;s=t.rectangle([e,i]),o.addLayer(s),r.addLayer(o),r.fitBounds(s.getBounds()),s.editing.enable(),a.data("area",s),r.on(t.Draw.Event.EDITMOVE,n.area.changedArea),r.on(t.Draw.Event.EDITRESIZE,n.area.changedArea),r.on(t.Draw.Event.EDITVERTEX,n.area.changedArea)}var o,l,s,d=a.data().mapLeafletFieldname,c=e('input[name="'+d+'.widgets.x1"]'),p=e('input[name="'+d+'.widgets.y1"]'),u=e('input[name="'+d+'.widgets.x2"]'),m=e('input[name="'+d+'.widgets.y2"]');if(c.val()&&p.val()&&u.val()&&m.val()){var f=e('select[name="'+d+'.widgets.projection:list"]'),g={area:{x1:parseFloat(c.val()),y1:parseFloat(p.val()),x2:parseFloat(u.val()),y2:parseFloat(m.val())},from_srid:f.val(),to_srid:n.WGS_SRID};n.callJSON("transformArea",g,(function(e){if(!e.error){var a=e.result.area;o=t.latLng({lon:a.x1,lat:a.y1}),l=t.latLng({lon:a.x2,lat:a.y2}),i(o,l)}}))}else{var v=a.data("leafmap.config");v.bounds?(o=t.latLng(v.bounds[0]),l=t.latLng(v.bounds[1])):(o=t.latLng({lon:-168,lat:-56.37}),l=t.latLng({lon:191.25,lat:83.72})),i(o,l)}}))}))})))},last_event:null,changedArea:function(a){n.area.last_event=a,setTimeout((function(){if(a===n.area.last_event){var t=a.target.getContainer(),i=e(t).data(),r=i.area.getBounds(),o=i.mapLeafletFieldname,l=e('select[name="'+o+'.widgets.projection:list"]').val(),s={area:{x1:r.getWest(),y1:r.getSouth(),x2:r.getEast(),y2:r.getNorth()},from_srid:n.WGS_SRID,to_srid:l};n.callJSON("transformArea",s,(function(a){if(!a.error){var t=a.result.area;e('input[name="'+o+'.widgets.x1"]').val(t.x1),e('input[name="'+o+'.widgets.y1"]').val(t.y1),e('input[name="'+o+'.widgets.x2"]').val(t.x2),e('input[name="'+o+'.widgets.y2"]').val(t.y2)}}))}}),100)},changedCoordinate:function(){var a=e(this),i=e(".map",a.parents("fieldset:first"));if(i.data("area")){var r=i.data("map-leaflet-fieldname"),o=e('input[name="'+r+'.widgets.x1"]'),l=e('input[name="'+r+'.widgets.y1"]'),s=e('input[name="'+r+'.widgets.x2"]'),d=e('input[name="'+r+'.widgets.y2"]');if(o.val()&&l.val()&&s.val()&&d.val()){var c=e('select[name="'+r+'.widgets.projection:list"]'),p={area:{x1:parseFloat(o.val()),y1:parseFloat(l.val()),x2:parseFloat(s.val()),y2:parseFloat(d.val())},from_srid:c.val(),to_srid:4326};n.callJSON("transformArea",p,(function(e){if(!e.error){var a=e.result.area,n=i.data("area");n.editing.disable(),n.setBounds([t.latLng({lon:a.x1,lat:a.y1}),t.latLng({lon:a.x2,lat:a.y2})]),n.editing.enable()}}))}}},changedProjection:function(a){var t=e(this),i=e(".map",t.parents("fieldset:first")).data("map-leaflet-fieldname"),r=e('input[name="'+i+'.widgets.x1"]'),o=e('input[name="'+i+'.widgets.y1"]'),l=e('input[name="'+i+'.widgets.x2"]'),s=e('input[name="'+i+'.widgets.y2"]');if(a.removed){var d=a.removed.id,c=a.added.id;if(d!==c&&r.val()&&o.val()&&l.val()&&s.val()){var p={area:{x1:parseFloat(r.val()),y1:parseFloat(o.val()),x2:parseFloat(l.val()),y2:parseFloat(s.val())},from_srid:d,to_srid:c};n.callJSON("transformArea",p,(function(e){if(!e.error){var a=e.result.area;r.val(a.x1),o.val(a.y1),l.val(a.x2),s.val(a.y2)}}))}}else n.area.changedCoordinate.apply(r)},clear:function(a){var t=e(this).parents("fieldset:first");e("input",t).val(null);var i=e(".map",t);i.trigger("marker.cleared.area",[i])}}};a.PyAMS_GIS=n}(jQuery,this);