diff --git a/src/OpenLayers.Blazor/wwwroot/openlayers_interop.js b/src/OpenLayers.Blazor/wwwroot/openlayers_interop.js index 7132dc4..027d44b 100644 --- a/src/OpenLayers.Blazor/wwwroot/openlayers_interop.js +++ b/src/OpenLayers.Blazor/wwwroot/openlayers_interop.js @@ -1056,6 +1056,17 @@ MapOL.prototype.getCoordinates = function(layerId, featureId) { return null; }; +MapOL.prototype.getShapeStyleAsync = async function(feature, layer_id) { + var shape; + if (ol.render.Feature.prototype.isPrototypeOf(feature)) + shape = this.mapFeatureToInternalFeature(feature); + else + shape = this.mapFeatureToShape(feature); + delete shape.coordinates; + const style = await this.Instance.invokeMethodAsync("OnGetShapeStyleAsync", shape, layer_id); + return this.mapStyleOptionsToStyle(style, shape.geometryType); +}; + MapOL.prototype.getShapeStyle = function(feature, layer_id) { var shape; if (ol.render.Feature.prototype.isPrototypeOf(feature)) @@ -1063,11 +1074,11 @@ MapOL.prototype.getShapeStyle = function(feature, layer_id) { else shape = this.mapFeatureToShape(feature); delete shape.coordinates; - const style = this.Instance.invokeMethod("OnGetShapeStyle", shape, layer_id); - return this.mapStyleOptionsToStyle(style); + const style = this.Instance.invokeMethod("OnGetShapeStyle", shape, layer_id); // will fail on blazor server + return this.mapStyleOptionsToStyle(style, shape.geometryType); }; -MapOL.prototype.mapStyleOptionsToStyle = function(style) { +MapOL.prototype.mapStyleOptionsToStyle = function(style, geometryType = null) { style = MapOL.transformNullToUndefined(style); @@ -1101,6 +1112,15 @@ MapOL.prototype.mapStyleOptionsToStyle = function(style) { if (style.text.backgroundStroke) style.text.backgroundStroke = new ol.style.Stroke(style.text.backgroundStroke); } + // fix point style if circle not set + if (geometryType == 'Point' && !style.circle) { + style.circle = { + fill: new ol.style.Fill(style.fill), + stroke: new ol.style.Stroke(style.stroke), + radius: style.stroke.width * 2 + }; + } + const styleObject = new ol.style.Style({ stroke: style.stroke ? new ol.style.Stroke(style.stroke) : undefined, fill: style.fill ? new ol.style.Fill(style.fill) : undefined, diff --git a/src/OpenLayers.Blazor/wwwroot/openlayers_interop.min.js b/src/OpenLayers.Blazor/wwwroot/openlayers_interop.min.js index 32ffc17..75cda6b 100644 --- a/src/OpenLayers.Blazor/wwwroot/openlayers_interop.min.js +++ b/src/OpenLayers.Blazor/wwwroot/openlayers_interop.min.js @@ -1 +1 @@ -var _MapOL=new Array;function MapOLInit(e,t,o,r,n,a,i,s,p){_MapOL[e]=new MapOL(e,t,o,r,n,a,i,s,p)}function MapOLDispose(e){_MapOL[e]=void 0}function MapOLCenter(e,t){_MapOL[e].setCenter(t)}function MapOLRotate(e,t){_MapOL[e].setRotation(t)}function MapOLZoom(e,t){_MapOL[e].setZoom(t)}function MapOLSetOptions(e,t){_MapOL[e].setOptions(t)}function MapOLZoomToExtent(e,t,o){_MapOL[e].setZoomToExtent(t,o)}function MapOLSetShapes(e,t,o){_MapOL[e].setShapes(t,o)}function MapOLCenterToCurrentGeoLocation(e){_MapOL[e].centerToCurrentGeoLocation()}function MapOLGetCurrentGeoLocation(e){return _MapOL[e].getCurrentGeoLocation()}function MapOLSetLayers(e,t){_MapOL[e].setLayers(t)}function MapOLRemoveLayer(e,t){_MapOL[e].removeLayer(t)}function MapOLAddLayer(e,t){_MapOL[e].addLayer(t)}function MapOLUpdateLayer(e,t){_MapOL[e].updateLayer(t)}function MapOLSetVisibleExtent(e,t){_MapOL[e].setVisibleExtent(t)}function MapOLSetDrawingSettings(e,t,o,r,n,a,i){_MapOL[e].setDrawingSettings(t,o,r,n,a,i)}function MapOLUndoDrawing(e){_MapOL[e].undoDrawing()}function MapOLUpdateShape(e,t,o){_MapOL[e].updateShape(t,o)}function MapOLRemoveShape(e,t,o){_MapOL[e].removeShape(t,o)}function MapOLAddShape(e,t,o){_MapOL[e].addShape(t,o)}function MapOLGetCoordinates(e,t,o){return _MapOL[e].getCoordinates(t,o)}function MapOLSetInteractions(e,t){_MapOL[e].setInteractions(t)}function MapOLSetSelectionSettings(e,t,o,r,n){_MapOL[e].setSelectionSettings(t,o,r,n)}function MapOLShowPopup(e,t){_MapOL[e].showPopup(t)}function MapOLApplyMapboxStyle(e,t,o){_MapOL[e].applyMapboxStyle(t,o)}function MapOL(e,t,o,r,n,a,i,s,p){this.Instance=p,this.Options=o;p=new ol.proj.Projection({code:"EPSG:21781",extent:[485869.5728,76443.1884,837076.5648,299941.7864],units:"m"}),ol.proj.addProjection(p),o=new ol.proj.Projection({code:"EPSG:2056",extent:[2485071.58,1074261.72,2837119.8,1299941.79],units:"m"}),ol.proj.addProjection(o),ol.proj.addCoordinateTransforms("EPSG:4326",p,function(e){return[MapOL.WGStoLV03y(e[1],e[0]),MapOL.WGStoLV03x(e[1],e[0])]},function(e){return[MapOL.CHtoLV03lng(e[0],e[1]),MapOL.CHtoLV03lat(e[0],e[1])]}),ol.proj.addCoordinateTransforms("EPSG:4326",o,function(e){return[MapOL.WGStoLV95y(e[1],e[0]),MapOL.WGStoLV95x(e[1],e[0])]},function(e){return[MapOL.LV95toWGSlng(e[0],e[1]),MapOL.LV95toWGSlat(e[0],e[1])]}),this.Options.coordinatesProjection||(this.Options.coordinatesProjection="EPSG:4326"),s=this.prepareLayers(s);let c=0{try{let e;var r,n,a,i,p=o.source.sourceType;switch(o.options&&delete(o=Object.assign(o,o.options)).options,o.source&&o.source.options&&(o.source=Object.assign(o.source,o.source.options),delete o.source.options),(o=MapOL.transformNullToUndefined(o)).extent&&this.Options.coordinatesProjection&&(r=l.Options.viewProjection??(0e.get("id")==t)},MapOL.prototype.setLayers=function(e){this.Map.setLayers(this.prepareLayers(e))},MapOL.prototype.removeLayer=function(e){this.Map.removeLayer(this.getLayer(e))},MapOL.prototype.addLayer=function(e){e=this.prepareLayers([e]);this.Map.addLayer(e[0])},MapOL.prototype.updateLayer=function(t){var e=this.Map.getAllLayers().find(e=>e.get("id")==t.id);null!=e&&(e.setVisible(t.visibility),e.setOpacity(t.opacity),e.setZIndex(t.zindex),e.setExtent(t.extent))},MapOL.prototype.getShapesLayer=function(){return this.getLayer("shapes")},MapOL.prototype.getMarkersLayer=function(){return this.getLayer("markers")},MapOL.prototype.setShapes=function(e,t){var o=this.getLayer(e).getSource();o.clear(),t&&t.forEach(e=>{e=this.mapShapeToFeature(e,o);o.addFeature(e)})},MapOL.prototype.setZoom=function(e){this.Map.getView().setZoom(e)},MapOL.prototype.setZoomToExtent=function(e,t){null==t&&(t=void 0);e=this.getLayer(e).getSource().getExtent();e[0]!==1/0&&this.Map.getView().fit(e,{size:this.Map.getSize(),padding:t})},MapOL.prototype.setCenter=function(e){this.Map.getView().setCenter(ol.proj.transform(e,this.Options.coordinatesProjection,this.Map.getView().getProjection()))},MapOL.prototype.setRotation=function(e){this.Map.getView().setRotation(e)},MapOL.prototype.setOptions=function(e){this.Options=e},MapOL.prototype.setInteractions=function(r){this.Map.getInteractions().forEach((e,t,o)=>{e.setActive(r)}),r?0==this.Map.getControls().getLength()&&this.addControls():this.Map.getControls().clear()},MapOL.prototype.addControls=function(){this.Options.zoomControl&&this.Map.addControl(new ol.control.Zoom),this.Options.attributionControl&&this.Map.addControl(new ol.control.Attribution),this.Options.fullScreenControl&&this.Map.addControl(new ol.control.FullScreen),this.Options.zoomSliderControl&&this.Map.addControl(new ol.control.ZoomSlider),this.Options.rotateControl&&this.Map.addControl(new ol.control.Rotate),"None"!=this.Options.scaleLineUnit&&this.Map.addControl(new ol.control.ScaleLine({units:this.Options.scaleLineUnit.toLowerCase()})),this.Options.overviewMap&&this.Map.addControl(new ol.control.OverviewMap({layers:[new ol.layer.Tile(layers[0])]})),this.Options.zoomToExtentControl&&this.Map.addControl(new ol.control.ZoomToExtent)},MapOL.prototype.getReducedFeature=function(e){e.getGeometry().getType();var t=((e,t)=>{let{[t]:o,...r}=e;return r})(e.getProperties(),"geometry");return{type:"Feature",geometry:{type:e.getGeometry().getType(),coordinates:e.getGeometry().getCoordinates()},properties:t}},MapOL.prototype.onMapClick=function(e,n,t){n.setPosition(0,0);var a=this,o=ol.proj.transform(e.coordinate,this.Map.getView().getProjection(),this.Options.coordinatesProjection);this.Instance.invokeMethodAsync("OnInternalClick",o),this.Map.forEachFeatureAtPixel(e.pixel,function(e,t){var o,r;t&&(t=t.get("id"),ol.Feature.prototype.isPrototypeOf(e)?((o=a.mapFeatureToShape(e))&&a.Instance.invokeMethodAsync("OnInternalShapeClick",o,t),r=!1,(r=null==(r=o?o.properties.popup:r)?a.Options.autoPopup:r)&&(o=e.getGeometry().getCoordinates(),n.setPosition(o))):ol.render.Feature.prototype.isPrototypeOf(e)&&((r=a.mapFeatureToInternalFeature(e))&&a.Instance.invokeMethodAsync("OnInternalFeatureClick",r,t),a.Options.autoPopup)&&n.setPosition(r.coordinates))})},MapOL.prototype.showPopup=function(e){this.OverlayPopup.setPosition(ol.proj.transform(e,this.Options.coordinatesProjection,this.Map.getView().getProjection()))},MapOL.prototype.onMapPointerMove=function(e){var t,o,r;e.dragging||Number.isNaN(e.coordinate[0])||(t=ol.proj.transform(e.coordinate,this.Map.getView().getProjection(),this.Options.coordinatesProjection),this.Instance.invokeMethodAsync("OnInternalPointerMove",t),r=o=null,this.Map.forEachFeatureAtPixel(e.pixel,function(e,t){t&&(e=e.getId())&&(t=t.get("id"),o||(o=e.toString(),r=t))}),this._hoverFeatureId==o&&this._hoverLayerId==r)||(this.Instance.invokeMethodAsync("OnInternalShapeHover",r,o),this._hoverFeatureId=o,this._hoverLayerId=r)},MapOL.prototype.onMapResolutionChanged=function(){this.Instance.invokeMethodAsync("OnInternalZoomChanged",this.Map.getView().getZoom()),this.onVisibleExtentChanged()},MapOL.prototype.onMapCenterChanged=function(){var e=this.Map.getView().getCenter();e&&(e=ol.proj.transform(e,this.Map.getView().getProjection(),this.Options.coordinatesProjection),this.Instance.invokeMethodAsync("OnInternalCenterChanged",e),this.onVisibleExtentChanged())},MapOL.prototype.onMapRotationChanged=function(){var e=this.Map.getView().getRotation();e&&this.Instance.invokeMethodAsync("OnInternalRotationChanged",e)},MapOL.prototype.onVisibleExtentChanged=function(){var e,t;this.disableVisibleExtentChanged||(e=this.Map.getView().calculateExtent(this.Map.getSize()),t=ol.proj.transform([e[0],e[1]],this.Map.getView().getProjection(),this.Options.coordinatesProjection),e=ol.proj.transform([e[2],e[3]],this.Map.getView().getProjection(),this.Options.coordinatesProjection),t={X1:t[0],Y1:t[1],X2:e[0],Y2:e[1]},this.Instance.invokeMethodAsync("OnInternalVisibleExtentChanged",t))},MapOL.prototype.centerToCurrentGeoLocation=function(){var o=this;navigator.geolocation&&navigator.geolocation.getCurrentPosition(function(e){var t=o.Map.getView().getProjection().getCode();o.Map.getView().setCenter(ol.proj.transform([e.coords.longitude,e.coords.latitude],"EPSG:4326",t))})},MapOL.prototype.getCurrentGeoLocation=function(){var r=this;return new Promise((o,e)=>{navigator.geolocation?navigator.geolocation.getCurrentPosition(function(e){var t=r.Map.getView().getProjection().getCode(),e=ol.proj.transform([e.coords.longitude,e.coords.latitude],"EPSG:4326",t);o(e)}):e("No geolocation received")})},MapOL.prototype.disableVisibleExtentChranged=!1,MapOL.prototype.setVisibleExtent=function(e){this.disableVisibleExtentChanged=!0;var t=this.Map.getView().getProjection(),e=ol.proj.transformExtent(new Array(e.x1,e.y1,e.x2,e.y2),this.Options.coordinatesProjection,t);this.Map.getView().fit(e,this.Map.getSize()),this.disableVisibleExtentChanged=!1},MapOL.prototype.currentDraw=null,MapOL.prototype.currentSnap=null,MapOL.prototype.currentModify=null,MapOL.prototype.setDrawingSettings=function(e,t,o,r,n,a){var i=this,s=(this.removeDrawingInteractions(),this.getLayer(e).getSource());o&&null==this.currentModify&&(this.currentModify=new ol.interaction.Modify({source:s}),this.Map.addInteraction(this.currentModify)),t&&(this.currentDraw=new ol.interaction.Draw({source:s,type:n,freehand:a}),this.currentDraw.on("drawend",function(t){i.getShapeStyleAsync(t.feature,"geometries").then(e=>t.feature.setStyle(e)),i.onFeatureAdded(e,t.feature)}),this.Map.addInteraction(this.currentDraw)),r&&(this.currentSnap=new ol.interaction.Snap({source:s}),this.Map.addInteraction(this.currentSnap))},MapOL.prototype.removeDrawingInteractions=function(){this.currentDraw&&(this.Map.removeInteraction(this.currentDraw),this.currentDraw=null),this.currentSnap&&(this.Map.removeInteraction(this.currentSnap),this.currentSnap=null),this.currentModify&&(this.Map.removeInteraction(this.currentModify),this.currentModify=null)},MapOL.prototype.undoDrawing=function(){this.currentDraw&&this.currentDraw.removeLastPoint()},MapOL.prototype.currentSelection=null,MapOL.prototype.setSelectionSettings=function(r,e,t,o){var n=this,a=new ol.style.Style({fill:new ol.style.Fill({color:"#eeeeeeaa"}),stroke:new ol.style.Stroke({color:"rgba(67, 141, 239, 0.7)",width:5})});e?(this.currentSelection=new ol.interaction.Select({condition:ol.events.condition.click,style:function(e){return t?n.mapStyleOptionsToStyle(t):(e=e.get("COLOR")||"#eeeeeeaa",a.getFill().setColor(e),a)},layers:r?[this.getLayer(r)]:void 0,multi:o}),this.currentSelection.on("select",function(e){var t=new Array,o=(e.selected&&e.selected.forEach(e=>t.push(n.mapFeatureToShape(e))),new Array);e.unselected&&e.unselected.forEach(e=>o.push(n.mapFeatureToShape(e))),n.Instance.invokeMethodAsync("OnInternalSelectionChanged",r,t,o)}),this.Map.addInteraction(this.currentSelection)):this.currentSelection&&(this.Map.removeInteraction(this.currentSelection),this.currentSelection=null)},MapOL.prototype.onFeatureAdded=function(e,t){t=this.mapFeatureToShape(t);this.Instance.invokeMethodAsync("OnInternalShapeAdded",e,t)},MapOL.prototype.mapFeatureToShape=function(e){var t,o,r,n,a,i;return null==e?null:(t=e.getGeometry(),a=this.Map?this.Map.getView().getProjection():this.Options.viewProjection??"EPSG:3857",(o=null)==t||Array.isArray(t)||("Circle"===t.getType()?o=ol.proj.transform(t.getCenter(),a,this.Options.coordinatesProjection):(i=t.getCoordinates(),r=i.length,Array.isArray(i[0])&&i.forEach(e=>r+=e.length),rn.push(this.mapStylesToStyleOptions(e))):i&&(n=[this.mapStylesToStyleOptions(i)]),null==(a=e.getId())?(a=self.crypto.randomUUID(),e.setId(a)):a=a.toString(),(i=((e,t)=>{let{[t]:o,...r}=e;return r})(e.getProperties(),"geometry")).type||(i.type="Shape"),e={id:a,geometryType:t?t.getType():"None",coordinates:o,properties:i,styles:n},t&&"Circle"==t.getType()&&t.getRadius&&(e.radius=t.getRadius()),e)},MapOL.prototype.mapFeatureToInternalFeature=function(e){var t,o,r,n;return null==e?null:(n=this.Map?this.Map.getView().getProjection():this.Options.viewProjection??"EPSG:3857",t=null,r=e.getFlatCoordinates(),o=r.length,Array.isArray(r[0])&&r.forEach(e=>o+=e.length),oi.push(this.mapStyleOptionsToStyle(e))),o.setStyle(i)):o.setStyle(this.mapStyleOptionsToStyle(e.styles))),e.flatStyle&&o.setStyle(e.flatStyle),o},MapOL.prototype.onFeatureRemoved=function(e,t){t=this.mapFeatureToShape(t);this.Instance.invokeMethodAsync("OnInternalShapeRemoved",e,t)},MapOL.prototype.onFeatureChanged=function(e,t){t=this.mapFeatureToShape(t);this.Instance.invokeMethodAsync("OnInternalShapeChanged",e,t)},MapOL.prototype.updateShape=function(e,t){var o,e=this.getLayer(e).getSource().getFeatureById(t.id);e&&((o=(t=this.mapShapeToFeature(t)).getGeometry())&&e.setGeometry(o),e.setStyle(t.getStyle()))},MapOL.prototype.removeShape=function(t,e){var o=this.Map.getAllLayers().find(e=>e.get("id")==t).getSource(),e=o.getFeatureById(e.id);e&&o.removeFeature(e)},MapOL.prototype.addShape=function(t,e){var o=this.Map.getAllLayers().find(e=>e.get("id")==t).getSource(),e=this.mapShapeToFeature(e,o);o.addFeature(e)},MapOL.prototype.getCoordinates=function(t,e){t=this.getLayer(t).getSource().getFeatureById(e);if(t){let e=t.getGeometry().getCoordinates();return e=e||t.getGeometry().getCenter()}return null},MapOL.prototype.getShapeStyle=function(e,t){e=ol.render.Feature.prototype.isPrototypeOf(e)?this.mapFeatureToInternalFeature(e):this.mapFeatureToShape(e),delete e.coordinates,e=this.Instance.invokeMethod("OnGetShapeStyle",e,t);return this.mapStyleOptionsToStyle(e)},MapOL.prototype.mapStyleOptionsToStyle=function(e){(e=MapOL.transformNullToUndefined(e)).icon&&e.icon.shapeSource&&(t=document.createElement("canvas"),r=ol.render.toContext(t.getContext("2d"),{size:e.icon.size,pixelRatio:1}),o=this.mapShapeToFeature(e.icon.shapeSource,null,!1),r.setStyle(o.getStyle()[0]),r.drawGeometry(o.getGeometry()),e.icon.img=t),e.icon&&e.icon.scale&&(e.icon.width=void 0,e.icon.height=void 0),e.circle&&(e.circle.fill&&(e.circle.fill=new ol.style.Fill(e.circle.fill)),e.circle.stroke)&&(e.circle.stroke=new ol.style.Stroke(e.circle.stroke)),e.text&&(e.text.fill&&(e.text.fill=new ol.style.Fill(e.text.fill)),e.text.stroke&&(e.text.stroke=new ol.style.Stroke(e.text.stroke)),e.text.backgroundFill&&(e.text.backgroundFill=new ol.style.Fill(e.text.backgroundFill)),e.text.backgroundStroke)&&(e.text.backgroundStroke=new ol.style.Stroke(e.text.backgroundStroke));var t,o,r=new ol.style.Style({stroke:e.stroke?new ol.style.Stroke(e.stroke):void 0,fill:e.fill?new ol.style.Fill(e.fill):void 0,text:e.text?new ol.style.Text(e.text):void 0,image:e.circle?new ol.style.Circle(e.circle):e.icon?new ol.style.Icon(e.icon):void 0,zIndex:e.zIndex});return r},MapOL.prototype.mapStylesToStyleOptions=function(e){var t,o,r=e.getImage(),n=e.getFill(),a=e.getStroke(),i=e.getText();return r&&r.getSrc&&(t=r),r&&r.getRadius&&(o=r),{fill:n?{color:n.getColor()}:void 0,stroke:a?{color:a.getColor(),lineCap:a.getLineCap(),lineJoin:a.getLineJoin(),lineDash:a.getLineDash(),lineDashOffset:a.getLineDashOffset(),miterLimit:a.getMiterLimit(),width:a.getWidth()}:void 0,text:i?{font:i.getFont(),maxAngle:i.getMaxAngle(),offsetX:i.getOffsetX(),offsetY:i.getOffsetY(),overflow:i.getOverflow(),placement:i.getPlacement(),repeat:i.getRepeat(),scale:i.getScale(),rotateWithView:i.getRotateWithView(),rotation:i.getRotation(),text:i.getText(),textAlign:i.getTextAlign(),justify:i.getJustify(),textBaseline:i.getTextBaseline(),fill:i.getFill()?{color:i.getFill().getColor()}:void 0,backgroundFill:i.getBackgroundFill()?{color:i.getBackgroundFill().getColor()}:void 0,stroke:i.getStroke()?{color:i.getStroke().getColor(),lineCap:i.getStroke().getLineCap(),lineJoin:i.getStroke().getLineJoin(),lineDash:i.getStroke().getLineDash(),lineDashOffset:i.getStroke().getLineDashOffset(),miterLimit:i.getStroke().getMiterLimit(),width:i.getStroke().getWidth()}:void 0,backgroundStroke:i.getBackgroundStroke()?{color:i.getBackgroundStroke().getColor(),lineCap:i.getBackgroundStroke().getLineCap(),lineJoin:i.getBackgroundStroke().getLineJoin(),lineDash:i.getBackgroundStroke().getLineDash(),lineDashOffset:i.getBackgroundStroke().getLineDashOffset(),miterLimit:i.getBackgroundStroke().getMiterLimit(),width:i.getBackgroundStroke().getWidth()}:void 0,backgroundFill:i.getBackgroundFill()?{color:i.getBackgroundFill().getColor()}:void 0,padding:i.getPadding()}:void 0,circle:o?{radius:o.getRadius(),fill:o.fill?{color:o.fill.getColor()}:void 0,rotation:o.getRotation(),rotateWithView:o.getRotateWithView(),declutterMode:o.getDeclutterMode(),displacement:o.getDisplacement(),stroke:o.stroke?{color:o.stroke.getColor(),lineCap:o.stroke.getLineCap(),lineJoin:o.stroke.getLineJoin(),lineDash:o.stroke.getLineDash(),lineDashOffset:o.stroke.getLineDashOffset(),miterLimit:o.stroke.getMiterLimit(),width:o.stroke.getWidth()}:void 0}:void 0,icon:t?{anchor:t.getAnchor(),color:t.getColor(),declutterMode:t.getDeclutterMode(),height:t.getHeight(),opacity:t.getOpacity(),rotation:t.getRotation(),rotateWithView:t.getRotateWithView(),scale:t.getScale(),size:t.getSize(),width:t.getWidth(),src:t.getSrc()}:void 0,zIndex:e.getZIndex()}},MapOL.prototype.applyMapboxStyle=function(e,t){var o=this;this.Map.getAllLayers().forEach(e=>{o.Map.removeLayer(e)}),olms.apply(this.Map,e,{accessToken:t}).then(function(e){})},MapOL.transformNullToUndefined=function e(t){for(var o in t)t.hasOwnProperty(o)&&null===t[o]?t[o]=void 0:"object"==typeof t[o]&&e(t[o]);return t},MapOL.transformCoordinates=function(o,r,n){var a;if(r===n)return o;if(Array.isArray(o)&&Array.isArray(o[0])){a=Array(o.length);for(let t=0;t{try{let e;var r,n,a,i,p=o.source.sourceType;switch(o.options&&delete(o=Object.assign(o,o.options)).options,o.source&&o.source.options&&(o.source=Object.assign(o.source,o.source.options),delete o.source.options),(o=MapOL.transformNullToUndefined(o)).extent&&this.Options.coordinatesProjection&&(r=l.Options.viewProjection??(0e.get("id")==t)},MapOL.prototype.setLayers=function(e){this.Map.setLayers(this.prepareLayers(e))},MapOL.prototype.removeLayer=function(e){this.Map.removeLayer(this.getLayer(e))},MapOL.prototype.addLayer=function(e){e=this.prepareLayers([e]);this.Map.addLayer(e[0])},MapOL.prototype.updateLayer=function(t){var e=this.Map.getAllLayers().find(e=>e.get("id")==t.id);null!=e&&(e.setVisible(t.visibility),e.setOpacity(t.opacity),e.setZIndex(t.zindex),e.setExtent(t.extent))},MapOL.prototype.getShapesLayer=function(){return this.getLayer("shapes")},MapOL.prototype.getMarkersLayer=function(){return this.getLayer("markers")},MapOL.prototype.setShapes=function(e,t){var o=this.getLayer(e).getSource();o.clear(),t&&t.forEach(e=>{e=this.mapShapeToFeature(e,o);o.addFeature(e)})},MapOL.prototype.setZoom=function(e){this.Map.getView().setZoom(e)},MapOL.prototype.setZoomToExtent=function(e,t){null==t&&(t=void 0);e=this.getLayer(e).getSource().getExtent();e[0]!==1/0&&this.Map.getView().fit(e,{size:this.Map.getSize(),padding:t})},MapOL.prototype.setCenter=function(e){this.Map.getView().setCenter(ol.proj.transform(e,this.Options.coordinatesProjection,this.Map.getView().getProjection()))},MapOL.prototype.setRotation=function(e){this.Map.getView().setRotation(e)},MapOL.prototype.setOptions=function(e){this.Options=e},MapOL.prototype.setInteractions=function(r){this.Map.getInteractions().forEach((e,t,o)=>{e.setActive(r)}),r?0==this.Map.getControls().getLength()&&this.addControls():this.Map.getControls().clear()},MapOL.prototype.addControls=function(){this.Options.zoomControl&&this.Map.addControl(new ol.control.Zoom),this.Options.attributionControl&&this.Map.addControl(new ol.control.Attribution),this.Options.fullScreenControl&&this.Map.addControl(new ol.control.FullScreen),this.Options.zoomSliderControl&&this.Map.addControl(new ol.control.ZoomSlider),this.Options.rotateControl&&this.Map.addControl(new ol.control.Rotate),"None"!=this.Options.scaleLineUnit&&this.Map.addControl(new ol.control.ScaleLine({units:this.Options.scaleLineUnit.toLowerCase()})),this.Options.overviewMap&&this.Map.addControl(new ol.control.OverviewMap({layers:[new ol.layer.Tile(layers[0])]})),this.Options.zoomToExtentControl&&this.Map.addControl(new ol.control.ZoomToExtent)},MapOL.prototype.getReducedFeature=function(e){e.getGeometry().getType();var t=((e,t)=>{let{[t]:o,...r}=e;return r})(e.getProperties(),"geometry");return{type:"Feature",geometry:{type:e.getGeometry().getType(),coordinates:e.getGeometry().getCoordinates()},properties:t}},MapOL.prototype.onMapClick=function(e,n,t){n.setPosition(0,0);var a=this,o=ol.proj.transform(e.coordinate,this.Map.getView().getProjection(),this.Options.coordinatesProjection);this.Instance.invokeMethodAsync("OnInternalClick",o),this.Map.forEachFeatureAtPixel(e.pixel,function(e,t){var o,r;t&&(t=t.get("id"),ol.Feature.prototype.isPrototypeOf(e)?((o=a.mapFeatureToShape(e))&&a.Instance.invokeMethodAsync("OnInternalShapeClick",o,t),r=!1,(r=null==(r=o?o.properties.popup:r)?a.Options.autoPopup:r)&&(o=e.getGeometry().getCoordinates(),n.setPosition(o))):ol.render.Feature.prototype.isPrototypeOf(e)&&((r=a.mapFeatureToInternalFeature(e))&&a.Instance.invokeMethodAsync("OnInternalFeatureClick",r,t),a.Options.autoPopup)&&n.setPosition(r.coordinates))})},MapOL.prototype.showPopup=function(e){this.OverlayPopup.setPosition(ol.proj.transform(e,this.Options.coordinatesProjection,this.Map.getView().getProjection()))},MapOL.prototype.onMapPointerMove=function(e){var t,o,r;e.dragging||Number.isNaN(e.coordinate[0])||(t=ol.proj.transform(e.coordinate,this.Map.getView().getProjection(),this.Options.coordinatesProjection),this.Instance.invokeMethodAsync("OnInternalPointerMove",t),r=o=null,this.Map.forEachFeatureAtPixel(e.pixel,function(e,t){t&&(e=e.getId())&&(t=t.get("id"),o||(o=e.toString(),r=t))}),this._hoverFeatureId==o&&this._hoverLayerId==r)||(this.Instance.invokeMethodAsync("OnInternalShapeHover",r,o),this._hoverFeatureId=o,this._hoverLayerId=r)},MapOL.prototype.onMapResolutionChanged=function(){this.Instance.invokeMethodAsync("OnInternalZoomChanged",this.Map.getView().getZoom()),this.onVisibleExtentChanged()},MapOL.prototype.onMapCenterChanged=function(){var e=this.Map.getView().getCenter();e&&(e=ol.proj.transform(e,this.Map.getView().getProjection(),this.Options.coordinatesProjection),this.Instance.invokeMethodAsync("OnInternalCenterChanged",e),this.onVisibleExtentChanged())},MapOL.prototype.onMapRotationChanged=function(){var e=this.Map.getView().getRotation();e&&this.Instance.invokeMethodAsync("OnInternalRotationChanged",e)},MapOL.prototype.onVisibleExtentChanged=function(){var e,t;this.disableVisibleExtentChanged||(e=this.Map.getView().calculateExtent(this.Map.getSize()),t=ol.proj.transform([e[0],e[1]],this.Map.getView().getProjection(),this.Options.coordinatesProjection),e=ol.proj.transform([e[2],e[3]],this.Map.getView().getProjection(),this.Options.coordinatesProjection),t={X1:t[0],Y1:t[1],X2:e[0],Y2:e[1]},this.Instance.invokeMethodAsync("OnInternalVisibleExtentChanged",t))},MapOL.prototype.centerToCurrentGeoLocation=function(){var o=this;navigator.geolocation&&navigator.geolocation.getCurrentPosition(function(e){var t=o.Map.getView().getProjection().getCode();o.Map.getView().setCenter(ol.proj.transform([e.coords.longitude,e.coords.latitude],"EPSG:4326",t))})},MapOL.prototype.getCurrentGeoLocation=function(){var r=this;return new Promise((o,e)=>{navigator.geolocation?navigator.geolocation.getCurrentPosition(function(e){var t=r.Map.getView().getProjection().getCode(),e=ol.proj.transform([e.coords.longitude,e.coords.latitude],"EPSG:4326",t);o(e)}):e("No geolocation received")})},MapOL.prototype.disableVisibleExtentChranged=!1,MapOL.prototype.setVisibleExtent=function(e){this.disableVisibleExtentChanged=!0;var t=this.Map.getView().getProjection(),e=ol.proj.transformExtent(new Array(e.x1,e.y1,e.x2,e.y2),this.Options.coordinatesProjection,t);this.Map.getView().fit(e,this.Map.getSize()),this.disableVisibleExtentChanged=!1},MapOL.prototype.currentDraw=null,MapOL.prototype.currentSnap=null,MapOL.prototype.currentModify=null,MapOL.prototype.setDrawingSettings=function(e,t,o,r,n,a){var i=this,s=(this.removeDrawingInteractions(),this.getLayer(e).getSource());o&&null==this.currentModify&&(this.currentModify=new ol.interaction.Modify({source:s}),this.Map.addInteraction(this.currentModify)),t&&(this.currentDraw=new ol.interaction.Draw({source:s,type:n,freehand:a}),this.currentDraw.on("drawend",function(t){i.getShapeStyleAsync(t.feature,"geometries").then(e=>t.feature.setStyle(e)),i.onFeatureAdded(e,t.feature)}),this.Map.addInteraction(this.currentDraw)),r&&(this.currentSnap=new ol.interaction.Snap({source:s}),this.Map.addInteraction(this.currentSnap))},MapOL.prototype.removeDrawingInteractions=function(){this.currentDraw&&(this.Map.removeInteraction(this.currentDraw),this.currentDraw=null),this.currentSnap&&(this.Map.removeInteraction(this.currentSnap),this.currentSnap=null),this.currentModify&&(this.Map.removeInteraction(this.currentModify),this.currentModify=null)},MapOL.prototype.undoDrawing=function(){this.currentDraw&&this.currentDraw.removeLastPoint()},MapOL.prototype.currentSelection=null,MapOL.prototype.setSelectionSettings=function(r,e,t,o){var n=this,a=new ol.style.Style({fill:new ol.style.Fill({color:"#eeeeeeaa"}),stroke:new ol.style.Stroke({color:"rgba(67, 141, 239, 0.7)",width:5})});e?(this.currentSelection=new ol.interaction.Select({condition:ol.events.condition.click,style:function(e){return t?n.mapStyleOptionsToStyle(t):(e=e.get("COLOR")||"#eeeeeeaa",a.getFill().setColor(e),a)},layers:r?[this.getLayer(r)]:void 0,multi:o}),this.currentSelection.on("select",function(e){var t=new Array,o=(e.selected&&e.selected.forEach(e=>t.push(n.mapFeatureToShape(e))),new Array);e.unselected&&e.unselected.forEach(e=>o.push(n.mapFeatureToShape(e))),n.Instance.invokeMethodAsync("OnInternalSelectionChanged",r,t,o)}),this.Map.addInteraction(this.currentSelection)):this.currentSelection&&(this.Map.removeInteraction(this.currentSelection),this.currentSelection=null)},MapOL.prototype.onFeatureAdded=function(e,t){t=this.mapFeatureToShape(t);this.Instance.invokeMethodAsync("OnInternalShapeAdded",e,t)},MapOL.prototype.mapFeatureToShape=function(e){var t,o,r,n,a,i;return null==e?null:(t=e.getGeometry(),a=this.Map?this.Map.getView().getProjection():this.Options.viewProjection??"EPSG:3857",(o=null)==t||Array.isArray(t)||("Circle"===t.getType()?o=ol.proj.transform(t.getCenter(),a,this.Options.coordinatesProjection):(i=t.getCoordinates(),r=i.length,Array.isArray(i[0])&&i.forEach(e=>r+=e.length),rn.push(this.mapStylesToStyleOptions(e))):i&&(n=[this.mapStylesToStyleOptions(i)]),null==(a=e.getId())?(a=self.crypto.randomUUID(),e.setId(a)):a=a.toString(),(i=((e,t)=>{let{[t]:o,...r}=e;return r})(e.getProperties(),"geometry")).type||(i.type="Shape"),e={id:a,geometryType:t?t.getType():"None",coordinates:o,properties:i,styles:n},t&&"Circle"==t.getType()&&t.getRadius&&(e.radius=t.getRadius()),e)},MapOL.prototype.mapFeatureToInternalFeature=function(e){var t,o,r,n;return null==e?null:(n=this.Map?this.Map.getView().getProjection():this.Options.viewProjection??"EPSG:3857",t=null,r=e.getFlatCoordinates(),o=r.length,Array.isArray(r[0])&&r.forEach(e=>o+=e.length),oi.push(this.mapStyleOptionsToStyle(e))),o.setStyle(i)):o.setStyle(this.mapStyleOptionsToStyle(e.styles))),e.flatStyle&&o.setStyle(e.flatStyle),o},MapOL.prototype.onFeatureRemoved=function(e,t){t=this.mapFeatureToShape(t);this.Instance.invokeMethodAsync("OnInternalShapeRemoved",e,t)},MapOL.prototype.onFeatureChanged=function(e,t){t=this.mapFeatureToShape(t);this.Instance.invokeMethodAsync("OnInternalShapeChanged",e,t)},MapOL.prototype.updateShape=function(e,t){var o,e=this.getLayer(e).getSource().getFeatureById(t.id);e&&((o=(t=this.mapShapeToFeature(t)).getGeometry())&&e.setGeometry(o),e.setStyle(t.getStyle()))},MapOL.prototype.removeShape=function(t,e){var o=this.Map.getAllLayers().find(e=>e.get("id")==t).getSource(),e=o.getFeatureById(e.id);e&&o.removeFeature(e)},MapOL.prototype.addShape=function(t,e){var o=this.Map.getAllLayers().find(e=>e.get("id")==t).getSource(),e=this.mapShapeToFeature(e,o);o.addFeature(e)},MapOL.prototype.getCoordinates=function(t,e){t=this.getLayer(t).getSource().getFeatureById(e);if(t){let e=t.getGeometry().getCoordinates();return e=e||t.getGeometry().getCenter()}return null},MapOL.prototype.getShapeStyleAsync=async function(e,t){e=ol.render.Feature.prototype.isPrototypeOf(e)?this.mapFeatureToInternalFeature(e):this.mapFeatureToShape(e),delete e.coordinates,t=await this.Instance.invokeMethodAsync("OnGetShapeStyleAsync",e,t);return this.mapStyleOptionsToStyle(t,e.geometryType)},MapOL.prototype.getShapeStyle=function(e,t){e=ol.render.Feature.prototype.isPrototypeOf(e)?this.mapFeatureToInternalFeature(e):this.mapFeatureToShape(e),delete e.coordinates,t=this.Instance.invokeMethod("OnGetShapeStyle",e,t);return this.mapStyleOptionsToStyle(t,e.geometryType)},MapOL.prototype.mapStyleOptionsToStyle=function(e,t=null){(e=MapOL.transformNullToUndefined(e)).icon&&e.icon.shapeSource&&(o=document.createElement("canvas"),n=ol.render.toContext(o.getContext("2d"),{size:e.icon.size,pixelRatio:1}),r=this.mapShapeToFeature(e.icon.shapeSource,null,!1),n.setStyle(r.getStyle()[0]),n.drawGeometry(r.getGeometry()),e.icon.img=o),e.icon&&e.icon.scale&&(e.icon.width=void 0,e.icon.height=void 0),e.circle&&(e.circle.fill&&(e.circle.fill=new ol.style.Fill(e.circle.fill)),e.circle.stroke)&&(e.circle.stroke=new ol.style.Stroke(e.circle.stroke)),e.text&&(e.text.fill&&(e.text.fill=new ol.style.Fill(e.text.fill)),e.text.stroke&&(e.text.stroke=new ol.style.Stroke(e.text.stroke)),e.text.backgroundFill&&(e.text.backgroundFill=new ol.style.Fill(e.text.backgroundFill)),e.text.backgroundStroke)&&(e.text.backgroundStroke=new ol.style.Stroke(e.text.backgroundStroke)),"Point"!=t||e.circle||(e.circle={fill:new ol.style.Fill(e.fill),stroke:new ol.style.Stroke(e.stroke),radius:2*e.stroke.width});var o,r,n=new ol.style.Style({stroke:e.stroke?new ol.style.Stroke(e.stroke):void 0,fill:e.fill?new ol.style.Fill(e.fill):void 0,text:e.text?new ol.style.Text(e.text):void 0,image:e.circle?new ol.style.Circle(e.circle):e.icon?new ol.style.Icon(e.icon):void 0,zIndex:e.zIndex});return n},MapOL.prototype.mapStylesToStyleOptions=function(e){var t,o,r=e.getImage(),n=e.getFill(),a=e.getStroke(),i=e.getText();return r&&r.getSrc&&(t=r),r&&r.getRadius&&(o=r),{fill:n?{color:n.getColor()}:void 0,stroke:a?{color:a.getColor(),lineCap:a.getLineCap(),lineJoin:a.getLineJoin(),lineDash:a.getLineDash(),lineDashOffset:a.getLineDashOffset(),miterLimit:a.getMiterLimit(),width:a.getWidth()}:void 0,text:i?{font:i.getFont(),maxAngle:i.getMaxAngle(),offsetX:i.getOffsetX(),offsetY:i.getOffsetY(),overflow:i.getOverflow(),placement:i.getPlacement(),repeat:i.getRepeat(),scale:i.getScale(),rotateWithView:i.getRotateWithView(),rotation:i.getRotation(),text:i.getText(),textAlign:i.getTextAlign(),justify:i.getJustify(),textBaseline:i.getTextBaseline(),fill:i.getFill()?{color:i.getFill().getColor()}:void 0,backgroundFill:i.getBackgroundFill()?{color:i.getBackgroundFill().getColor()}:void 0,stroke:i.getStroke()?{color:i.getStroke().getColor(),lineCap:i.getStroke().getLineCap(),lineJoin:i.getStroke().getLineJoin(),lineDash:i.getStroke().getLineDash(),lineDashOffset:i.getStroke().getLineDashOffset(),miterLimit:i.getStroke().getMiterLimit(),width:i.getStroke().getWidth()}:void 0,backgroundStroke:i.getBackgroundStroke()?{color:i.getBackgroundStroke().getColor(),lineCap:i.getBackgroundStroke().getLineCap(),lineJoin:i.getBackgroundStroke().getLineJoin(),lineDash:i.getBackgroundStroke().getLineDash(),lineDashOffset:i.getBackgroundStroke().getLineDashOffset(),miterLimit:i.getBackgroundStroke().getMiterLimit(),width:i.getBackgroundStroke().getWidth()}:void 0,backgroundFill:i.getBackgroundFill()?{color:i.getBackgroundFill().getColor()}:void 0,padding:i.getPadding()}:void 0,circle:o?{radius:o.getRadius(),fill:o.fill?{color:o.fill.getColor()}:void 0,rotation:o.getRotation(),rotateWithView:o.getRotateWithView(),declutterMode:o.getDeclutterMode(),displacement:o.getDisplacement(),stroke:o.stroke?{color:o.stroke.getColor(),lineCap:o.stroke.getLineCap(),lineJoin:o.stroke.getLineJoin(),lineDash:o.stroke.getLineDash(),lineDashOffset:o.stroke.getLineDashOffset(),miterLimit:o.stroke.getMiterLimit(),width:o.stroke.getWidth()}:void 0}:void 0,icon:t?{anchor:t.getAnchor(),color:t.getColor(),declutterMode:t.getDeclutterMode(),height:t.getHeight(),opacity:t.getOpacity(),rotation:t.getRotation(),rotateWithView:t.getRotateWithView(),scale:t.getScale(),size:t.getSize(),width:t.getWidth(),src:t.getSrc()}:void 0,zIndex:e.getZIndex()}},MapOL.prototype.applyMapboxStyle=function(e,t){var o=this;this.Map.getAllLayers().forEach(e=>{o.Map.removeLayer(e)}),olms.apply(this.Map,e,{accessToken:t}).then(function(e){})},MapOL.transformNullToUndefined=function e(t){for(var o in t)t.hasOwnProperty(o)&&null===t[o]?t[o]=void 0:"object"==typeof t[o]&&e(t[o]);return t},MapOL.transformCoordinates=function(o,r,n){var a;if(r===n)return o;if(Array.isArray(o)&&Array.isArray(o[0])){a=Array(o.length);for(let t=0;t