terra-draw-openlayers-adapter 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- var e=require("terra-draw");function t(e,r){return t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},t(e,r)}exports.TerraDrawOpenLayersAdapter=/*#__PURE__*/function(e){function r(t){var r,n;(n=e.call(this,t)||this).baseZIndex=1e5,n.stylingFunction=function(){return{}},n._lib=void 0,n._map=void 0,n._container=void 0,n._projection=void 0,n._vectorSource=void 0,n._geoJSONReader=void 0,n.registeredLayerHandlers=void 0,n._map=t.map,n._lib=t.lib,n._geoJSONReader=new n._lib.GeoJSON,n._projection=function(){var e;return null!=(e=n._lib.getUserProjection())?e:new n._lib.Projection({code:"EPSG:3857"})},n._container=n._map.getViewport(),n._container.setAttribute("tabindex","0");var o=new n._lib.VectorSource({features:[]});n._vectorSource=o,n.baseZIndex=null!=(r=t.zIndex)?r:1e5;var i=new n._lib.VectorLayer({source:o,style:function(e){return n.getStyles(e,n.stylingFunction())},zIndex:n.baseZIndex});return n._map.addLayer(i),n}var n,o;o=e,(n=r).prototype=Object.create(o.prototype),n.prototype.constructor=n,t(n,o);var i=r.prototype;return i.hexToRGB=function(e){return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16)}},i.getStyles=function(e,t){var r=this,n=e.getGeometry();if(n)return{Point:function(e){var n=e.getProperties(),o=t[n.mode]({type:"Feature",geometry:{type:"Point",coordinates:[]},properties:n});return new r._lib.Style({zIndex:r.baseZIndex+o.zIndex,image:new r._lib.Circle({radius:o.pointWidth,fill:new r._lib.Fill({color:o.pointColor}),stroke:new r._lib.Stroke({color:o.pointOutlineColor,width:o.pointOutlineWidth})})})},LineString:function(e){var n=e.getProperties(),o=t[n.mode]({type:"Feature",geometry:{type:"LineString",coordinates:[]},properties:n});return new r._lib.Style({zIndex:o.zIndex,stroke:new r._lib.Stroke({color:o.lineStringColor,width:o.lineStringWidth})})},Polygon:function(e){var n=e.getProperties(),o=t[n.mode]({type:"Feature",geometry:{type:"Polygon",coordinates:[]},properties:n}),i=r.hexToRGB(o.polygonFillColor),a=i.r,c=i.g,s=i.b;return new r._lib.Style({zIndex:o.zIndex,stroke:new r._lib.Stroke({color:o.polygonOutlineColor,width:o.polygonOutlineWidth}),fill:new r._lib.Fill({color:"rgba("+a+","+c+","+s+","+o.polygonFillOpacity+")"})})}}[n.getType()](e)},i.clearLayers=function(){this._vectorSource&&this._vectorSource.clear()},i.addFeature=function(e){var t=this._geoJSONReader.readFeature(e,{dataProjection:"EPSG:4326",featureProjection:this._projection()});this._vectorSource.addFeature(t)},i.removeFeature=function(e){var t=this._vectorSource.getFeatureById(e);t&&this._vectorSource.removeFeature(t)},i.sortElementsByDOMOrder=function(e){return e.sort(function(e,t){var r=e.compareDocumentPosition(t);return r&Node.DOCUMENT_POSITION_FOLLOWING?-1:r&Node.DOCUMENT_POSITION_PRECEDING?1:0})},i.getLngLatFromEvent=function(e){var t=this.getMapElementXYPosition(e),r=t.containerX,n=t.containerY;try{return this.unproject(r,n)}catch(e){return null}},i.getMapEventElement=function(){var e=Array.from(this._container.querySelectorAll("canvas")),t=this.sortElementsByDOMOrder(e);return t[t.length-1]},i.setDraggability=function(e){this._map.getInteractions().forEach(function(t){"DragPan"===t.constructor.name&&t.setActive(e)})},i.project=function(e,t){var r=this._map.getPixelFromCoordinate(this._lib.fromLonLat([e,t],this._projection()));return{x:r[0],y:r[1]}},i.unproject=function(e,t){var r=this._lib.toLonLat(this._map.getCoordinateFromPixel([e,t]),this._projection());return{lng:r[0],lat:r[1]}},i.setCursor=function(e){"unset"===e?this.getMapEventElement().style.removeProperty("cursor"):this.getMapEventElement().style.cursor=e},i.setDoubleClickToZoom=function(e){this._map.getInteractions().forEach(function(t){"DoubleClickZoom"===t.constructor.name&&t.setActive(e)})},i.render=function(e,t){var r=this;this.stylingFunction=function(){return t},e.deletedIds.forEach(function(e){r.removeFeature(e)}),e.updated.forEach(function(e){r.removeFeature(e.id),r.addFeature(e)}),e.created.forEach(function(e){r.addFeature(e)})},i.clear=function(){this._currentModeCallbacks&&(this._currentModeCallbacks.onClear(),this.clearLayers())},i.register=function(t){var r,n=this;if(e.prototype.register.call(this,t),!this.registeredLayerHandlers){var o=this._map.getLayerGroup().getLayers(),i=function(){n._listeners.forEach(function(e){e.unregister()})},a=function(){n._listeners=n.getAdapterListeners(),n._listeners.forEach(function(e){e.register()})};this.registeredLayerHandlers={addLayers:function(){i(),n._map.once("rendercomplete",function(){n._currentModeCallbacks&&a()})},removeLayers:function(){i(),n._map.once("rendercomplete",function(){n._currentModeCallbacks&&a()})}},o.on("add",function(){i(),n._map.once("rendercomplete",function(){n._currentModeCallbacks&&a()})}),o.on("remove",function(){i(),n._map.once("rendercomplete",function(){n._currentModeCallbacks&&a()})})}null!=(r=this._currentModeCallbacks)&&r.onReady&&this._currentModeCallbacks.onReady()},i.getCoordinatePrecision=function(){return e.prototype.getCoordinatePrecision.call(this)},i.unregister=function(){if(this.registeredLayerHandlers){var t=this._map.getLayerGroup();if(t){var r=t.getLayers();r&&(r.un("add",this.registeredLayerHandlers.addLayers),r.un("remove",this.registeredLayerHandlers.removeLayers))}}return e.prototype.unregister.call(this)},r}(e.TerraDrawExtend.TerraDrawBaseAdapter);
1
+ var e=require("terra-draw");function t(e,r){return t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},t(e,r)}exports.TerraDrawOpenLayersAdapter=/*#__PURE__*/function(e){function r(t){var r,n;(n=e.call(this,t)||this).baseZIndex=1e5,n.stylingFunction=function(){return{}},n._lib=void 0,n._map=void 0,n._container=void 0,n._projection=void 0,n._vectorSource=void 0,n._geoJSONReader=void 0,n.registeredLayerHandlers=void 0,n._map=t.map,n._lib=t.lib,n._geoJSONReader=new n._lib.GeoJSON,n._projection=function(){var e;return null!=(e=n._lib.getUserProjection())?e:new n._lib.Projection({code:"EPSG:3857"})},n._container=n._map.getViewport(),n._container.setAttribute("tabindex","0");var o=new n._lib.VectorSource({features:[]});n._vectorSource=o,n.baseZIndex=null!=(r=t.zIndex)?r:1e5;var i=new n._lib.VectorLayer({source:o,style:function(e){return n.getStyles(e,n.stylingFunction())},zIndex:n.baseZIndex});return n._map.addLayer(i),n}var n,o;o=e,(n=r).prototype=Object.create(o.prototype),n.prototype.constructor=n,t(n,o);var i=r.prototype;return i.hexToRGB=function(e){return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16)}},i.getStyles=function(e,t){var r=this,n=e.getGeometry();if(n)return{Point:function(e){var n=e.getProperties(),o=t[n.mode]({type:"Feature",geometry:{type:"Point",coordinates:[]},properties:n});return new r._lib.Style(o.markerUrl&&o.markerWidth&&o.markerHeight?{zIndex:r.baseZIndex+o.zIndex,image:new r._lib.Icon({src:o.markerUrl,width:o.markerWidth,height:o.markerHeight,anchor:[.5,1]})}:{zIndex:r.baseZIndex+o.zIndex,image:new r._lib.Circle({radius:o.pointWidth,fill:new r._lib.Fill({color:o.pointColor}),stroke:new r._lib.Stroke({color:o.pointOutlineColor,width:o.pointOutlineWidth})})})},LineString:function(e){var n=e.getProperties(),o=t[n.mode]({type:"Feature",geometry:{type:"LineString",coordinates:[]},properties:n});return new r._lib.Style({zIndex:o.zIndex,stroke:new r._lib.Stroke({color:o.lineStringColor,width:o.lineStringWidth})})},Polygon:function(e){var n=e.getProperties(),o=t[n.mode]({type:"Feature",geometry:{type:"Polygon",coordinates:[]},properties:n}),i=r.hexToRGB(o.polygonFillColor),a=i.r,c=i.g,s=i.b;return new r._lib.Style({zIndex:o.zIndex,stroke:new r._lib.Stroke({color:o.polygonOutlineColor,width:o.polygonOutlineWidth}),fill:new r._lib.Fill({color:"rgba("+a+","+c+","+s+","+o.polygonFillOpacity+")"})})}}[n.getType()](e)},i.clearLayers=function(){this._vectorSource&&this._vectorSource.clear()},i.addFeature=function(e){var t=this._geoJSONReader.readFeature(e,{dataProjection:"EPSG:4326",featureProjection:this._projection()});this._vectorSource.addFeature(t)},i.removeFeature=function(e){var t=this._vectorSource.getFeatureById(e);t&&this._vectorSource.removeFeature(t)},i.sortElementsByDOMOrder=function(e){return e.sort(function(e,t){var r=e.compareDocumentPosition(t);return r&Node.DOCUMENT_POSITION_FOLLOWING?-1:r&Node.DOCUMENT_POSITION_PRECEDING?1:0})},i.getLngLatFromEvent=function(e){var t=this.getMapElementXYPosition(e),r=t.containerX,n=t.containerY;try{return this.unproject(r,n)}catch(e){return null}},i.getMapEventElement=function(){var e=Array.from(this._container.querySelectorAll("canvas")),t=this.sortElementsByDOMOrder(e);return t[t.length-1]},i.setDraggability=function(e){this._map.getInteractions().forEach(function(t){"DragPan"===t.constructor.name&&t.setActive(e)})},i.project=function(e,t){var r=this._map.getPixelFromCoordinate(this._lib.fromLonLat([e,t],this._projection()));return{x:r[0],y:r[1]}},i.unproject=function(e,t){var r=this._lib.toLonLat(this._map.getCoordinateFromPixel([e,t]),this._projection());return{lng:r[0],lat:r[1]}},i.setCursor=function(e){"unset"===e?this.getMapEventElement().style.removeProperty("cursor"):this.getMapEventElement().style.cursor=e},i.setDoubleClickToZoom=function(e){this._map.getInteractions().forEach(function(t){"DoubleClickZoom"===t.constructor.name&&t.setActive(e)})},i.render=function(e,t){var r=this;this.stylingFunction=function(){return t},e.deletedIds.forEach(function(e){r.removeFeature(e)}),e.updated.forEach(function(e){r.removeFeature(e.id),r.addFeature(e)}),e.created.forEach(function(e){r.addFeature(e)})},i.clear=function(){this._currentModeCallbacks&&(this._currentModeCallbacks.onClear(),this.clearLayers())},i.register=function(t){var r,n=this;if(e.prototype.register.call(this,t),!this.registeredLayerHandlers){var o=this._map.getLayerGroup().getLayers(),i=function(){n._listeners.forEach(function(e){e.unregister()})},a=function(){n._listeners=n.getAdapterListeners(),n._listeners.forEach(function(e){e.register()})};this.registeredLayerHandlers={addLayers:function(){i(),n._map.once("rendercomplete",function(){n._currentModeCallbacks&&a()})},removeLayers:function(){i(),n._map.once("rendercomplete",function(){n._currentModeCallbacks&&a()})}},o.on("add",function(){i(),n._map.once("rendercomplete",function(){n._currentModeCallbacks&&a()})}),o.on("remove",function(){i(),n._map.once("rendercomplete",function(){n._currentModeCallbacks&&a()})})}null!=(r=this._currentModeCallbacks)&&r.onReady&&this._currentModeCallbacks.onReady()},i.getCoordinatePrecision=function(){return e.prototype.getCoordinatePrecision.call(this)},i.unregister=function(){if(this.registeredLayerHandlers){var t=this._map.getLayerGroup();if(t){var r=t.getLayers();r&&(r.un("add",this.registeredLayerHandlers.addLayers),r.un("remove",this.registeredLayerHandlers.removeLayers))}}return e.prototype.unregister.call(this)},r}(e.TerraDrawExtend.TerraDrawBaseAdapter);
2
2
  //# sourceMappingURL=terra-draw-openlayers-adapter.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"terra-draw-openlayers-adapter.cjs","sources":["../src/terra-draw-openlayers-adapter.ts"],"sourcesContent":["/**\n * @module terra-draw-openlayers-adapter\n */\nimport {\n\tTerraDrawChanges,\n\tSetCursor,\n\tTerraDrawStylingFunction,\n\tGeoJSONStoreFeatures,\n\tTerraDrawExtend,\n} from \"terra-draw\";\n\nimport Feature, { FeatureLike } from \"ol/Feature\";\nimport GeoJSON from \"ol/format/GeoJSON\";\nimport Map from \"ol/Map\";\nimport Circle from \"ol/style/Circle\";\nimport Fill from \"ol/style/Fill\";\nimport Stroke from \"ol/style/Stroke\";\nimport Style from \"ol/style/Style\";\nimport VectorSource from \"ol/source/Vector\";\nimport { Geometry } from \"ol/geom\";\nimport VectorLayer from \"ol/layer/Vector\";\nimport Projection from \"ol/proj/Projection\";\nimport { fromLonLat, toLonLat, getUserProjection } from \"ol/proj\";\nimport { Coordinate } from \"ol/coordinate\";\nimport { Pixel } from \"ol/pixel\";\n\nexport type InjectableOL = {\n\tFill: typeof Fill;\n\tFeature: typeof Feature;\n\tGeoJSON: typeof GeoJSON;\n\tStyle: typeof Style;\n\tCircle: typeof Circle;\n\tVectorLayer: typeof VectorLayer;\n\tVectorSource: typeof VectorSource;\n\tStroke: typeof Stroke;\n\tProjection: typeof Projection;\n\tgetUserProjection: typeof getUserProjection;\n\tfromLonLat: typeof fromLonLat;\n\ttoLonLat: typeof toLonLat;\n};\n\nexport class TerraDrawOpenLayersAdapter extends TerraDrawExtend.TerraDrawBaseAdapter {\n\tconstructor(\n\t\tconfig: {\n\t\t\tmap: Map;\n\t\t\tlib: InjectableOL;\n\t\t\tzIndex?: number;\n\t\t} & TerraDrawExtend.BaseAdapterConfig,\n\t) {\n\t\tsuper(config);\n\n\t\tthis._map = config.map;\n\t\tthis._lib = config.lib;\n\n\t\tthis._geoJSONReader = new this._lib.GeoJSON();\n\t\tthis._projection = () =>\n\t\t\tthis._lib.getUserProjection() ??\n\t\t\tnew this._lib.Projection({ code: \"EPSG:3857\" });\n\n\t\tthis._container = this._map.getViewport();\n\n\t\t// TODO: Is this the best way to receive keyboard events\n\t\tthis._container.setAttribute(\"tabindex\", \"0\");\n\n\t\tconst vectorSource = new this._lib.VectorSource({\n\t\t\tfeatures: [],\n\t\t}) as unknown as VectorSource<Feature<Geometry>>;\n\n\t\tthis._vectorSource = vectorSource as unknown as VectorSource<\n\t\t\tFeature<Geometry>\n\t\t>;\n\n\t\tthis.baseZIndex = config.zIndex ?? 100000;\n\n\t\tconst vectorLayer = new this._lib.VectorLayer({\n\t\t\tsource: vectorSource as unknown as VectorSource<never>,\n\t\t\tstyle: (feature) => this.getStyles(feature, this.stylingFunction()),\n\t\t\tzIndex: this.baseZIndex,\n\t\t});\n\n\t\tthis._map.addLayer(vectorLayer);\n\t}\n\n\tprivate baseZIndex = 100000;\n\tprivate stylingFunction = () => ({});\n\n\tprivate _lib: InjectableOL;\n\tprivate _map: Map;\n\tprivate _container: HTMLElement;\n\tprivate _projection: () => Projection;\n\tprivate _vectorSource: VectorSource<Feature<Geometry>>;\n\tprivate _geoJSONReader: GeoJSON;\n\n\t/**\n\t * Converts a hexadecimal color to RGB\n\t * @param hex a string of the hexadecimal string\n\t * @returns an object to red green and blue (RGB) color\n\t */\n\tprivate hexToRGB(hex: string): { r: number; g: number; b: number } {\n\t\treturn {\n\t\t\tr: parseInt(hex.slice(1, 3), 16),\n\t\t\tg: parseInt(hex.slice(3, 5), 16),\n\t\t\tb: parseInt(hex.slice(5, 7), 16),\n\t\t};\n\t}\n\n\tprivate getStyles(feature: FeatureLike, styling: TerraDrawStylingFunction) {\n\t\tconst geometry = feature.getGeometry();\n\t\tif (!geometry) {\n\t\t\treturn;\n\t\t}\n\t\tconst key = geometry.getType() as \"Point\" | \"LineString\" | \"Polygon\";\n\n\t\treturn {\n\t\t\tPoint: (feature: FeatureLike) => {\n\t\t\t\tconst properties = feature.getProperties();\n\t\t\t\tconst style = styling[properties.mode]({\n\t\t\t\t\ttype: \"Feature\",\n\t\t\t\t\tgeometry: { type: \"Point\", coordinates: [] },\n\t\t\t\t\tproperties,\n\t\t\t\t});\n\t\t\t\treturn new this._lib.Style({\n\t\t\t\t\tzIndex: this.baseZIndex + style.zIndex,\n\t\t\t\t\timage: new this._lib.Circle({\n\t\t\t\t\t\tradius: style.pointWidth,\n\t\t\t\t\t\tfill: new this._lib.Fill({\n\t\t\t\t\t\t\tcolor: style.pointColor,\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tstroke: new this._lib.Stroke({\n\t\t\t\t\t\t\tcolor: style.pointOutlineColor,\n\t\t\t\t\t\t\twidth: style.pointOutlineWidth,\n\t\t\t\t\t\t}),\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t},\n\t\t\tLineString: (feature: FeatureLike) => {\n\t\t\t\tconst properties = feature.getProperties();\n\t\t\t\tconst style = styling[properties.mode]({\n\t\t\t\t\ttype: \"Feature\",\n\t\t\t\t\tgeometry: { type: \"LineString\", coordinates: [] },\n\t\t\t\t\tproperties,\n\t\t\t\t});\n\t\t\t\treturn new this._lib.Style({\n\t\t\t\t\tzIndex: style.zIndex,\n\t\t\t\t\tstroke: new this._lib.Stroke({\n\t\t\t\t\t\tcolor: style.lineStringColor,\n\t\t\t\t\t\twidth: style.lineStringWidth,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t},\n\t\t\tPolygon: (feature: FeatureLike) => {\n\t\t\t\tconst properties = feature.getProperties();\n\t\t\t\tconst style = styling[properties.mode]({\n\t\t\t\t\ttype: \"Feature\",\n\t\t\t\t\tgeometry: { type: \"Polygon\", coordinates: [] },\n\n\t\t\t\t\tproperties,\n\t\t\t\t});\n\t\t\t\tconst { r, g, b } = this.hexToRGB(style.polygonFillColor);\n\n\t\t\t\treturn new this._lib.Style({\n\t\t\t\t\tzIndex: style.zIndex,\n\t\t\t\t\tstroke: new this._lib.Stroke({\n\t\t\t\t\t\tcolor: style.polygonOutlineColor,\n\t\t\t\t\t\twidth: style.polygonOutlineWidth,\n\t\t\t\t\t}),\n\t\t\t\t\tfill: new this._lib.Fill({\n\t\t\t\t\t\tcolor: `rgba(${r},${g},${b},${style.polygonFillOpacity})`,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t},\n\t\t}[key](feature);\n\t}\n\n\t/**\n\t * Clears the layers created by the adapter\n\t * @returns void\n\t * */\n\tprivate clearLayers() {\n\t\tif (this._vectorSource) {\n\t\t\tthis._vectorSource.clear();\n\t\t}\n\t}\n\n\tprivate addFeature(feature: GeoJSONStoreFeatures) {\n\t\tconst olFeature = this._geoJSONReader.readFeature(feature, {\n\t\t\tdataProjection: \"EPSG:4326\",\n\t\t\tfeatureProjection: this._projection(),\n\t\t}) as Feature<Geometry>;\n\t\tthis._vectorSource.addFeature(olFeature);\n\t}\n\n\tprivate removeFeature(id: TerraDrawExtend.FeatureId) {\n\t\tconst deleted = this._vectorSource.getFeatureById(id);\n\t\tif (!deleted) {\n\t\t\treturn;\n\t\t}\n\t\tthis._vectorSource.removeFeature(deleted);\n\t}\n\n\t/**\n\t * Sorts an array of DOM elements based on their order in the document, from earliest to latest.\n\t * @param elements - An array of `HTMLElement` objects to be sorted.\n\t * @returns A new array of `HTMLElement` objects sorted by their document order.\n\t */\n\tprivate sortElementsByDOMOrder(elements: HTMLElement[]) {\n\t\t// Sort the elements based on their DOM position\n\t\treturn elements.sort((a, b) => {\n\t\t\tconst position = a.compareDocumentPosition(b);\n\n\t\t\t// If a comes before b in the DOM\n\t\t\tif (position & Node.DOCUMENT_POSITION_FOLLOWING) {\n\t\t\t\treturn -1;\n\t\t\t}\n\n\t\t\t// If a comes after b in the DOM\n\t\t\tif (position & Node.DOCUMENT_POSITION_PRECEDING) {\n\t\t\t\treturn 1;\n\t\t\t}\n\n\t\t\t// If they are the same element\n\t\t\treturn 0;\n\t\t});\n\t}\n\n\t/**\n\t * Returns the longitude and latitude coordinates from a given PointerEvent on the map.\n\t * @param event The PointerEvent or MouseEvent containing the screen coordinates of the pointer.\n\t * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude, or null if the conversion is not possible.\n\t */\n\tpublic getLngLatFromEvent(event: PointerEvent | MouseEvent) {\n\t\tconst { containerX: x, containerY: y } =\n\t\t\tthis.getMapElementXYPosition(event);\n\t\ttry {\n\t\t\treturn this.unproject(x, y);\n\t\t} catch (_) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * Retrieves the HTML element of the OpenLayers element that handles interaction events\n\t * @returns The HTMLElement representing the map container.\n\t */\n\tpublic getMapEventElement() {\n\t\t// Each VectorLayer has a canvas element that is used to render the features, it orders\n\t\t// these in the order they are added to the map. The last canvas is the one that is on top\n\t\t// so we need to add the event listeners to this canvas so that the events are captured.\n\t\tconst canvases = Array.from(this._container.querySelectorAll(\"canvas\"));\n\t\tconst sortedCanvases = this.sortElementsByDOMOrder(\n\t\t\tcanvases,\n\t\t) as HTMLCanvasElement[];\n\t\tconst topCanvas = sortedCanvases[sortedCanvases.length - 1];\n\n\t\treturn topCanvas;\n\t}\n\n\t/**\n\t * Enables or disables the draggable functionality of the map.\n\t * @param enabled Set to true to enable map dragging, or false to disable it.\n\t */\n\tpublic setDraggability(enabled: boolean) {\n\t\tthis._map.getInteractions().forEach((interaction) => {\n\t\t\tif (interaction.constructor.name === \"DragPan\") {\n\t\t\t\tinteraction.setActive(enabled);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Converts longitude and latitude coordinates to pixel coordinates in the map container.\n\t * @param lng The longitude coordinate to project.\n\t * @param lat The latitude coordinate to project.\n\t * @returns An object with 'x' and 'y' properties representing the pixel coordinates within the map container.\n\t */\n\tpublic project(lng: number, lat: number) {\n\t\tconst [x, y] = this._map.getPixelFromCoordinate(\n\t\t\tthis._lib.fromLonLat([lng, lat], this._projection()) as Coordinate,\n\t\t);\n\t\treturn { x, y };\n\t}\n\n\t/**\n\t * Converts pixel coordinates in the map container to longitude and latitude coordinates.\n\t * @param x The x-coordinate in the map container to unproject.\n\t * @param y The y-coordinate in the map container to unproject.\n\t * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude coordinates.\n\t */\n\tpublic unproject(x: number, y: number) {\n\t\tconst [lng, lat] = this._lib.toLonLat(\n\t\t\tthis._map.getCoordinateFromPixel([x, y]) as Pixel,\n\t\t\tthis._projection(),\n\t\t);\n\t\treturn { lng, lat };\n\t}\n\n\t/**\n\t * Sets the cursor style for the map container.\n\t * @param cursor The CSS cursor style to apply, or 'unset' to remove any previously applied cursor style.\n\t */\n\tpublic setCursor(cursor: Parameters<SetCursor>[0]) {\n\t\tif (cursor === \"unset\") {\n\t\t\tthis.getMapEventElement().style.removeProperty(\"cursor\");\n\t\t} else {\n\t\t\tthis.getMapEventElement().style.cursor = cursor;\n\t\t}\n\t}\n\n\t/**\n\t * Enables or disables the double-click to zoom functionality on the map.\n\t * @param enabled Set to true to enable double-click to zoom, or false to disable it.\n\t */\n\tpublic setDoubleClickToZoom(enabled: boolean) {\n\t\tthis._map.getInteractions().forEach(function (interaction) {\n\t\t\tif (interaction.constructor.name === \"DoubleClickZoom\") {\n\t\t\t\tinteraction.setActive(enabled);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Renders GeoJSON features on the map using the provided styling configuration.\n\t * @param changes An object containing arrays of created, updated, and unchanged features to render.\n\t * @param styling An object mapping draw modes to feature styling functions\n\t */\n\tpublic render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction) {\n\t\tthis.stylingFunction = () => styling;\n\n\t\tchanges.deletedIds.forEach((id) => {\n\t\t\tthis.removeFeature(id);\n\t\t});\n\n\t\tchanges.updated.forEach((feature) => {\n\t\t\tthis.removeFeature(feature.id as TerraDrawExtend.FeatureId);\n\t\t\tthis.addFeature(feature);\n\t\t});\n\n\t\tchanges.created.forEach((feature) => {\n\t\t\tthis.addFeature(feature);\n\t\t});\n\t}\n\n\t/**\n\t * Clears the map and store of all rendered data layers\n\t * @returns void\n\t * */\n\tpublic clear() {\n\t\tif (this._currentModeCallbacks) {\n\t\t\t// Clean up state first\n\t\t\tthis._currentModeCallbacks.onClear();\n\n\t\t\t// Then clean up rendering\n\t\t\tthis.clearLayers();\n\t\t}\n\t}\n\n\tprivate registeredLayerHandlers:\n\t\t| undefined\n\t\t| { addLayers: () => void; removeLayers: () => void };\n\n\tpublic register(callbacks: TerraDrawExtend.TerraDrawCallbacks) {\n\t\tsuper.register(callbacks);\n\n\t\t// We need to handle the complex case in OpenLayers where adding and removing layers\n\t\t// can change the canvas ordering preventing the event listeners from working correctly\n\t\tif (!this.registeredLayerHandlers) {\n\t\t\tconst layerGroup = this._map.getLayerGroup();\n\t\t\tconst layers = layerGroup.getLayers();\n\n\t\t\tconst removeListeners = () => {\n\t\t\t\tthis._listeners.forEach((listener) => {\n\t\t\t\t\tlistener.unregister();\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tconst addListeners = () => {\n\t\t\t\tthis._listeners = this.getAdapterListeners();\n\n\t\t\t\tthis._listeners.forEach((listener) => {\n\t\t\t\t\tlistener.register();\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tthis.registeredLayerHandlers = {\n\t\t\t\taddLayers: () => {\n\t\t\t\t\tremoveListeners();\n\t\t\t\t\tthis._map.once(\"rendercomplete\", () => {\n\t\t\t\t\t\tif (this._currentModeCallbacks) {\n\t\t\t\t\t\t\taddListeners();\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tremoveLayers: () => {\n\t\t\t\t\tremoveListeners();\n\t\t\t\t\tthis._map.once(\"rendercomplete\", () => {\n\t\t\t\t\t\tif (this._currentModeCallbacks) {\n\t\t\t\t\t\t\taddListeners();\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tlayers.on(\"add\", () => {\n\t\t\t\tremoveListeners();\n\t\t\t\tthis._map.once(\"rendercomplete\", () => {\n\t\t\t\t\tif (this._currentModeCallbacks) {\n\t\t\t\t\t\taddListeners();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tlayers.on(\"remove\", () => {\n\t\t\t\tremoveListeners();\n\t\t\t\tthis._map.once(\"rendercomplete\", () => {\n\t\t\t\t\tif (this._currentModeCallbacks) {\n\t\t\t\t\t\taddListeners();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\tif (this._currentModeCallbacks?.onReady) {\n\t\t\tthis._currentModeCallbacks.onReady();\n\t\t}\n\t}\n\n\tpublic getCoordinatePrecision(): number {\n\t\treturn super.getCoordinatePrecision();\n\t}\n\n\tpublic unregister(): void {\n\t\tif (this.registeredLayerHandlers) {\n\t\t\tconst layerGroup = this._map.getLayerGroup();\n\t\t\tif (layerGroup) {\n\t\t\t\tconst layers = layerGroup.getLayers();\n\n\t\t\t\tif (layers) {\n\t\t\t\t\tlayers.un(\"add\", this.registeredLayerHandlers.addLayers);\n\t\t\t\t\tlayers.un(\"remove\", this.registeredLayerHandlers.removeLayers);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn super.unregister();\n\t}\n}\n"],"names":["_TerraDrawExtend$Terr","TerraDrawOpenLayersAdapter","config","_config$zIndex","_this","call","baseZIndex","stylingFunction","_lib","_map","_container","_projection","_vectorSource","_geoJSONReader","registeredLayerHandlers","map","lib","GeoJSON","_this$_lib$getUserPro","getUserProjection","Projection","code","getViewport","setAttribute","vectorSource","VectorSource","features","zIndex","vectorLayer","VectorLayer","source","style","feature","getStyles","addLayer","_proto","prototype","hexToRGB","hex","r","parseInt","slice","g","b","styling","_this2","geometry","getGeometry","Point","properties","getProperties","mode","type","coordinates","Style","image","Circle","radius","pointWidth","fill","Fill","color","pointColor","stroke","Stroke","pointOutlineColor","width","pointOutlineWidth","LineString","lineStringColor","lineStringWidth","Polygon","_this2$hexToRGB","polygonFillColor","polygonOutlineColor","polygonOutlineWidth","polygonFillOpacity","getType","clearLayers","this","clear","addFeature","olFeature","readFeature","dataProjection","featureProjection","removeFeature","id","deleted","getFeatureById","sortElementsByDOMOrder","elements","sort","a","position","compareDocumentPosition","Node","DOCUMENT_POSITION_FOLLOWING","DOCUMENT_POSITION_PRECEDING","getLngLatFromEvent","event","_this$getMapElementXY","getMapElementXYPosition","x","containerX","y","containerY","unproject","_","getMapEventElement","canvases","Array","from","querySelectorAll","sortedCanvases","length","setDraggability","enabled","getInteractions","forEach","interaction","constructor","name","setActive","project","lng","lat","_this$_map$getPixelFr","getPixelFromCoordinate","fromLonLat","_this$_lib$toLonLat","toLonLat","getCoordinateFromPixel","setCursor","cursor","removeProperty","setDoubleClickToZoom","render","changes","_this3","deletedIds","updated","created","_currentModeCallbacks","onClear","register","callbacks","_this$_currentModeCal","_this4","layers","getLayerGroup","getLayers","removeListeners","_listeners","listener","unregister","addListeners","getAdapterListeners","addLayers","once","removeLayers","on","onReady","getCoordinatePrecision","layerGroup","un","TerraDrawExtend","TerraDrawBaseAdapter"],"mappings":"qMAyCwC,SAAAA,GACvC,SAAAC,EACCC,GAIqC,IAAAC,EAAAC,GAErCA,EAAAJ,EAAAK,KAAMH,KAAAA,IAAQE,MAkCPE,WAAa,IAA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ts"],"sourcesContent":["/**\n * @module terra-draw-openlayers-adapter\n */\nimport {\n\tTerraDrawChanges,\n\tSetCursor,\n\tTerraDrawStylingFunction,\n\tGeoJSONStoreFeatures,\n\tTerraDrawExtend,\n} from \"terra-draw\";\n\nimport Feature, { FeatureLike } from \"ol/Feature\";\nimport GeoJSON from \"ol/format/GeoJSON\";\nimport Map from \"ol/Map\";\nimport Circle from \"ol/style/Circle\";\nimport Fill from \"ol/style/Fill\";\nimport Stroke from \"ol/style/Stroke\";\nimport Style from \"ol/style/Style\";\nimport VectorSource from \"ol/source/Vector\";\nimport { Geometry } from \"ol/geom\";\nimport VectorLayer from \"ol/layer/Vector\";\nimport Projection from \"ol/proj/Projection\";\nimport { fromLonLat, toLonLat, getUserProjection } from \"ol/proj\";\nimport { Coordinate } from \"ol/coordinate\";\nimport { Pixel } from \"ol/pixel\";\nimport { Icon } from \"ol/style\";\n\nexport type InjectableOL = {\n\tIcon: typeof Icon;\n\tFill: typeof Fill;\n\tFeature: typeof Feature;\n\tGeoJSON: typeof GeoJSON;\n\tStyle: typeof Style;\n\tCircle: typeof Circle;\n\tVectorLayer: typeof VectorLayer;\n\tVectorSource: typeof VectorSource;\n\tStroke: typeof Stroke;\n\tProjection: typeof Projection;\n\tgetUserProjection: typeof getUserProjection;\n\tfromLonLat: typeof fromLonLat;\n\ttoLonLat: typeof toLonLat;\n};\n\nexport class TerraDrawOpenLayersAdapter extends TerraDrawExtend.TerraDrawBaseAdapter {\n\tconstructor(\n\t\tconfig: {\n\t\t\tmap: Map;\n\t\t\tlib: InjectableOL;\n\t\t\tzIndex?: number;\n\t\t} & TerraDrawExtend.BaseAdapterConfig,\n\t) {\n\t\tsuper(config);\n\n\t\tthis._map = config.map;\n\t\tthis._lib = config.lib;\n\n\t\tthis._geoJSONReader = new this._lib.GeoJSON();\n\t\tthis._projection = () =>\n\t\t\tthis._lib.getUserProjection() ??\n\t\t\tnew this._lib.Projection({ code: \"EPSG:3857\" });\n\n\t\tthis._container = this._map.getViewport();\n\n\t\t// TODO: Is this the best way to receive keyboard events\n\t\tthis._container.setAttribute(\"tabindex\", \"0\");\n\n\t\tconst vectorSource = new this._lib.VectorSource({\n\t\t\tfeatures: [],\n\t\t}) as unknown as VectorSource<Feature<Geometry>>;\n\n\t\tthis._vectorSource = vectorSource as unknown as VectorSource<\n\t\t\tFeature<Geometry>\n\t\t>;\n\n\t\tthis.baseZIndex = config.zIndex ?? 100000;\n\n\t\tconst vectorLayer = new this._lib.VectorLayer({\n\t\t\tsource: vectorSource as unknown as VectorSource<never>,\n\t\t\tstyle: (feature) => this.getStyles(feature, this.stylingFunction()),\n\t\t\tzIndex: this.baseZIndex,\n\t\t});\n\n\t\tthis._map.addLayer(vectorLayer);\n\t}\n\n\tprivate baseZIndex = 100000;\n\tprivate stylingFunction = () => ({});\n\n\tprivate _lib: InjectableOL;\n\tprivate _map: Map;\n\tprivate _container: HTMLElement;\n\tprivate _projection: () => Projection;\n\tprivate _vectorSource: VectorSource<Feature<Geometry>>;\n\tprivate _geoJSONReader: GeoJSON;\n\n\t/**\n\t * Converts a hexadecimal color to RGB\n\t * @param hex a string of the hexadecimal string\n\t * @returns an object to red green and blue (RGB) color\n\t */\n\tprivate hexToRGB(hex: string): { r: number; g: number; b: number } {\n\t\treturn {\n\t\t\tr: parseInt(hex.slice(1, 3), 16),\n\t\t\tg: parseInt(hex.slice(3, 5), 16),\n\t\t\tb: parseInt(hex.slice(5, 7), 16),\n\t\t};\n\t}\n\n\tprivate getStyles(feature: FeatureLike, styling: TerraDrawStylingFunction) {\n\t\tconst geometry = feature.getGeometry();\n\t\tif (!geometry) {\n\t\t\treturn;\n\t\t}\n\t\tconst key = geometry.getType() as \"Point\" | \"LineString\" | \"Polygon\";\n\n\t\treturn {\n\t\t\tPoint: (feature: FeatureLike) => {\n\t\t\t\tconst properties = feature.getProperties();\n\t\t\t\tconst style = styling[properties.mode]({\n\t\t\t\t\ttype: \"Feature\",\n\t\t\t\t\tgeometry: { type: \"Point\", coordinates: [] },\n\t\t\t\t\tproperties,\n\t\t\t\t});\n\n\t\t\t\tif (style.markerUrl && style.markerWidth && style.markerHeight) {\n\t\t\t\t\treturn new this._lib.Style({\n\t\t\t\t\t\tzIndex: this.baseZIndex + style.zIndex,\n\t\t\t\t\t\timage: new this._lib.Icon({\n\t\t\t\t\t\t\tsrc: style.markerUrl as string,\n\t\t\t\t\t\t\twidth: style.markerWidth,\n\t\t\t\t\t\t\theight: style.markerHeight,\n\t\t\t\t\t\t\tanchor: [0.5, 1], // Anchor the icon at the bottom center\n\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn new this._lib.Style({\n\t\t\t\t\tzIndex: this.baseZIndex + style.zIndex,\n\t\t\t\t\timage: new this._lib.Circle({\n\t\t\t\t\t\tradius: style.pointWidth,\n\t\t\t\t\t\tfill: new this._lib.Fill({\n\t\t\t\t\t\t\tcolor: style.pointColor,\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tstroke: new this._lib.Stroke({\n\t\t\t\t\t\t\tcolor: style.pointOutlineColor,\n\t\t\t\t\t\t\twidth: style.pointOutlineWidth,\n\t\t\t\t\t\t}),\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t},\n\t\t\tLineString: (feature: FeatureLike) => {\n\t\t\t\tconst properties = feature.getProperties();\n\t\t\t\tconst style = styling[properties.mode]({\n\t\t\t\t\ttype: \"Feature\",\n\t\t\t\t\tgeometry: { type: \"LineString\", coordinates: [] },\n\t\t\t\t\tproperties,\n\t\t\t\t});\n\t\t\t\treturn new this._lib.Style({\n\t\t\t\t\tzIndex: style.zIndex,\n\t\t\t\t\tstroke: new this._lib.Stroke({\n\t\t\t\t\t\tcolor: style.lineStringColor,\n\t\t\t\t\t\twidth: style.lineStringWidth,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t},\n\t\t\tPolygon: (feature: FeatureLike) => {\n\t\t\t\tconst properties = feature.getProperties();\n\t\t\t\tconst style = styling[properties.mode]({\n\t\t\t\t\ttype: \"Feature\",\n\t\t\t\t\tgeometry: { type: \"Polygon\", coordinates: [] },\n\n\t\t\t\t\tproperties,\n\t\t\t\t});\n\t\t\t\tconst { r, g, b } = this.hexToRGB(style.polygonFillColor);\n\n\t\t\t\treturn new this._lib.Style({\n\t\t\t\t\tzIndex: style.zIndex,\n\t\t\t\t\tstroke: new this._lib.Stroke({\n\t\t\t\t\t\tcolor: style.polygonOutlineColor,\n\t\t\t\t\t\twidth: style.polygonOutlineWidth,\n\t\t\t\t\t}),\n\t\t\t\t\tfill: new this._lib.Fill({\n\t\t\t\t\t\tcolor: `rgba(${r},${g},${b},${style.polygonFillOpacity})`,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t},\n\t\t}[key](feature);\n\t}\n\n\t/**\n\t * Clears the layers created by the adapter\n\t * @returns void\n\t * */\n\tprivate clearLayers() {\n\t\tif (this._vectorSource) {\n\t\t\tthis._vectorSource.clear();\n\t\t}\n\t}\n\n\tprivate addFeature(feature: GeoJSONStoreFeatures) {\n\t\tconst olFeature = this._geoJSONReader.readFeature(feature, {\n\t\t\tdataProjection: \"EPSG:4326\",\n\t\t\tfeatureProjection: this._projection(),\n\t\t}) as Feature<Geometry>;\n\t\tthis._vectorSource.addFeature(olFeature);\n\t}\n\n\tprivate removeFeature(id: TerraDrawExtend.FeatureId) {\n\t\tconst deleted = this._vectorSource.getFeatureById(id);\n\t\tif (!deleted) {\n\t\t\treturn;\n\t\t}\n\t\tthis._vectorSource.removeFeature(deleted);\n\t}\n\n\t/**\n\t * Sorts an array of DOM elements based on their order in the document, from earliest to latest.\n\t * @param elements - An array of `HTMLElement` objects to be sorted.\n\t * @returns A new array of `HTMLElement` objects sorted by their document order.\n\t */\n\tprivate sortElementsByDOMOrder(elements: HTMLElement[]) {\n\t\t// Sort the elements based on their DOM position\n\t\treturn elements.sort((a, b) => {\n\t\t\tconst position = a.compareDocumentPosition(b);\n\n\t\t\t// If a comes before b in the DOM\n\t\t\tif (position & Node.DOCUMENT_POSITION_FOLLOWING) {\n\t\t\t\treturn -1;\n\t\t\t}\n\n\t\t\t// If a comes after b in the DOM\n\t\t\tif (position & Node.DOCUMENT_POSITION_PRECEDING) {\n\t\t\t\treturn 1;\n\t\t\t}\n\n\t\t\t// If they are the same element\n\t\t\treturn 0;\n\t\t});\n\t}\n\n\t/**\n\t * Returns the longitude and latitude coordinates from a given PointerEvent on the map.\n\t * @param event The PointerEvent or MouseEvent containing the screen coordinates of the pointer.\n\t * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude, or null if the conversion is not possible.\n\t */\n\tpublic getLngLatFromEvent(event: PointerEvent | MouseEvent) {\n\t\tconst { containerX: x, containerY: y } =\n\t\t\tthis.getMapElementXYPosition(event);\n\t\ttry {\n\t\t\treturn this.unproject(x, y);\n\t\t} catch (_) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * Retrieves the HTML element of the OpenLayers element that handles interaction events\n\t * @returns The HTMLElement representing the map container.\n\t */\n\tpublic getMapEventElement() {\n\t\t// Each VectorLayer has a canvas element that is used to render the features, it orders\n\t\t// these in the order they are added to the map. The last canvas is the one that is on top\n\t\t// so we need to add the event listeners to this canvas so that the events are captured.\n\t\tconst canvases = Array.from(this._container.querySelectorAll(\"canvas\"));\n\t\tconst sortedCanvases = this.sortElementsByDOMOrder(\n\t\t\tcanvases,\n\t\t) as HTMLCanvasElement[];\n\t\tconst topCanvas = sortedCanvases[sortedCanvases.length - 1];\n\n\t\treturn topCanvas;\n\t}\n\n\t/**\n\t * Enables or disables the draggable functionality of the map.\n\t * @param enabled Set to true to enable map dragging, or false to disable it.\n\t */\n\tpublic setDraggability(enabled: boolean) {\n\t\tthis._map.getInteractions().forEach((interaction) => {\n\t\t\tif (interaction.constructor.name === \"DragPan\") {\n\t\t\t\tinteraction.setActive(enabled);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Converts longitude and latitude coordinates to pixel coordinates in the map container.\n\t * @param lng The longitude coordinate to project.\n\t * @param lat The latitude coordinate to project.\n\t * @returns An object with 'x' and 'y' properties representing the pixel coordinates within the map container.\n\t */\n\tpublic project(lng: number, lat: number) {\n\t\tconst [x, y] = this._map.getPixelFromCoordinate(\n\t\t\tthis._lib.fromLonLat([lng, lat], this._projection()) as Coordinate,\n\t\t);\n\t\treturn { x, y };\n\t}\n\n\t/**\n\t * Converts pixel coordinates in the map container to longitude and latitude coordinates.\n\t * @param x The x-coordinate in the map container to unproject.\n\t * @param y The y-coordinate in the map container to unproject.\n\t * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude coordinates.\n\t */\n\tpublic unproject(x: number, y: number) {\n\t\tconst [lng, lat] = this._lib.toLonLat(\n\t\t\tthis._map.getCoordinateFromPixel([x, y]) as Pixel,\n\t\t\tthis._projection(),\n\t\t);\n\t\treturn { lng, lat };\n\t}\n\n\t/**\n\t * Sets the cursor style for the map container.\n\t * @param cursor The CSS cursor style to apply, or 'unset' to remove any previously applied cursor style.\n\t */\n\tpublic setCursor(cursor: Parameters<SetCursor>[0]) {\n\t\tif (cursor === \"unset\") {\n\t\t\tthis.getMapEventElement().style.removeProperty(\"cursor\");\n\t\t} else {\n\t\t\tthis.getMapEventElement().style.cursor = cursor;\n\t\t}\n\t}\n\n\t/**\n\t * Enables or disables the double-click to zoom functionality on the map.\n\t * @param enabled Set to true to enable double-click to zoom, or false to disable it.\n\t */\n\tpublic setDoubleClickToZoom(enabled: boolean) {\n\t\tthis._map.getInteractions().forEach(function (interaction) {\n\t\t\tif (interaction.constructor.name === \"DoubleClickZoom\") {\n\t\t\t\tinteraction.setActive(enabled);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Renders GeoJSON features on the map using the provided styling configuration.\n\t * @param changes An object containing arrays of created, updated, and unchanged features to render.\n\t * @param styling An object mapping draw modes to feature styling functions\n\t */\n\tpublic render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction) {\n\t\tthis.stylingFunction = () => styling;\n\n\t\tchanges.deletedIds.forEach((id) => {\n\t\t\tthis.removeFeature(id);\n\t\t});\n\n\t\tchanges.updated.forEach((feature) => {\n\t\t\tthis.removeFeature(feature.id as TerraDrawExtend.FeatureId);\n\t\t\tthis.addFeature(feature);\n\t\t});\n\n\t\tchanges.created.forEach((feature) => {\n\t\t\tthis.addFeature(feature);\n\t\t});\n\t}\n\n\t/**\n\t * Clears the map and store of all rendered data layers\n\t * @returns void\n\t * */\n\tpublic clear() {\n\t\tif (this._currentModeCallbacks) {\n\t\t\t// Clean up state first\n\t\t\tthis._currentModeCallbacks.onClear();\n\n\t\t\t// Then clean up rendering\n\t\t\tthis.clearLayers();\n\t\t}\n\t}\n\n\tprivate registeredLayerHandlers:\n\t\t| undefined\n\t\t| { addLayers: () => void; removeLayers: () => void };\n\n\tpublic register(callbacks: TerraDrawExtend.TerraDrawCallbacks) {\n\t\tsuper.register(callbacks);\n\n\t\t// We need to handle the complex case in OpenLayers where adding and removing layers\n\t\t// can change the canvas ordering preventing the event listeners from working correctly\n\t\tif (!this.registeredLayerHandlers) {\n\t\t\tconst layerGroup = this._map.getLayerGroup();\n\t\t\tconst layers = layerGroup.getLayers();\n\n\t\t\tconst removeListeners = () => {\n\t\t\t\tthis._listeners.forEach((listener) => {\n\t\t\t\t\tlistener.unregister();\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tconst addListeners = () => {\n\t\t\t\tthis._listeners = this.getAdapterListeners();\n\n\t\t\t\tthis._listeners.forEach((listener) => {\n\t\t\t\t\tlistener.register();\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tthis.registeredLayerHandlers = {\n\t\t\t\taddLayers: () => {\n\t\t\t\t\tremoveListeners();\n\t\t\t\t\tthis._map.once(\"rendercomplete\", () => {\n\t\t\t\t\t\tif (this._currentModeCallbacks) {\n\t\t\t\t\t\t\taddListeners();\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tremoveLayers: () => {\n\t\t\t\t\tremoveListeners();\n\t\t\t\t\tthis._map.once(\"rendercomplete\", () => {\n\t\t\t\t\t\tif (this._currentModeCallbacks) {\n\t\t\t\t\t\t\taddListeners();\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tlayers.on(\"add\", () => {\n\t\t\t\tremoveListeners();\n\t\t\t\tthis._map.once(\"rendercomplete\", () => {\n\t\t\t\t\tif (this._currentModeCallbacks) {\n\t\t\t\t\t\taddListeners();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tlayers.on(\"remove\", () => {\n\t\t\t\tremoveListeners();\n\t\t\t\tthis._map.once(\"rendercomplete\", () => {\n\t\t\t\t\tif (this._currentModeCallbacks) {\n\t\t\t\t\t\taddListeners();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\tif (this._currentModeCallbacks?.onReady) {\n\t\t\tthis._currentModeCallbacks.onReady();\n\t\t}\n\t}\n\n\tpublic getCoordinatePrecision(): number {\n\t\treturn super.getCoordinatePrecision();\n\t}\n\n\tpublic unregister(): void {\n\t\tif (this.registeredLayerHandlers) {\n\t\t\tconst layerGroup = this._map.getLayerGroup();\n\t\t\tif (layerGroup) {\n\t\t\t\tconst layers = layerGroup.getLayers();\n\n\t\t\t\tif (layers) {\n\t\t\t\t\tlayers.un(\"add\", this.registeredLayerHandlers.addLayers);\n\t\t\t\t\tlayers.un(\"remove\", this.registeredLayerHandlers.removeLayers);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn super.unregister();\n\t}\n}\n"],"names":["_TerraDrawExtend$Terr","TerraDrawOpenLayersAdapter","config","_config$zIndex","_this","call","this","baseZIndex","stylingFunction","_lib","_map","_container","_projection","_vectorSource","_geoJSONReader","registeredLayerHandlers","map","lib","GeoJSON","_this$_lib$getUserPro","getUserProjection","Projection","code","getViewport","setAttribute","vectorSource","VectorSource","features","zIndex","vectorLayer","VectorLayer","source","style","feature","getStyles","addLayer","_proto","prototype","hexToRGB","hex","r","parseInt","slice","g","b","styling","_this2","geometry","getGeometry","Point","properties","getProperties","mode","type","coordinates","Style","markerUrl","markerWidth","markerHeight","image","Icon","src","width","height","anchor","Circle","radius","pointWidth","fill","Fill","color","pointColor","stroke","Stroke","pointOutlineColor","pointOutlineWidth","LineString","lineStringColor","lineStringWidth","Polygon","_this2$hexToRGB","polygonFillColor","polygonOutlineColor","polygonOutlineWidth","polygonFillOpacity","getType","clearLayers","clear","addFeature","olFeature","readFeature","dataProjection","featureProjection","removeFeature","id","deleted","getFeatureById","sortElementsByDOMOrder","elements","sort","a","position","compareDocumentPosition","Node","DOCUMENT_POSITION_FOLLOWING","DOCUMENT_POSITION_PRECEDING","getLngLatFromEvent","event","_this$getMapElementXY","getMapElementXYPosition","x","containerX","y","containerY","unproject","_","getMapEventElement","canvases","Array","from","querySelectorAll","sortedCanvases","length","setDraggability","enabled","getInteractions","forEach","interaction","constructor","name","setActive","project","lng","lat","_this$_map$getPixelFr","getPixelFromCoordinate","fromLonLat","_this$_lib$toLonLat","toLonLat","getCoordinateFromPixel","setCursor","cursor","removeProperty","setDoubleClickToZoom","render","changes","_this3","deletedIds","updated","created","_currentModeCallbacks","onClear","register","callbacks","_this$_currentModeCal","_this4","layers","getLayerGroup","getLayers","removeListeners","_listeners","listener","unregister","addListeners","getAdapterListeners","addLayers","once","removeLayers","on","onReady","getCoordinatePrecision","layerGroup","un","TerraDrawExtend","TerraDrawBaseAdapter"],"mappings":"qMA2CwC,SAAAA,GACvC,SAAAC,EACCC,GAIqC,IAAAC,EAAAC,GAErCA,EAAAJ,EAAAK,KAAAC,KAAMJ,UAkCCK,WAAa,IAAMH,EACnBI,gBAAkB,WAAO,MAAA,CAAA,CAAE,EAACJ,EAE5BK,UAAI,EAAAL,EACJM,UAAI,EAAAN,EACJO,gBAAU,EAAAP,EACVQ,iBAAWR,EAAAA,EACXS,mBAAaT,EAAAA,EACbU,oBAAcV,EAAAA,EAsRdW,6BA9TPX,EAAAA,EA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";
13
13
  import VectorLayer from "ol/layer/Vector";
14
14
  import Projection from "ol/proj/Projection";
15
15
  import { fromLonLat, toLonLat, getUserProjection } from "ol/proj";
16
+ import { Icon } from "ol/style";
16
17
  export type InjectableOL = {
18
+ Icon: typeof Icon;
17
19
  Fill: typeof Fill;
18
20
  Feature: typeof Feature;
19
21
  GeoJSON: typeof GeoJSON;
@@ -1,2 +1,2 @@
1
- import{TerraDrawExtend as e}from"terra-draw";class t extends e.TerraDrawBaseAdapter{constructor(e){var t;super(e),this.baseZIndex=1e5,this.stylingFunction=()=>({}),this._lib=void 0,this._map=void 0,this._container=void 0,this._projection=void 0,this._vectorSource=void 0,this._geoJSONReader=void 0,this.registeredLayerHandlers=void 0,this._map=e.map,this._lib=e.lib,this._geoJSONReader=new this._lib.GeoJSON,this._projection=()=>{var e;return null!=(e=this._lib.getUserProjection())?e:new this._lib.Projection({code:"EPSG:3857"})},this._container=this._map.getViewport(),this._container.setAttribute("tabindex","0");const r=new this._lib.VectorSource({features:[]});this._vectorSource=r,this.baseZIndex=null!=(t=e.zIndex)?t:1e5;const o=new this._lib.VectorLayer({source:r,style:e=>this.getStyles(e,this.stylingFunction()),zIndex:this.baseZIndex});this._map.addLayer(o)}hexToRGB(e){return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16)}}getStyles(e,t){const r=e.getGeometry();if(r)return{Point:e=>{const r=e.getProperties(),o=t[r.mode]({type:"Feature",geometry:{type:"Point",coordinates:[]},properties:r});return new this._lib.Style({zIndex:this.baseZIndex+o.zIndex,image:new this._lib.Circle({radius:o.pointWidth,fill:new this._lib.Fill({color:o.pointColor}),stroke:new this._lib.Stroke({color:o.pointOutlineColor,width:o.pointOutlineWidth})})})},LineString:e=>{const r=e.getProperties(),o=t[r.mode]({type:"Feature",geometry:{type:"LineString",coordinates:[]},properties:r});return new this._lib.Style({zIndex:o.zIndex,stroke:new this._lib.Stroke({color:o.lineStringColor,width:o.lineStringWidth})})},Polygon:e=>{const r=e.getProperties(),o=t[r.mode]({type:"Feature",geometry:{type:"Polygon",coordinates:[]},properties:r}),{r:i,g:s,b:n}=this.hexToRGB(o.polygonFillColor);return new this._lib.Style({zIndex:o.zIndex,stroke:new this._lib.Stroke({color:o.polygonOutlineColor,width:o.polygonOutlineWidth}),fill:new this._lib.Fill({color:`rgba(${i},${s},${n},${o.polygonFillOpacity})`})})}}[r.getType()](e)}clearLayers(){this._vectorSource&&this._vectorSource.clear()}addFeature(e){const t=this._geoJSONReader.readFeature(e,{dataProjection:"EPSG:4326",featureProjection:this._projection()});this._vectorSource.addFeature(t)}removeFeature(e){const t=this._vectorSource.getFeatureById(e);t&&this._vectorSource.removeFeature(t)}sortElementsByDOMOrder(e){return e.sort((e,t)=>{const r=e.compareDocumentPosition(t);return r&Node.DOCUMENT_POSITION_FOLLOWING?-1:r&Node.DOCUMENT_POSITION_PRECEDING?1:0})}getLngLatFromEvent(e){const{containerX:t,containerY:r}=this.getMapElementXYPosition(e);try{return this.unproject(t,r)}catch(e){return null}}getMapEventElement(){const e=Array.from(this._container.querySelectorAll("canvas")),t=this.sortElementsByDOMOrder(e);return t[t.length-1]}setDraggability(e){this._map.getInteractions().forEach(t=>{"DragPan"===t.constructor.name&&t.setActive(e)})}project(e,t){const[r,o]=this._map.getPixelFromCoordinate(this._lib.fromLonLat([e,t],this._projection()));return{x:r,y:o}}unproject(e,t){const[r,o]=this._lib.toLonLat(this._map.getCoordinateFromPixel([e,t]),this._projection());return{lng:r,lat:o}}setCursor(e){"unset"===e?this.getMapEventElement().style.removeProperty("cursor"):this.getMapEventElement().style.cursor=e}setDoubleClickToZoom(e){this._map.getInteractions().forEach(function(t){"DoubleClickZoom"===t.constructor.name&&t.setActive(e)})}render(e,t){this.stylingFunction=()=>t,e.deletedIds.forEach(e=>{this.removeFeature(e)}),e.updated.forEach(e=>{this.removeFeature(e.id),this.addFeature(e)}),e.created.forEach(e=>{this.addFeature(e)})}clear(){this._currentModeCallbacks&&(this._currentModeCallbacks.onClear(),this.clearLayers())}register(e){var t;if(super.register(e),!this.registeredLayerHandlers){const e=this._map.getLayerGroup().getLayers(),t=()=>{this._listeners.forEach(e=>{e.unregister()})},r=()=>{this._listeners=this.getAdapterListeners(),this._listeners.forEach(e=>{e.register()})};this.registeredLayerHandlers={addLayers:()=>{t(),this._map.once("rendercomplete",()=>{this._currentModeCallbacks&&r()})},removeLayers:()=>{t(),this._map.once("rendercomplete",()=>{this._currentModeCallbacks&&r()})}},e.on("add",()=>{t(),this._map.once("rendercomplete",()=>{this._currentModeCallbacks&&r()})}),e.on("remove",()=>{t(),this._map.once("rendercomplete",()=>{this._currentModeCallbacks&&r()})})}null!=(t=this._currentModeCallbacks)&&t.onReady&&this._currentModeCallbacks.onReady()}getCoordinatePrecision(){return super.getCoordinatePrecision()}unregister(){if(this.registeredLayerHandlers){const e=this._map.getLayerGroup();if(e){const t=e.getLayers();t&&(t.un("add",this.registeredLayerHandlers.addLayers),t.un("remove",this.registeredLayerHandlers.removeLayers))}}return super.unregister()}}export{t as TerraDrawOpenLayersAdapter};
1
+ import{TerraDrawExtend as e}from"terra-draw";class t extends e.TerraDrawBaseAdapter{constructor(e){var t;super(e),this.baseZIndex=1e5,this.stylingFunction=()=>({}),this._lib=void 0,this._map=void 0,this._container=void 0,this._projection=void 0,this._vectorSource=void 0,this._geoJSONReader=void 0,this.registeredLayerHandlers=void 0,this._map=e.map,this._lib=e.lib,this._geoJSONReader=new this._lib.GeoJSON,this._projection=()=>{var e;return null!=(e=this._lib.getUserProjection())?e:new this._lib.Projection({code:"EPSG:3857"})},this._container=this._map.getViewport(),this._container.setAttribute("tabindex","0");const r=new this._lib.VectorSource({features:[]});this._vectorSource=r,this.baseZIndex=null!=(t=e.zIndex)?t:1e5;const i=new this._lib.VectorLayer({source:r,style:e=>this.getStyles(e,this.stylingFunction()),zIndex:this.baseZIndex});this._map.addLayer(i)}hexToRGB(e){return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16)}}getStyles(e,t){const r=e.getGeometry();if(r)return{Point:e=>{const r=e.getProperties(),i=t[r.mode]({type:"Feature",geometry:{type:"Point",coordinates:[]},properties:r});return new this._lib.Style(i.markerUrl&&i.markerWidth&&i.markerHeight?{zIndex:this.baseZIndex+i.zIndex,image:new this._lib.Icon({src:i.markerUrl,width:i.markerWidth,height:i.markerHeight,anchor:[.5,1]})}:{zIndex:this.baseZIndex+i.zIndex,image:new this._lib.Circle({radius:i.pointWidth,fill:new this._lib.Fill({color:i.pointColor}),stroke:new this._lib.Stroke({color:i.pointOutlineColor,width:i.pointOutlineWidth})})})},LineString:e=>{const r=e.getProperties(),i=t[r.mode]({type:"Feature",geometry:{type:"LineString",coordinates:[]},properties:r});return new this._lib.Style({zIndex:i.zIndex,stroke:new this._lib.Stroke({color:i.lineStringColor,width:i.lineStringWidth})})},Polygon:e=>{const r=e.getProperties(),i=t[r.mode]({type:"Feature",geometry:{type:"Polygon",coordinates:[]},properties:r}),{r:o,g:s,b:n}=this.hexToRGB(i.polygonFillColor);return new this._lib.Style({zIndex:i.zIndex,stroke:new this._lib.Stroke({color:i.polygonOutlineColor,width:i.polygonOutlineWidth}),fill:new this._lib.Fill({color:`rgba(${o},${s},${n},${i.polygonFillOpacity})`})})}}[r.getType()](e)}clearLayers(){this._vectorSource&&this._vectorSource.clear()}addFeature(e){const t=this._geoJSONReader.readFeature(e,{dataProjection:"EPSG:4326",featureProjection:this._projection()});this._vectorSource.addFeature(t)}removeFeature(e){const t=this._vectorSource.getFeatureById(e);t&&this._vectorSource.removeFeature(t)}sortElementsByDOMOrder(e){return e.sort((e,t)=>{const r=e.compareDocumentPosition(t);return r&Node.DOCUMENT_POSITION_FOLLOWING?-1:r&Node.DOCUMENT_POSITION_PRECEDING?1:0})}getLngLatFromEvent(e){const{containerX:t,containerY:r}=this.getMapElementXYPosition(e);try{return this.unproject(t,r)}catch(e){return null}}getMapEventElement(){const e=Array.from(this._container.querySelectorAll("canvas")),t=this.sortElementsByDOMOrder(e);return t[t.length-1]}setDraggability(e){this._map.getInteractions().forEach(t=>{"DragPan"===t.constructor.name&&t.setActive(e)})}project(e,t){const[r,i]=this._map.getPixelFromCoordinate(this._lib.fromLonLat([e,t],this._projection()));return{x:r,y:i}}unproject(e,t){const[r,i]=this._lib.toLonLat(this._map.getCoordinateFromPixel([e,t]),this._projection());return{lng:r,lat:i}}setCursor(e){"unset"===e?this.getMapEventElement().style.removeProperty("cursor"):this.getMapEventElement().style.cursor=e}setDoubleClickToZoom(e){this._map.getInteractions().forEach(function(t){"DoubleClickZoom"===t.constructor.name&&t.setActive(e)})}render(e,t){this.stylingFunction=()=>t,e.deletedIds.forEach(e=>{this.removeFeature(e)}),e.updated.forEach(e=>{this.removeFeature(e.id),this.addFeature(e)}),e.created.forEach(e=>{this.addFeature(e)})}clear(){this._currentModeCallbacks&&(this._currentModeCallbacks.onClear(),this.clearLayers())}register(e){var t;if(super.register(e),!this.registeredLayerHandlers){const e=this._map.getLayerGroup().getLayers(),t=()=>{this._listeners.forEach(e=>{e.unregister()})},r=()=>{this._listeners=this.getAdapterListeners(),this._listeners.forEach(e=>{e.register()})};this.registeredLayerHandlers={addLayers:()=>{t(),this._map.once("rendercomplete",()=>{this._currentModeCallbacks&&r()})},removeLayers:()=>{t(),this._map.once("rendercomplete",()=>{this._currentModeCallbacks&&r()})}},e.on("add",()=>{t(),this._map.once("rendercomplete",()=>{this._currentModeCallbacks&&r()})}),e.on("remove",()=>{t(),this._map.once("rendercomplete",()=>{this._currentModeCallbacks&&r()})})}null!=(t=this._currentModeCallbacks)&&t.onReady&&this._currentModeCallbacks.onReady()}getCoordinatePrecision(){return super.getCoordinatePrecision()}unregister(){if(this.registeredLayerHandlers){const e=this._map.getLayerGroup();if(e){const t=e.getLayers();t&&(t.un("add",this.registeredLayerHandlers.addLayers),t.un("remove",this.registeredLayerHandlers.removeLayers))}}return super.unregister()}}export{t as TerraDrawOpenLayersAdapter};
2
2
  //# sourceMappingURL=terra-draw-openlayers-adapter.modern.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"terra-draw-openlayers-adapter.modern.js","sources":["../src/terra-draw-openlayers-adapter.ts"],"sourcesContent":["/**\n * @module terra-draw-openlayers-adapter\n */\nimport {\n\tTerraDrawChanges,\n\tSetCursor,\n\tTerraDrawStylingFunction,\n\tGeoJSONStoreFeatures,\n\tTerraDrawExtend,\n} from \"terra-draw\";\n\nimport Feature, { FeatureLike } from \"ol/Feature\";\nimport GeoJSON from \"ol/format/GeoJSON\";\nimport Map from \"ol/Map\";\nimport Circle from \"ol/style/Circle\";\nimport Fill from \"ol/style/Fill\";\nimport Stroke from \"ol/style/Stroke\";\nimport Style from \"ol/style/Style\";\nimport VectorSource from \"ol/source/Vector\";\nimport { Geometry } from \"ol/geom\";\nimport VectorLayer from \"ol/layer/Vector\";\nimport Projection from \"ol/proj/Projection\";\nimport { fromLonLat, toLonLat, getUserProjection } from \"ol/proj\";\nimport { Coordinate } from \"ol/coordinate\";\nimport { Pixel } from \"ol/pixel\";\n\nexport type InjectableOL = {\n\tFill: typeof Fill;\n\tFeature: typeof Feature;\n\tGeoJSON: typeof GeoJSON;\n\tStyle: typeof Style;\n\tCircle: typeof Circle;\n\tVectorLayer: typeof VectorLayer;\n\tVectorSource: typeof VectorSource;\n\tStroke: typeof Stroke;\n\tProjection: typeof Projection;\n\tgetUserProjection: typeof getUserProjection;\n\tfromLonLat: typeof fromLonLat;\n\ttoLonLat: typeof toLonLat;\n};\n\nexport class TerraDrawOpenLayersAdapter extends TerraDrawExtend.TerraDrawBaseAdapter {\n\tconstructor(\n\t\tconfig: {\n\t\t\tmap: Map;\n\t\t\tlib: InjectableOL;\n\t\t\tzIndex?: number;\n\t\t} & TerraDrawExtend.BaseAdapterConfig,\n\t) {\n\t\tsuper(config);\n\n\t\tthis._map = config.map;\n\t\tthis._lib = config.lib;\n\n\t\tthis._geoJSONReader = new this._lib.GeoJSON();\n\t\tthis._projection = () =>\n\t\t\tthis._lib.getUserProjection() ??\n\t\t\tnew this._lib.Projection({ code: \"EPSG:3857\" });\n\n\t\tthis._container = this._map.getViewport();\n\n\t\t// TODO: Is this the best way to receive keyboard events\n\t\tthis._container.setAttribute(\"tabindex\", \"0\");\n\n\t\tconst vectorSource = new this._lib.VectorSource({\n\t\t\tfeatures: [],\n\t\t}) as unknown as VectorSource<Feature<Geometry>>;\n\n\t\tthis._vectorSource = vectorSource as unknown as VectorSource<\n\t\t\tFeature<Geometry>\n\t\t>;\n\n\t\tthis.baseZIndex = config.zIndex ?? 100000;\n\n\t\tconst vectorLayer = new this._lib.VectorLayer({\n\t\t\tsource: vectorSource as unknown as VectorSource<never>,\n\t\t\tstyle: (feature) => this.getStyles(feature, this.stylingFunction()),\n\t\t\tzIndex: this.baseZIndex,\n\t\t});\n\n\t\tthis._map.addLayer(vectorLayer);\n\t}\n\n\tprivate baseZIndex = 100000;\n\tprivate stylingFunction = () => ({});\n\n\tprivate _lib: InjectableOL;\n\tprivate _map: Map;\n\tprivate _container: HTMLElement;\n\tprivate _projection: () => Projection;\n\tprivate _vectorSource: VectorSource<Feature<Geometry>>;\n\tprivate _geoJSONReader: GeoJSON;\n\n\t/**\n\t * Converts a hexadecimal color to RGB\n\t * @param hex a string of the hexadecimal string\n\t * @returns an object to red green and blue (RGB) color\n\t */\n\tprivate hexToRGB(hex: string): { r: number; g: number; b: number } {\n\t\treturn {\n\t\t\tr: parseInt(hex.slice(1, 3), 16),\n\t\t\tg: parseInt(hex.slice(3, 5), 16),\n\t\t\tb: parseInt(hex.slice(5, 7), 16),\n\t\t};\n\t}\n\n\tprivate getStyles(feature: FeatureLike, styling: TerraDrawStylingFunction) {\n\t\tconst geometry = feature.getGeometry();\n\t\tif (!geometry) {\n\t\t\treturn;\n\t\t}\n\t\tconst key = geometry.getType() as \"Point\" | \"LineString\" | \"Polygon\";\n\n\t\treturn {\n\t\t\tPoint: (feature: FeatureLike) => {\n\t\t\t\tconst properties = feature.getProperties();\n\t\t\t\tconst style = styling[properties.mode]({\n\t\t\t\t\ttype: \"Feature\",\n\t\t\t\t\tgeometry: { type: \"Point\", coordinates: [] },\n\t\t\t\t\tproperties,\n\t\t\t\t});\n\t\t\t\treturn new this._lib.Style({\n\t\t\t\t\tzIndex: this.baseZIndex + style.zIndex,\n\t\t\t\t\timage: new this._lib.Circle({\n\t\t\t\t\t\tradius: style.pointWidth,\n\t\t\t\t\t\tfill: new this._lib.Fill({\n\t\t\t\t\t\t\tcolor: style.pointColor,\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tstroke: new this._lib.Stroke({\n\t\t\t\t\t\t\tcolor: style.pointOutlineColor,\n\t\t\t\t\t\t\twidth: style.pointOutlineWidth,\n\t\t\t\t\t\t}),\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t},\n\t\t\tLineString: (feature: FeatureLike) => {\n\t\t\t\tconst properties = feature.getProperties();\n\t\t\t\tconst style = styling[properties.mode]({\n\t\t\t\t\ttype: \"Feature\",\n\t\t\t\t\tgeometry: { type: \"LineString\", coordinates: [] },\n\t\t\t\t\tproperties,\n\t\t\t\t});\n\t\t\t\treturn new this._lib.Style({\n\t\t\t\t\tzIndex: style.zIndex,\n\t\t\t\t\tstroke: new this._lib.Stroke({\n\t\t\t\t\t\tcolor: style.lineStringColor,\n\t\t\t\t\t\twidth: style.lineStringWidth,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t},\n\t\t\tPolygon: (feature: FeatureLike) => {\n\t\t\t\tconst properties = feature.getProperties();\n\t\t\t\tconst style = styling[properties.mode]({\n\t\t\t\t\ttype: \"Feature\",\n\t\t\t\t\tgeometry: { type: \"Polygon\", coordinates: [] },\n\n\t\t\t\t\tproperties,\n\t\t\t\t});\n\t\t\t\tconst { r, g, b } = this.hexToRGB(style.polygonFillColor);\n\n\t\t\t\treturn new this._lib.Style({\n\t\t\t\t\tzIndex: style.zIndex,\n\t\t\t\t\tstroke: new this._lib.Stroke({\n\t\t\t\t\t\tcolor: style.polygonOutlineColor,\n\t\t\t\t\t\twidth: style.polygonOutlineWidth,\n\t\t\t\t\t}),\n\t\t\t\t\tfill: new this._lib.Fill({\n\t\t\t\t\t\tcolor: `rgba(${r},${g},${b},${style.polygonFillOpacity})`,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t},\n\t\t}[key](feature);\n\t}\n\n\t/**\n\t * Clears the layers created by the adapter\n\t * @returns void\n\t * */\n\tprivate clearLayers() {\n\t\tif (this._vectorSource) {\n\t\t\tthis._vectorSource.clear();\n\t\t}\n\t}\n\n\tprivate addFeature(feature: GeoJSONStoreFeatures) {\n\t\tconst olFeature = this._geoJSONReader.readFeature(feature, {\n\t\t\tdataProjection: \"EPSG:4326\",\n\t\t\tfeatureProjection: this._projection(),\n\t\t}) as Feature<Geometry>;\n\t\tthis._vectorSource.addFeature(olFeature);\n\t}\n\n\tprivate removeFeature(id: TerraDrawExtend.FeatureId) {\n\t\tconst deleted = this._vectorSource.getFeatureById(id);\n\t\tif (!deleted) {\n\t\t\treturn;\n\t\t}\n\t\tthis._vectorSource.removeFeature(deleted);\n\t}\n\n\t/**\n\t * Sorts an array of DOM elements based on their order in the document, from earliest to latest.\n\t * @param elements - An array of `HTMLElement` objects to be sorted.\n\t * @returns A new array of `HTMLElement` objects sorted by their document order.\n\t */\n\tprivate sortElementsByDOMOrder(elements: HTMLElement[]) {\n\t\t// Sort the elements based on their DOM position\n\t\treturn elements.sort((a, b) => {\n\t\t\tconst position = a.compareDocumentPosition(b);\n\n\t\t\t// If a comes before b in the DOM\n\t\t\tif (position & Node.DOCUMENT_POSITION_FOLLOWING) {\n\t\t\t\treturn -1;\n\t\t\t}\n\n\t\t\t// If a comes after b in the DOM\n\t\t\tif (position & Node.DOCUMENT_POSITION_PRECEDING) {\n\t\t\t\treturn 1;\n\t\t\t}\n\n\t\t\t// If they are the same element\n\t\t\treturn 0;\n\t\t});\n\t}\n\n\t/**\n\t * Returns the longitude and latitude coordinates from a given PointerEvent on the map.\n\t * @param event The PointerEvent or MouseEvent containing the screen coordinates of the pointer.\n\t * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude, or null if the conversion is not possible.\n\t */\n\tpublic getLngLatFromEvent(event: PointerEvent | MouseEvent) {\n\t\tconst { containerX: x, containerY: y } =\n\t\t\tthis.getMapElementXYPosition(event);\n\t\ttry {\n\t\t\treturn this.unproject(x, y);\n\t\t} catch (_) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * Retrieves the HTML element of the OpenLayers element that handles interaction events\n\t * @returns The HTMLElement representing the map container.\n\t */\n\tpublic getMapEventElement() {\n\t\t// Each VectorLayer has a canvas element that is used to render the features, it orders\n\t\t// these in the order they are added to the map. The last canvas is the one that is on top\n\t\t// so we need to add the event listeners to this canvas so that the events are captured.\n\t\tconst canvases = Array.from(this._container.querySelectorAll(\"canvas\"));\n\t\tconst sortedCanvases = this.sortElementsByDOMOrder(\n\t\t\tcanvases,\n\t\t) as HTMLCanvasElement[];\n\t\tconst topCanvas = sortedCanvases[sortedCanvases.length - 1];\n\n\t\treturn topCanvas;\n\t}\n\n\t/**\n\t * Enables or disables the draggable functionality of the map.\n\t * @param enabled Set to true to enable map dragging, or false to disable it.\n\t */\n\tpublic setDraggability(enabled: boolean) {\n\t\tthis._map.getInteractions().forEach((interaction) => {\n\t\t\tif (interaction.constructor.name === \"DragPan\") {\n\t\t\t\tinteraction.setActive(enabled);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Converts longitude and latitude coordinates to pixel coordinates in the map container.\n\t * @param lng The longitude coordinate to project.\n\t * @param lat The latitude coordinate to project.\n\t * @returns An object with 'x' and 'y' properties representing the pixel coordinates within the map container.\n\t */\n\tpublic project(lng: number, lat: number) {\n\t\tconst [x, y] = this._map.getPixelFromCoordinate(\n\t\t\tthis._lib.fromLonLat([lng, lat], this._projection()) as Coordinate,\n\t\t);\n\t\treturn { x, y };\n\t}\n\n\t/**\n\t * Converts pixel coordinates in the map container to longitude and latitude coordinates.\n\t * @param x The x-coordinate in the map container to unproject.\n\t * @param y The y-coordinate in the map container to unproject.\n\t * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude coordinates.\n\t */\n\tpublic unproject(x: number, y: number) {\n\t\tconst [lng, lat] = this._lib.toLonLat(\n\t\t\tthis._map.getCoordinateFromPixel([x, y]) as Pixel,\n\t\t\tthis._projection(),\n\t\t);\n\t\treturn { lng, lat };\n\t}\n\n\t/**\n\t * Sets the cursor style for the map container.\n\t * @param cursor The CSS cursor style to apply, or 'unset' to remove any previously applied cursor style.\n\t */\n\tpublic setCursor(cursor: Parameters<SetCursor>[0]) {\n\t\tif (cursor === \"unset\") {\n\t\t\tthis.getMapEventElement().style.removeProperty(\"cursor\");\n\t\t} else {\n\t\t\tthis.getMapEventElement().style.cursor = cursor;\n\t\t}\n\t}\n\n\t/**\n\t * Enables or disables the double-click to zoom functionality on the map.\n\t * @param enabled Set to true to enable double-click to zoom, or false to disable it.\n\t */\n\tpublic setDoubleClickToZoom(enabled: boolean) {\n\t\tthis._map.getInteractions().forEach(function (interaction) {\n\t\t\tif (interaction.constructor.name === \"DoubleClickZoom\") {\n\t\t\t\tinteraction.setActive(enabled);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Renders GeoJSON features on the map using the provided styling configuration.\n\t * @param changes An object containing arrays of created, updated, and unchanged features to render.\n\t * @param styling An object mapping draw modes to feature styling functions\n\t */\n\tpublic render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction) {\n\t\tthis.stylingFunction = () => styling;\n\n\t\tchanges.deletedIds.forEach((id) => {\n\t\t\tthis.removeFeature(id);\n\t\t});\n\n\t\tchanges.updated.forEach((feature) => {\n\t\t\tthis.removeFeature(feature.id as TerraDrawExtend.FeatureId);\n\t\t\tthis.addFeature(feature);\n\t\t});\n\n\t\tchanges.created.forEach((feature) => {\n\t\t\tthis.addFeature(feature);\n\t\t});\n\t}\n\n\t/**\n\t * Clears the map and store of all rendered data layers\n\t * @returns void\n\t * */\n\tpublic clear() {\n\t\tif (this._currentModeCallbacks) {\n\t\t\t// Clean up state first\n\t\t\tthis._currentModeCallbacks.onClear();\n\n\t\t\t// Then clean up rendering\n\t\t\tthis.clearLayers();\n\t\t}\n\t}\n\n\tprivate registeredLayerHandlers:\n\t\t| undefined\n\t\t| { addLayers: () => void; removeLayers: () => void };\n\n\tpublic register(callbacks: TerraDrawExtend.TerraDrawCallbacks) {\n\t\tsuper.register(callbacks);\n\n\t\t// We need to handle the complex case in OpenLayers where adding and removing layers\n\t\t// can change the canvas ordering preventing the event listeners from working correctly\n\t\tif (!this.registeredLayerHandlers) {\n\t\t\tconst layerGroup = this._map.getLayerGroup();\n\t\t\tconst layers = layerGroup.getLayers();\n\n\t\t\tconst removeListeners = () => {\n\t\t\t\tthis._listeners.forEach((listener) => {\n\t\t\t\t\tlistener.unregister();\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tconst addListeners = () => {\n\t\t\t\tthis._listeners = this.getAdapterListeners();\n\n\t\t\t\tthis._listeners.forEach((listener) => {\n\t\t\t\t\tlistener.register();\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tthis.registeredLayerHandlers = {\n\t\t\t\taddLayers: () => {\n\t\t\t\t\tremoveListeners();\n\t\t\t\t\tthis._map.once(\"rendercomplete\", () => {\n\t\t\t\t\t\tif (this._currentModeCallbacks) {\n\t\t\t\t\t\t\taddListeners();\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tremoveLayers: () => {\n\t\t\t\t\tremoveListeners();\n\t\t\t\t\tthis._map.once(\"rendercomplete\", () => {\n\t\t\t\t\t\tif (this._currentModeCallbacks) {\n\t\t\t\t\t\t\taddListeners();\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tlayers.on(\"add\", () => {\n\t\t\t\tremoveListeners();\n\t\t\t\tthis._map.once(\"rendercomplete\", () => {\n\t\t\t\t\tif (this._currentModeCallbacks) {\n\t\t\t\t\t\taddListeners();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tlayers.on(\"remove\", () => {\n\t\t\t\tremoveListeners();\n\t\t\t\tthis._map.once(\"rendercomplete\", () => {\n\t\t\t\t\tif (this._currentModeCallbacks) {\n\t\t\t\t\t\taddListeners();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\tif (this._currentModeCallbacks?.onReady) {\n\t\t\tthis._currentModeCallbacks.onReady();\n\t\t}\n\t}\n\n\tpublic getCoordinatePrecision(): number {\n\t\treturn super.getCoordinatePrecision();\n\t}\n\n\tpublic unregister(): void {\n\t\tif (this.registeredLayerHandlers) {\n\t\t\tconst layerGroup = this._map.getLayerGroup();\n\t\t\tif (layerGroup) {\n\t\t\t\tconst layers = layerGroup.getLayers();\n\n\t\t\t\tif (layers) {\n\t\t\t\t\tlayers.un(\"add\", this.registeredLayerHandlers.addLayers);\n\t\t\t\t\tlayers.un(\"remove\", this.registeredLayerHandlers.removeLayers);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn super.unregister();\n\t}\n}\n"],"names":["TerraDrawOpenLayersAdapter","TerraDrawExtend","TerraDrawBaseAdapter","constructor","config","_config$zIndex","super","this","baseZIndex","stylingFunction","_lib","_map","_container","_projection","_vectorSource","_geoJSONReader","registeredLayerHandlers","map","lib","GeoJSON","_this$_lib$getUserPro","getUserProjection","Projection","code","getViewport","setAttribute","vectorSource","VectorSource","features","zIndex","vectorLayer","VectorLayer","source","style","feature","getStyles","addLayer","hexToRGB","hex","r","parseInt","slice","g","b","styling","geometry","getGeometry","Point","properties","getProperties","mode","type","coordinates","Style","image","Circle","radius","pointWidth","fill","Fill","color","pointColor","stroke","Stroke","pointOutlineColor","width","pointOutlineWidth","LineString","lineStringColor","lineStringWidth","Polygon","polygonFillColor","polygonOutlineColor","polygonOutlineWidth","polygonFillOpacity","getType","clearLayers","clear","addFeature","olFeature","readFeature","dataProjection","featureProjection","removeFeature","id","deleted","getFeatureById","sortElementsByDOMOrder","elements","sort","a","position","compareDocumentPosition","Node","DOCUMENT_POSITION_FOLLOWING","DOCUMENT_POSITION_PRECEDING","getLngLatFromEvent","event","containerX","x","containerY","y","getMapElementXYPosition","unproject","_","getMapEventElement","canvases","Array","from","querySelectorAll","sortedCanvases","length","setDraggability","enabled","getInteractions","forEach","interaction","name","setActive","project","lng","lat","getPixelFromCoordinate","fromLonLat","toLonLat","getCoordinateFromPixel","setCursor","cursor","removeProperty","setDoubleClickToZoom","render","changes","deletedIds","updated","created","_currentModeCallbacks","onClear","register","callbacks","_this$_currentModeCal","layers","getLayerGroup","getLayers","removeListeners","_listeners","listener","unregister","addListeners","getAdapterListeners","addLayers","once","removeLayers","on","onReady","getCoordinatePrecision","layerGroup","un"],"mappings":"6CAyCa,MAAAA,UAAmCC,EAAgBC,qBAC/DC,WAAAA,CACCC,GAIqC,IAAAC,EAErCC,MAAMF,GAAQG,KAkCPC,WAAa,IAAMD,KACnBE,gBAAkB,KAAO,CAAE,QAE3BC,UAAI,EAAAH,KACJI,UACAC,EAAAA,KAAAA,gBACAC,EAAAA,KAAAA,iBACAC,EAAAA,KAAAA,0BACAC,oBAAc,EAAAR,KAyQdS,6BAjTP,EAAAT,KAAKI,KAAOP,EAAOa,IACnBV,KAAKG,KAAON,EAAOc,IAEnBX,KAAKQ,eAAiB,IAAQR,KAACG,KAAKS,QACpCZ,KAAKM,YAAc,KAAA,IAAAO,EAAAA,OACWA,OADXA,EAClBb,KAAKG,KAAKW,qBAAmBD,EAC7B,IAAIb,KAAKG,KAAKY,WAAW,CAAEC,KAAM,aAAa,EAE/ChB,KAAKK,WAAaL,KAAKI,KAAKa,cAG5BjB,KAAKK,WAAWa,aAAa,WAAY,KAEzC,MAAMC,EAAe,IAAQnB,KAACG,KAAKiB,aAAa,CAC/CC,SAAU,KAGXrB,KAAKO,cAAgBY,EAIrBnB,KAAKC,WAA0B,OAAhBH,EAAGD,EAAOyB,QAAM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,CAClC,MACM4H,EADarI,KAAKI,KAAKkI,gBACHC,YAEpBC,EAAkBA,KACvBxI,KAAKyI,WAAW7B,QAAS8B,IACxBA,EAASC,cACT,EAGIC,EAAeA,KACpB5I,KAAKyI,WAAazI,KAAK6I,sBAEvB7I,KAAKyI,WAAW7B,QAAS8B,IACxBA,EAASR,YACT,EAGFlI,KAAKS,wBAA0B,CAC9BqI,UAAWA,KACVN,IACAxI,KAAKI,KAAK2I,KAAK,iBAAkB,KAC5B/I,KAAKgI,uBACRY,GACD,EAEF,EACAI,aAAcA,KACbR,IACAxI,KAAKI,KAAK2I,KAAK,iBAAkB,KAC5B/I,KAAKgI,uBACRY,GACD,KAKHP,EAAOY,GAAG,MAAO,KAChBT,IACAxI,KAAKI,KAAK2I,KAAK,iBAAkB,KAC5B/I,KAAKgI,uBACRY,GACD,EAEF,GAEAP,EAAOY,GAAG,SAAU,KACnBT,IACAxI,KAAKI,KAAK2I,KAAK,iBAAkB,KAC5B/I,KAAKgI,uBACRY,GACD,IAGH,CAEIR,OAAJA,EAAIpI,KAAKgI,wBAALI,EAA4Bc,SAC/BlJ,KAAKgI,sBAAsBkB,SAE7B,CAEOC,sBAAAA,GACN,aAAaA,wBACd,CAEOR,UAAAA,GACN,GAAI3I,KAAKS,wBAAyB,CACjC,MAAM2I,EAAapJ,KAAKI,KAAKkI,gBAC7B,GAAIc,EAAY,CACf,MAAMf,EAASe,EAAWb,YAEtBF,IACHA,EAAOgB,GAAG,MAAOrJ,KAAKS,wBAAwBqI,WAC9CT,EAAOgB,GAAG,SAAUrJ,KAAKS,wBAAwBuI,cAEnD,CACD,CAEA,aAAaL,YACd"}
1
+ {"version":3,"file":"terra-draw-openlayers-adapter.modern.js","sources":["../src/terra-draw-openlayers-adapter.ts"],"sourcesContent":["/**\n * @module terra-draw-openlayers-adapter\n */\nimport {\n\tTerraDrawChanges,\n\tSetCursor,\n\tTerraDrawStylingFunction,\n\tGeoJSONStoreFeatures,\n\tTerraDrawExtend,\n} from \"terra-draw\";\n\nimport Feature, { FeatureLike } from \"ol/Feature\";\nimport GeoJSON from \"ol/format/GeoJSON\";\nimport Map from \"ol/Map\";\nimport Circle from \"ol/style/Circle\";\nimport Fill from \"ol/style/Fill\";\nimport Stroke from \"ol/style/Stroke\";\nimport Style from \"ol/style/Style\";\nimport VectorSource from \"ol/source/Vector\";\nimport { Geometry } from \"ol/geom\";\nimport VectorLayer from \"ol/layer/Vector\";\nimport Projection from \"ol/proj/Projection\";\nimport { fromLonLat, toLonLat, getUserProjection } from \"ol/proj\";\nimport { Coordinate } from \"ol/coordinate\";\nimport { Pixel } from \"ol/pixel\";\nimport { Icon } from \"ol/style\";\n\nexport type InjectableOL = {\n\tIcon: typeof Icon;\n\tFill: typeof Fill;\n\tFeature: typeof Feature;\n\tGeoJSON: typeof GeoJSON;\n\tStyle: typeof Style;\n\tCircle: typeof Circle;\n\tVectorLayer: typeof VectorLayer;\n\tVectorSource: typeof VectorSource;\n\tStroke: typeof Stroke;\n\tProjection: typeof Projection;\n\tgetUserProjection: typeof getUserProjection;\n\tfromLonLat: typeof fromLonLat;\n\ttoLonLat: typeof toLonLat;\n};\n\nexport class TerraDrawOpenLayersAdapter extends TerraDrawExtend.TerraDrawBaseAdapter {\n\tconstructor(\n\t\tconfig: {\n\t\t\tmap: Map;\n\t\t\tlib: InjectableOL;\n\t\t\tzIndex?: number;\n\t\t} & TerraDrawExtend.BaseAdapterConfig,\n\t) {\n\t\tsuper(config);\n\n\t\tthis._map = config.map;\n\t\tthis._lib = config.lib;\n\n\t\tthis._geoJSONReader = new this._lib.GeoJSON();\n\t\tthis._projection = () =>\n\t\t\tthis._lib.getUserProjection() ??\n\t\t\tnew this._lib.Projection({ code: \"EPSG:3857\" });\n\n\t\tthis._container = this._map.getViewport();\n\n\t\t// TODO: Is this the best way to receive keyboard events\n\t\tthis._container.setAttribute(\"tabindex\", \"0\");\n\n\t\tconst vectorSource = new this._lib.VectorSource({\n\t\t\tfeatures: [],\n\t\t}) as unknown as VectorSource<Feature<Geometry>>;\n\n\t\tthis._vectorSource = vectorSource as unknown as VectorSource<\n\t\t\tFeature<Geometry>\n\t\t>;\n\n\t\tthis.baseZIndex = config.zIndex ?? 100000;\n\n\t\tconst vectorLayer = new this._lib.VectorLayer({\n\t\t\tsource: vectorSource as unknown as VectorSource<never>,\n\t\t\tstyle: (feature) => this.getStyles(feature, this.stylingFunction()),\n\t\t\tzIndex: this.baseZIndex,\n\t\t});\n\n\t\tthis._map.addLayer(vectorLayer);\n\t}\n\n\tprivate baseZIndex = 100000;\n\tprivate stylingFunction = () => ({});\n\n\tprivate _lib: InjectableOL;\n\tprivate _map: Map;\n\tprivate _container: HTMLElement;\n\tprivate _projection: () => Projection;\n\tprivate _vectorSource: VectorSource<Feature<Geometry>>;\n\tprivate _geoJSONReader: GeoJSON;\n\n\t/**\n\t * Converts a hexadecimal color to RGB\n\t * @param hex a string of the hexadecimal string\n\t * @returns an object to red green and blue (RGB) color\n\t */\n\tprivate hexToRGB(hex: string): { r: number; g: number; b: number } {\n\t\treturn {\n\t\t\tr: parseInt(hex.slice(1, 3), 16),\n\t\t\tg: parseInt(hex.slice(3, 5), 16),\n\t\t\tb: parseInt(hex.slice(5, 7), 16),\n\t\t};\n\t}\n\n\tprivate getStyles(feature: FeatureLike, styling: TerraDrawStylingFunction) {\n\t\tconst geometry = feature.getGeometry();\n\t\tif (!geometry) {\n\t\t\treturn;\n\t\t}\n\t\tconst key = geometry.getType() as \"Point\" | \"LineString\" | \"Polygon\";\n\n\t\treturn {\n\t\t\tPoint: (feature: FeatureLike) => {\n\t\t\t\tconst properties = feature.getProperties();\n\t\t\t\tconst style = styling[properties.mode]({\n\t\t\t\t\ttype: \"Feature\",\n\t\t\t\t\tgeometry: { type: \"Point\", coordinates: [] },\n\t\t\t\t\tproperties,\n\t\t\t\t});\n\n\t\t\t\tif (style.markerUrl && style.markerWidth && style.markerHeight) {\n\t\t\t\t\treturn new this._lib.Style({\n\t\t\t\t\t\tzIndex: this.baseZIndex + style.zIndex,\n\t\t\t\t\t\timage: new this._lib.Icon({\n\t\t\t\t\t\t\tsrc: style.markerUrl as string,\n\t\t\t\t\t\t\twidth: style.markerWidth,\n\t\t\t\t\t\t\theight: style.markerHeight,\n\t\t\t\t\t\t\tanchor: [0.5, 1], // Anchor the icon at the bottom center\n\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn new this._lib.Style({\n\t\t\t\t\tzIndex: this.baseZIndex + style.zIndex,\n\t\t\t\t\timage: new this._lib.Circle({\n\t\t\t\t\t\tradius: style.pointWidth,\n\t\t\t\t\t\tfill: new this._lib.Fill({\n\t\t\t\t\t\t\tcolor: style.pointColor,\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tstroke: new this._lib.Stroke({\n\t\t\t\t\t\t\tcolor: style.pointOutlineColor,\n\t\t\t\t\t\t\twidth: style.pointOutlineWidth,\n\t\t\t\t\t\t}),\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t},\n\t\t\tLineString: (feature: FeatureLike) => {\n\t\t\t\tconst properties = feature.getProperties();\n\t\t\t\tconst style = styling[properties.mode]({\n\t\t\t\t\ttype: \"Feature\",\n\t\t\t\t\tgeometry: { type: \"LineString\", coordinates: [] },\n\t\t\t\t\tproperties,\n\t\t\t\t});\n\t\t\t\treturn new this._lib.Style({\n\t\t\t\t\tzIndex: style.zIndex,\n\t\t\t\t\tstroke: new this._lib.Stroke({\n\t\t\t\t\t\tcolor: style.lineStringColor,\n\t\t\t\t\t\twidth: style.lineStringWidth,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t},\n\t\t\tPolygon: (feature: FeatureLike) => {\n\t\t\t\tconst properties = feature.getProperties();\n\t\t\t\tconst style = styling[properties.mode]({\n\t\t\t\t\ttype: \"Feature\",\n\t\t\t\t\tgeometry: { type: \"Polygon\", coordinates: [] },\n\n\t\t\t\t\tproperties,\n\t\t\t\t});\n\t\t\t\tconst { r, g, b } = this.hexToRGB(style.polygonFillColor);\n\n\t\t\t\treturn new this._lib.Style({\n\t\t\t\t\tzIndex: style.zIndex,\n\t\t\t\t\tstroke: new this._lib.Stroke({\n\t\t\t\t\t\tcolor: style.polygonOutlineColor,\n\t\t\t\t\t\twidth: style.polygonOutlineWidth,\n\t\t\t\t\t}),\n\t\t\t\t\tfill: new this._lib.Fill({\n\t\t\t\t\t\tcolor: `rgba(${r},${g},${b},${style.polygonFillOpacity})`,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t},\n\t\t}[key](feature);\n\t}\n\n\t/**\n\t * Clears the layers created by the adapter\n\t * @returns void\n\t * */\n\tprivate clearLayers() {\n\t\tif (this._vectorSource) {\n\t\t\tthis._vectorSource.clear();\n\t\t}\n\t}\n\n\tprivate addFeature(feature: GeoJSONStoreFeatures) {\n\t\tconst olFeature = this._geoJSONReader.readFeature(feature, {\n\t\t\tdataProjection: \"EPSG:4326\",\n\t\t\tfeatureProjection: this._projection(),\n\t\t}) as Feature<Geometry>;\n\t\tthis._vectorSource.addFeature(olFeature);\n\t}\n\n\tprivate removeFeature(id: TerraDrawExtend.FeatureId) {\n\t\tconst deleted = this._vectorSource.getFeatureById(id);\n\t\tif (!deleted) {\n\t\t\treturn;\n\t\t}\n\t\tthis._vectorSource.removeFeature(deleted);\n\t}\n\n\t/**\n\t * Sorts an array of DOM elements based on their order in the document, from earliest to latest.\n\t * @param elements - An array of `HTMLElement` objects to be sorted.\n\t * @returns A new array of `HTMLElement` objects sorted by their document order.\n\t */\n\tprivate sortElementsByDOMOrder(elements: HTMLElement[]) {\n\t\t// Sort the elements based on their DOM position\n\t\treturn elements.sort((a, b) => {\n\t\t\tconst position = a.compareDocumentPosition(b);\n\n\t\t\t// If a comes before b in the DOM\n\t\t\tif (position & Node.DOCUMENT_POSITION_FOLLOWING) {\n\t\t\t\treturn -1;\n\t\t\t}\n\n\t\t\t// If a comes after b in the DOM\n\t\t\tif (position & Node.DOCUMENT_POSITION_PRECEDING) {\n\t\t\t\treturn 1;\n\t\t\t}\n\n\t\t\t// If they are the same element\n\t\t\treturn 0;\n\t\t});\n\t}\n\n\t/**\n\t * Returns the longitude and latitude coordinates from a given PointerEvent on the map.\n\t * @param event The PointerEvent or MouseEvent containing the screen coordinates of the pointer.\n\t * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude, or null if the conversion is not possible.\n\t */\n\tpublic getLngLatFromEvent(event: PointerEvent | MouseEvent) {\n\t\tconst { containerX: x, containerY: y } =\n\t\t\tthis.getMapElementXYPosition(event);\n\t\ttry {\n\t\t\treturn this.unproject(x, y);\n\t\t} catch (_) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * Retrieves the HTML element of the OpenLayers element that handles interaction events\n\t * @returns The HTMLElement representing the map container.\n\t */\n\tpublic getMapEventElement() {\n\t\t// Each VectorLayer has a canvas element that is used to render the features, it orders\n\t\t// these in the order they are added to the map. The last canvas is the one that is on top\n\t\t// so we need to add the event listeners to this canvas so that the events are captured.\n\t\tconst canvases = Array.from(this._container.querySelectorAll(\"canvas\"));\n\t\tconst sortedCanvases = this.sortElementsByDOMOrder(\n\t\t\tcanvases,\n\t\t) as HTMLCanvasElement[];\n\t\tconst topCanvas = sortedCanvases[sortedCanvases.length - 1];\n\n\t\treturn topCanvas;\n\t}\n\n\t/**\n\t * Enables or disables the draggable functionality of the map.\n\t * @param enabled Set to true to enable map dragging, or false to disable it.\n\t */\n\tpublic setDraggability(enabled: boolean) {\n\t\tthis._map.getInteractions().forEach((interaction) => {\n\t\t\tif (interaction.constructor.name === \"DragPan\") {\n\t\t\t\tinteraction.setActive(enabled);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Converts longitude and latitude coordinates to pixel coordinates in the map container.\n\t * @param lng The longitude coordinate to project.\n\t * @param lat The latitude coordinate to project.\n\t * @returns An object with 'x' and 'y' properties representing the pixel coordinates within the map container.\n\t */\n\tpublic project(lng: number, lat: number) {\n\t\tconst [x, y] = this._map.getPixelFromCoordinate(\n\t\t\tthis._lib.fromLonLat([lng, lat], this._projection()) as Coordinate,\n\t\t);\n\t\treturn { x, y };\n\t}\n\n\t/**\n\t * Converts pixel coordinates in the map container to longitude and latitude coordinates.\n\t * @param x The x-coordinate in the map container to unproject.\n\t * @param y The y-coordinate in the map container to unproject.\n\t * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude coordinates.\n\t */\n\tpublic unproject(x: number, y: number) {\n\t\tconst [lng, lat] = this._lib.toLonLat(\n\t\t\tthis._map.getCoordinateFromPixel([x, y]) as Pixel,\n\t\t\tthis._projection(),\n\t\t);\n\t\treturn { lng, lat };\n\t}\n\n\t/**\n\t * Sets the cursor style for the map container.\n\t * @param cursor The CSS cursor style to apply, or 'unset' to remove any previously applied cursor style.\n\t */\n\tpublic setCursor(cursor: Parameters<SetCursor>[0]) {\n\t\tif (cursor === \"unset\") {\n\t\t\tthis.getMapEventElement().style.removeProperty(\"cursor\");\n\t\t} else {\n\t\t\tthis.getMapEventElement().style.cursor = cursor;\n\t\t}\n\t}\n\n\t/**\n\t * Enables or disables the double-click to zoom functionality on the map.\n\t * @param enabled Set to true to enable double-click to zoom, or false to disable it.\n\t */\n\tpublic setDoubleClickToZoom(enabled: boolean) {\n\t\tthis._map.getInteractions().forEach(function (interaction) {\n\t\t\tif (interaction.constructor.name === \"DoubleClickZoom\") {\n\t\t\t\tinteraction.setActive(enabled);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Renders GeoJSON features on the map using the provided styling configuration.\n\t * @param changes An object containing arrays of created, updated, and unchanged features to render.\n\t * @param styling An object mapping draw modes to feature styling functions\n\t */\n\tpublic render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction) {\n\t\tthis.stylingFunction = () => styling;\n\n\t\tchanges.deletedIds.forEach((id) => {\n\t\t\tthis.removeFeature(id);\n\t\t});\n\n\t\tchanges.updated.forEach((feature) => {\n\t\t\tthis.removeFeature(feature.id as TerraDrawExtend.FeatureId);\n\t\t\tthis.addFeature(feature);\n\t\t});\n\n\t\tchanges.created.forEach((feature) => {\n\t\t\tthis.addFeature(feature);\n\t\t});\n\t}\n\n\t/**\n\t * Clears the map and store of all rendered data layers\n\t * @returns void\n\t * */\n\tpublic clear() {\n\t\tif (this._currentModeCallbacks) {\n\t\t\t// Clean up state first\n\t\t\tthis._currentModeCallbacks.onClear();\n\n\t\t\t// Then clean up rendering\n\t\t\tthis.clearLayers();\n\t\t}\n\t}\n\n\tprivate registeredLayerHandlers:\n\t\t| undefined\n\t\t| { addLayers: () => void; removeLayers: () => void };\n\n\tpublic register(callbacks: TerraDrawExtend.TerraDrawCallbacks) {\n\t\tsuper.register(callbacks);\n\n\t\t// We need to handle the complex case in OpenLayers where adding and removing layers\n\t\t// can change the canvas ordering preventing the event listeners from working correctly\n\t\tif (!this.registeredLayerHandlers) {\n\t\t\tconst layerGroup = this._map.getLayerGroup();\n\t\t\tconst layers = layerGroup.getLayers();\n\n\t\t\tconst removeListeners = () => {\n\t\t\t\tthis._listeners.forEach((listener) => {\n\t\t\t\t\tlistener.unregister();\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tconst addListeners = () => {\n\t\t\t\tthis._listeners = this.getAdapterListeners();\n\n\t\t\t\tthis._listeners.forEach((listener) => {\n\t\t\t\t\tlistener.register();\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tthis.registeredLayerHandlers = {\n\t\t\t\taddLayers: () => {\n\t\t\t\t\tremoveListeners();\n\t\t\t\t\tthis._map.once(\"rendercomplete\", () => {\n\t\t\t\t\t\tif (this._currentModeCallbacks) {\n\t\t\t\t\t\t\taddListeners();\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tremoveLayers: () => {\n\t\t\t\t\tremoveListeners();\n\t\t\t\t\tthis._map.once(\"rendercomplete\", () => {\n\t\t\t\t\t\tif (this._currentModeCallbacks) {\n\t\t\t\t\t\t\taddListeners();\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tlayers.on(\"add\", () => {\n\t\t\t\tremoveListeners();\n\t\t\t\tthis._map.once(\"rendercomplete\", () => {\n\t\t\t\t\tif (this._currentModeCallbacks) {\n\t\t\t\t\t\taddListeners();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tlayers.on(\"remove\", () => {\n\t\t\t\tremoveListeners();\n\t\t\t\tthis._map.once(\"rendercomplete\", () => {\n\t\t\t\t\tif (this._currentModeCallbacks) {\n\t\t\t\t\t\taddListeners();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\tif (this._currentModeCallbacks?.onReady) {\n\t\t\tthis._currentModeCallbacks.onReady();\n\t\t}\n\t}\n\n\tpublic getCoordinatePrecision(): number {\n\t\treturn super.getCoordinatePrecision();\n\t}\n\n\tpublic unregister(): void {\n\t\tif (this.registeredLayerHandlers) {\n\t\t\tconst layerGroup = this._map.getLayerGroup();\n\t\t\tif (layerGroup) {\n\t\t\t\tconst layers = layerGroup.getLayers();\n\n\t\t\t\tif (layers) {\n\t\t\t\t\tlayers.un(\"add\", this.registeredLayerHandlers.addLayers);\n\t\t\t\t\tlayers.un(\"remove\", this.registeredLayerHandlers.removeLayers);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn super.unregister();\n\t}\n}\n"],"names":["TerraDrawOpenLayersAdapter","TerraDrawExtend","TerraDrawBaseAdapter","constructor","config","_config$zIndex","super","this","baseZIndex","stylingFunction","_lib","_map","_container","_projection","_vectorSource","_geoJSONReader","registeredLayerHandlers","map","lib","GeoJSON","_this$_lib$getUserPro","getUserProjection","Projection","code","getViewport","setAttribute","vectorSource","VectorSource","features","zIndex","vectorLayer","VectorLayer","source","style","feature","getStyles","addLayer","hexToRGB","hex","r","parseInt","slice","g","b","styling","geometry","getGeometry","Point","properties","getProperties","mode","type","coordinates","Style","markerUrl","markerWidth","markerHeight","image","Icon","src","width","height","anchor","Circle","radius","pointWidth","fill","Fill","color","pointColor","stroke","Stroke","pointOutlineColor","pointOutlineWidth","LineString","lineStringColor","lineStringWidth","Polygon","polygonFillColor","polygonOutlineColor","polygonOutlineWidth","polygonFillOpacity","getType","clearLayers","clear","addFeature","olFeature","readFeature","dataProjection","featureProjection","removeFeature","id","deleted","getFeatureById","sortElementsByDOMOrder","elements","sort","a","position","compareDocumentPosition","Node","DOCUMENT_POSITION_FOLLOWING","DOCUMENT_POSITION_PRECEDING","getLngLatFromEvent","event","containerX","x","containerY","y","getMapElementXYPosition","unproject","_","getMapEventElement","canvases","Array","from","querySelectorAll","sortedCanvases","length","setDraggability","enabled","getInteractions","forEach","interaction","name","setActive","project","lng","lat","getPixelFromCoordinate","fromLonLat","toLonLat","getCoordinateFromPixel","setCursor","cursor","removeProperty","setDoubleClickToZoom","render","changes","deletedIds","updated","created","_currentModeCallbacks","onClear","register","callbacks","_this$_currentModeCal","layers","getLayerGroup","getLayers","removeListeners","_listeners","listener","unregister","addListeners","getAdapterListeners","addLayers","once","removeLayers","on","onReady","getCoordinatePrecision","layerGroup","un"],"mappings":"6CA2Ca,MAAAA,UAAmCC,EAAgBC,qBAC/DC,WAAAA,CACCC,GAIqC,IAAAC,EAErCC,MAAMF,GAAQG,KAkCPC,WAAa,IACbC,KAAAA,gBAAkB,MAAS,GAE3BC,KAAAA,iBACAC,UAAI,EAAAJ,KACJK,gBACAC,EAAAA,KAAAA,iBACAC,EAAAA,KAAAA,mBACAC,EAAAA,KAAAA,2BAsRAC,6BAAuB,EA9T9BT,KAAKI,KAAOP,EAAOa,IACnBV,KAAKG,KAAON,EAAOc,IAEnBX,KAAKQ,eAAiB,IAAQR,KAACG,KAAKS,QACpCZ,KAAKM,YAAc,KAAA,IAAAO,EAAA,OACWA,OADXA,EAClBb,KAAKG,KAAKW,qBAAmBD,EAC7B,IAAQb,KAACG,KAAKY,WAAW,CAAEC,KAAM,aAAa,EAE/ChB,KAAKK,WAAaL,KAAKI,KAAKa,cAG5BjB,KAAKK,WAAWa,a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AAAA,GACN,GAAIlJ,KAAKS,wBAAyB,CACjC,MAAMkJ,EAAa3J,KAAKI,KAAKyI,gBAC7B,GAAIc,EAAY,CACf,MAAMf,EAASe,EAAWb,YAEtBF,IACHA,EAAOgB,GAAG,MAAO5J,KAAKS,wBAAwB4I,WAC9CT,EAAOgB,GAAG,SAAU5J,KAAKS,wBAAwB8I,cAEnD,CACD,CAEA,aAAaL,YACd"}
@@ -1,2 +1,2 @@
1
- import{TerraDrawExtend as e}from"terra-draw";function t(e,r){return t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},t(e,r)}var r=/*#__PURE__*/function(e){function r(t){var r,o;(o=e.call(this,t)||this).baseZIndex=1e5,o.stylingFunction=function(){return{}},o._lib=void 0,o._map=void 0,o._container=void 0,o._projection=void 0,o._vectorSource=void 0,o._geoJSONReader=void 0,o.registeredLayerHandlers=void 0,o._map=t.map,o._lib=t.lib,o._geoJSONReader=new o._lib.GeoJSON,o._projection=function(){var e;return null!=(e=o._lib.getUserProjection())?e:new o._lib.Projection({code:"EPSG:3857"})},o._container=o._map.getViewport(),o._container.setAttribute("tabindex","0");var n=new o._lib.VectorSource({features:[]});o._vectorSource=n,o.baseZIndex=null!=(r=t.zIndex)?r:1e5;var i=new o._lib.VectorLayer({source:n,style:function(e){return o.getStyles(e,o.stylingFunction())},zIndex:o.baseZIndex});return o._map.addLayer(i),o}var o,n;n=e,(o=r).prototype=Object.create(n.prototype),o.prototype.constructor=o,t(o,n);var i=r.prototype;return i.hexToRGB=function(e){return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16)}},i.getStyles=function(e,t){var r=this,o=e.getGeometry();if(o)return{Point:function(e){var o=e.getProperties(),n=t[o.mode]({type:"Feature",geometry:{type:"Point",coordinates:[]},properties:o});return new r._lib.Style({zIndex:r.baseZIndex+n.zIndex,image:new r._lib.Circle({radius:n.pointWidth,fill:new r._lib.Fill({color:n.pointColor}),stroke:new r._lib.Stroke({color:n.pointOutlineColor,width:n.pointOutlineWidth})})})},LineString:function(e){var o=e.getProperties(),n=t[o.mode]({type:"Feature",geometry:{type:"LineString",coordinates:[]},properties:o});return new r._lib.Style({zIndex:n.zIndex,stroke:new r._lib.Stroke({color:n.lineStringColor,width:n.lineStringWidth})})},Polygon:function(e){var o=e.getProperties(),n=t[o.mode]({type:"Feature",geometry:{type:"Polygon",coordinates:[]},properties:o}),i=r.hexToRGB(n.polygonFillColor),a=i.r,c=i.g,s=i.b;return new r._lib.Style({zIndex:n.zIndex,stroke:new r._lib.Stroke({color:n.polygonOutlineColor,width:n.polygonOutlineWidth}),fill:new r._lib.Fill({color:"rgba("+a+","+c+","+s+","+n.polygonFillOpacity+")"})})}}[o.getType()](e)},i.clearLayers=function(){this._vectorSource&&this._vectorSource.clear()},i.addFeature=function(e){var t=this._geoJSONReader.readFeature(e,{dataProjection:"EPSG:4326",featureProjection:this._projection()});this._vectorSource.addFeature(t)},i.removeFeature=function(e){var t=this._vectorSource.getFeatureById(e);t&&this._vectorSource.removeFeature(t)},i.sortElementsByDOMOrder=function(e){return e.sort(function(e,t){var r=e.compareDocumentPosition(t);return r&Node.DOCUMENT_POSITION_FOLLOWING?-1:r&Node.DOCUMENT_POSITION_PRECEDING?1:0})},i.getLngLatFromEvent=function(e){var t=this.getMapElementXYPosition(e),r=t.containerX,o=t.containerY;try{return this.unproject(r,o)}catch(e){return null}},i.getMapEventElement=function(){var e=Array.from(this._container.querySelectorAll("canvas")),t=this.sortElementsByDOMOrder(e);return t[t.length-1]},i.setDraggability=function(e){this._map.getInteractions().forEach(function(t){"DragPan"===t.constructor.name&&t.setActive(e)})},i.project=function(e,t){var r=this._map.getPixelFromCoordinate(this._lib.fromLonLat([e,t],this._projection()));return{x:r[0],y:r[1]}},i.unproject=function(e,t){var r=this._lib.toLonLat(this._map.getCoordinateFromPixel([e,t]),this._projection());return{lng:r[0],lat:r[1]}},i.setCursor=function(e){"unset"===e?this.getMapEventElement().style.removeProperty("cursor"):this.getMapEventElement().style.cursor=e},i.setDoubleClickToZoom=function(e){this._map.getInteractions().forEach(function(t){"DoubleClickZoom"===t.constructor.name&&t.setActive(e)})},i.render=function(e,t){var r=this;this.stylingFunction=function(){return t},e.deletedIds.forEach(function(e){r.removeFeature(e)}),e.updated.forEach(function(e){r.removeFeature(e.id),r.addFeature(e)}),e.created.forEach(function(e){r.addFeature(e)})},i.clear=function(){this._currentModeCallbacks&&(this._currentModeCallbacks.onClear(),this.clearLayers())},i.register=function(t){var r,o=this;if(e.prototype.register.call(this,t),!this.registeredLayerHandlers){var n=this._map.getLayerGroup().getLayers(),i=function(){o._listeners.forEach(function(e){e.unregister()})},a=function(){o._listeners=o.getAdapterListeners(),o._listeners.forEach(function(e){e.register()})};this.registeredLayerHandlers={addLayers:function(){i(),o._map.once("rendercomplete",function(){o._currentModeCallbacks&&a()})},removeLayers:function(){i(),o._map.once("rendercomplete",function(){o._currentModeCallbacks&&a()})}},n.on("add",function(){i(),o._map.once("rendercomplete",function(){o._currentModeCallbacks&&a()})}),n.on("remove",function(){i(),o._map.once("rendercomplete",function(){o._currentModeCallbacks&&a()})})}null!=(r=this._currentModeCallbacks)&&r.onReady&&this._currentModeCallbacks.onReady()},i.getCoordinatePrecision=function(){return e.prototype.getCoordinatePrecision.call(this)},i.unregister=function(){if(this.registeredLayerHandlers){var t=this._map.getLayerGroup();if(t){var r=t.getLayers();r&&(r.un("add",this.registeredLayerHandlers.addLayers),r.un("remove",this.registeredLayerHandlers.removeLayers))}}return e.prototype.unregister.call(this)},r}(e.TerraDrawBaseAdapter);export{r as TerraDrawOpenLayersAdapter};
1
+ import{TerraDrawExtend as e}from"terra-draw";function t(e,r){return t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},t(e,r)}var r=/*#__PURE__*/function(e){function r(t){var r,n;(n=e.call(this,t)||this).baseZIndex=1e5,n.stylingFunction=function(){return{}},n._lib=void 0,n._map=void 0,n._container=void 0,n._projection=void 0,n._vectorSource=void 0,n._geoJSONReader=void 0,n.registeredLayerHandlers=void 0,n._map=t.map,n._lib=t.lib,n._geoJSONReader=new n._lib.GeoJSON,n._projection=function(){var e;return null!=(e=n._lib.getUserProjection())?e:new n._lib.Projection({code:"EPSG:3857"})},n._container=n._map.getViewport(),n._container.setAttribute("tabindex","0");var o=new n._lib.VectorSource({features:[]});n._vectorSource=o,n.baseZIndex=null!=(r=t.zIndex)?r:1e5;var i=new n._lib.VectorLayer({source:o,style:function(e){return n.getStyles(e,n.stylingFunction())},zIndex:n.baseZIndex});return n._map.addLayer(i),n}var n,o;o=e,(n=r).prototype=Object.create(o.prototype),n.prototype.constructor=n,t(n,o);var i=r.prototype;return i.hexToRGB=function(e){return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16)}},i.getStyles=function(e,t){var r=this,n=e.getGeometry();if(n)return{Point:function(e){var n=e.getProperties(),o=t[n.mode]({type:"Feature",geometry:{type:"Point",coordinates:[]},properties:n});return new r._lib.Style(o.markerUrl&&o.markerWidth&&o.markerHeight?{zIndex:r.baseZIndex+o.zIndex,image:new r._lib.Icon({src:o.markerUrl,width:o.markerWidth,height:o.markerHeight,anchor:[.5,1]})}:{zIndex:r.baseZIndex+o.zIndex,image:new r._lib.Circle({radius:o.pointWidth,fill:new r._lib.Fill({color:o.pointColor}),stroke:new r._lib.Stroke({color:o.pointOutlineColor,width:o.pointOutlineWidth})})})},LineString:function(e){var n=e.getProperties(),o=t[n.mode]({type:"Feature",geometry:{type:"LineString",coordinates:[]},properties:n});return new r._lib.Style({zIndex:o.zIndex,stroke:new r._lib.Stroke({color:o.lineStringColor,width:o.lineStringWidth})})},Polygon:function(e){var n=e.getProperties(),o=t[n.mode]({type:"Feature",geometry:{type:"Polygon",coordinates:[]},properties:n}),i=r.hexToRGB(o.polygonFillColor),a=i.r,c=i.g,s=i.b;return new r._lib.Style({zIndex:o.zIndex,stroke:new r._lib.Stroke({color:o.polygonOutlineColor,width:o.polygonOutlineWidth}),fill:new r._lib.Fill({color:"rgba("+a+","+c+","+s+","+o.polygonFillOpacity+")"})})}}[n.getType()](e)},i.clearLayers=function(){this._vectorSource&&this._vectorSource.clear()},i.addFeature=function(e){var t=this._geoJSONReader.readFeature(e,{dataProjection:"EPSG:4326",featureProjection:this._projection()});this._vectorSource.addFeature(t)},i.removeFeature=function(e){var t=this._vectorSource.getFeatureById(e);t&&this._vectorSource.removeFeature(t)},i.sortElementsByDOMOrder=function(e){return e.sort(function(e,t){var r=e.compareDocumentPosition(t);return r&Node.DOCUMENT_POSITION_FOLLOWING?-1:r&Node.DOCUMENT_POSITION_PRECEDING?1:0})},i.getLngLatFromEvent=function(e){var t=this.getMapElementXYPosition(e),r=t.containerX,n=t.containerY;try{return this.unproject(r,n)}catch(e){return null}},i.getMapEventElement=function(){var e=Array.from(this._container.querySelectorAll("canvas")),t=this.sortElementsByDOMOrder(e);return t[t.length-1]},i.setDraggability=function(e){this._map.getInteractions().forEach(function(t){"DragPan"===t.constructor.name&&t.setActive(e)})},i.project=function(e,t){var r=this._map.getPixelFromCoordinate(this._lib.fromLonLat([e,t],this._projection()));return{x:r[0],y:r[1]}},i.unproject=function(e,t){var r=this._lib.toLonLat(this._map.getCoordinateFromPixel([e,t]),this._projection());return{lng:r[0],lat:r[1]}},i.setCursor=function(e){"unset"===e?this.getMapEventElement().style.removeProperty("cursor"):this.getMapEventElement().style.cursor=e},i.setDoubleClickToZoom=function(e){this._map.getInteractions().forEach(function(t){"DoubleClickZoom"===t.constructor.name&&t.setActive(e)})},i.render=function(e,t){var r=this;this.stylingFunction=function(){return t},e.deletedIds.forEach(function(e){r.removeFeature(e)}),e.updated.forEach(function(e){r.removeFeature(e.id),r.addFeature(e)}),e.created.forEach(function(e){r.addFeature(e)})},i.clear=function(){this._currentModeCallbacks&&(this._currentModeCallbacks.onClear(),this.clearLayers())},i.register=function(t){var r,n=this;if(e.prototype.register.call(this,t),!this.registeredLayerHandlers){var o=this._map.getLayerGroup().getLayers(),i=function(){n._listeners.forEach(function(e){e.unregister()})},a=function(){n._listeners=n.getAdapterListeners(),n._listeners.forEach(function(e){e.register()})};this.registeredLayerHandlers={addLayers:function(){i(),n._map.once("rendercomplete",function(){n._currentModeCallbacks&&a()})},removeLayers:function(){i(),n._map.once("rendercomplete",function(){n._currentModeCallbacks&&a()})}},o.on("add",function(){i(),n._map.once("rendercomplete",function(){n._currentModeCallbacks&&a()})}),o.on("remove",function(){i(),n._map.once("rendercomplete",function(){n._currentModeCallbacks&&a()})})}null!=(r=this._currentModeCallbacks)&&r.onReady&&this._currentModeCallbacks.onReady()},i.getCoordinatePrecision=function(){return e.prototype.getCoordinatePrecision.call(this)},i.unregister=function(){if(this.registeredLayerHandlers){var t=this._map.getLayerGroup();if(t){var r=t.getLayers();r&&(r.un("add",this.registeredLayerHandlers.addLayers),r.un("remove",this.registeredLayerHandlers.removeLayers))}}return e.prototype.unregister.call(this)},r}(e.TerraDrawBaseAdapter);export{r as TerraDrawOpenLayersAdapter};
2
2
  //# sourceMappingURL=terra-draw-openlayers-adapter.module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"terra-draw-openlayers-adapter.module.js","sources":["../src/terra-draw-openlayers-adapter.ts"],"sourcesContent":["/**\n * @module terra-draw-openlayers-adapter\n */\nimport {\n\tTerraDrawChanges,\n\tSetCursor,\n\tTerraDrawStylingFunction,\n\tGeoJSONStoreFeatures,\n\tTerraDrawExtend,\n} from \"terra-draw\";\n\nimport Feature, { FeatureLike } from \"ol/Feature\";\nimport GeoJSON from \"ol/format/GeoJSON\";\nimport Map from \"ol/Map\";\nimport Circle from \"ol/style/Circle\";\nimport Fill from \"ol/style/Fill\";\nimport Stroke from \"ol/style/Stroke\";\nimport Style from \"ol/style/Style\";\nimport VectorSource from \"ol/source/Vector\";\nimport { Geometry } from \"ol/geom\";\nimport VectorLayer from \"ol/layer/Vector\";\nimport Projection from \"ol/proj/Projection\";\nimport { fromLonLat, toLonLat, getUserProjection } from \"ol/proj\";\nimport { Coordinate } from \"ol/coordinate\";\nimport { Pixel } from \"ol/pixel\";\n\nexport type InjectableOL = {\n\tFill: typeof Fill;\n\tFeature: typeof Feature;\n\tGeoJSON: typeof GeoJSON;\n\tStyle: typeof Style;\n\tCircle: typeof Circle;\n\tVectorLayer: typeof VectorLayer;\n\tVectorSource: typeof VectorSource;\n\tStroke: typeof Stroke;\n\tProjection: typeof Projection;\n\tgetUserProjection: typeof getUserProjection;\n\tfromLonLat: typeof fromLonLat;\n\ttoLonLat: typeof toLonLat;\n};\n\nexport class TerraDrawOpenLayersAdapter extends TerraDrawExtend.TerraDrawBaseAdapter {\n\tconstructor(\n\t\tconfig: {\n\t\t\tmap: Map;\n\t\t\tlib: InjectableOL;\n\t\t\tzIndex?: number;\n\t\t} & TerraDrawExtend.BaseAdapterConfig,\n\t) {\n\t\tsuper(config);\n\n\t\tthis._map = config.map;\n\t\tthis._lib = config.lib;\n\n\t\tthis._geoJSONReader = new this._lib.GeoJSON();\n\t\tthis._projection = () =>\n\t\t\tthis._lib.getUserProjection() ??\n\t\t\tnew this._lib.Projection({ code: \"EPSG:3857\" });\n\n\t\tthis._container = this._map.getViewport();\n\n\t\t// TODO: Is this the best way to receive keyboard events\n\t\tthis._container.setAttribute(\"tabindex\", \"0\");\n\n\t\tconst vectorSource = new this._lib.VectorSource({\n\t\t\tfeatures: [],\n\t\t}) as unknown as VectorSource<Feature<Geometry>>;\n\n\t\tthis._vectorSource = vectorSource as unknown as VectorSource<\n\t\t\tFeature<Geometry>\n\t\t>;\n\n\t\tthis.baseZIndex = config.zIndex ?? 100000;\n\n\t\tconst vectorLayer = new this._lib.VectorLayer({\n\t\t\tsource: vectorSource as unknown as VectorSource<never>,\n\t\t\tstyle: (feature) => this.getStyles(feature, this.stylingFunction()),\n\t\t\tzIndex: this.baseZIndex,\n\t\t});\n\n\t\tthis._map.addLayer(vectorLayer);\n\t}\n\n\tprivate baseZIndex = 100000;\n\tprivate stylingFunction = () => ({});\n\n\tprivate _lib: InjectableOL;\n\tprivate _map: Map;\n\tprivate _container: HTMLElement;\n\tprivate _projection: () => Projection;\n\tprivate _vectorSource: VectorSource<Feature<Geometry>>;\n\tprivate _geoJSONReader: GeoJSON;\n\n\t/**\n\t * Converts a hexadecimal color to RGB\n\t * @param hex a string of the hexadecimal string\n\t * @returns an object to red green and blue (RGB) color\n\t */\n\tprivate hexToRGB(hex: string): { r: number; g: number; b: number } {\n\t\treturn {\n\t\t\tr: parseInt(hex.slice(1, 3), 16),\n\t\t\tg: parseInt(hex.slice(3, 5), 16),\n\t\t\tb: parseInt(hex.slice(5, 7), 16),\n\t\t};\n\t}\n\n\tprivate getStyles(feature: FeatureLike, styling: TerraDrawStylingFunction) {\n\t\tconst geometry = feature.getGeometry();\n\t\tif (!geometry) {\n\t\t\treturn;\n\t\t}\n\t\tconst key = geometry.getType() as \"Point\" | \"LineString\" | \"Polygon\";\n\n\t\treturn {\n\t\t\tPoint: (feature: FeatureLike) => {\n\t\t\t\tconst properties = feature.getProperties();\n\t\t\t\tconst style = styling[properties.mode]({\n\t\t\t\t\ttype: \"Feature\",\n\t\t\t\t\tgeometry: { type: \"Point\", coordinates: [] },\n\t\t\t\t\tproperties,\n\t\t\t\t});\n\t\t\t\treturn new this._lib.Style({\n\t\t\t\t\tzIndex: this.baseZIndex + style.zIndex,\n\t\t\t\t\timage: new this._lib.Circle({\n\t\t\t\t\t\tradius: style.pointWidth,\n\t\t\t\t\t\tfill: new this._lib.Fill({\n\t\t\t\t\t\t\tcolor: style.pointColor,\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tstroke: new this._lib.Stroke({\n\t\t\t\t\t\t\tcolor: style.pointOutlineColor,\n\t\t\t\t\t\t\twidth: style.pointOutlineWidth,\n\t\t\t\t\t\t}),\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t},\n\t\t\tLineString: (feature: FeatureLike) => {\n\t\t\t\tconst properties = feature.getProperties();\n\t\t\t\tconst style = styling[properties.mode]({\n\t\t\t\t\ttype: \"Feature\",\n\t\t\t\t\tgeometry: { type: \"LineString\", coordinates: [] },\n\t\t\t\t\tproperties,\n\t\t\t\t});\n\t\t\t\treturn new this._lib.Style({\n\t\t\t\t\tzIndex: style.zIndex,\n\t\t\t\t\tstroke: new this._lib.Stroke({\n\t\t\t\t\t\tcolor: style.lineStringColor,\n\t\t\t\t\t\twidth: style.lineStringWidth,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t},\n\t\t\tPolygon: (feature: FeatureLike) => {\n\t\t\t\tconst properties = feature.getProperties();\n\t\t\t\tconst style = styling[properties.mode]({\n\t\t\t\t\ttype: \"Feature\",\n\t\t\t\t\tgeometry: { type: \"Polygon\", coordinates: [] },\n\n\t\t\t\t\tproperties,\n\t\t\t\t});\n\t\t\t\tconst { r, g, b } = this.hexToRGB(style.polygonFillColor);\n\n\t\t\t\treturn new this._lib.Style({\n\t\t\t\t\tzIndex: style.zIndex,\n\t\t\t\t\tstroke: new this._lib.Stroke({\n\t\t\t\t\t\tcolor: style.polygonOutlineColor,\n\t\t\t\t\t\twidth: style.polygonOutlineWidth,\n\t\t\t\t\t}),\n\t\t\t\t\tfill: new this._lib.Fill({\n\t\t\t\t\t\tcolor: `rgba(${r},${g},${b},${style.polygonFillOpacity})`,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t},\n\t\t}[key](feature);\n\t}\n\n\t/**\n\t * Clears the layers created by the adapter\n\t * @returns void\n\t * */\n\tprivate clearLayers() {\n\t\tif (this._vectorSource) {\n\t\t\tthis._vectorSource.clear();\n\t\t}\n\t}\n\n\tprivate addFeature(feature: GeoJSONStoreFeatures) {\n\t\tconst olFeature = this._geoJSONReader.readFeature(feature, {\n\t\t\tdataProjection: \"EPSG:4326\",\n\t\t\tfeatureProjection: this._projection(),\n\t\t}) as Feature<Geometry>;\n\t\tthis._vectorSource.addFeature(olFeature);\n\t}\n\n\tprivate removeFeature(id: TerraDrawExtend.FeatureId) {\n\t\tconst deleted = this._vectorSource.getFeatureById(id);\n\t\tif (!deleted) {\n\t\t\treturn;\n\t\t}\n\t\tthis._vectorSource.removeFeature(deleted);\n\t}\n\n\t/**\n\t * Sorts an array of DOM elements based on their order in the document, from earliest to latest.\n\t * @param elements - An array of `HTMLElement` objects to be sorted.\n\t * @returns A new array of `HTMLElement` objects sorted by their document order.\n\t */\n\tprivate sortElementsByDOMOrder(elements: HTMLElement[]) {\n\t\t// Sort the elements based on their DOM position\n\t\treturn elements.sort((a, b) => {\n\t\t\tconst position = a.compareDocumentPosition(b);\n\n\t\t\t// If a comes before b in the DOM\n\t\t\tif (position & Node.DOCUMENT_POSITION_FOLLOWING) {\n\t\t\t\treturn -1;\n\t\t\t}\n\n\t\t\t// If a comes after b in the DOM\n\t\t\tif (position & Node.DOCUMENT_POSITION_PRECEDING) {\n\t\t\t\treturn 1;\n\t\t\t}\n\n\t\t\t// If they are the same element\n\t\t\treturn 0;\n\t\t});\n\t}\n\n\t/**\n\t * Returns the longitude and latitude coordinates from a given PointerEvent on the map.\n\t * @param event The PointerEvent or MouseEvent containing the screen coordinates of the pointer.\n\t * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude, or null if the conversion is not possible.\n\t */\n\tpublic getLngLatFromEvent(event: PointerEvent | MouseEvent) {\n\t\tconst { containerX: x, containerY: y } =\n\t\t\tthis.getMapElementXYPosition(event);\n\t\ttry {\n\t\t\treturn this.unproject(x, y);\n\t\t} catch (_) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * Retrieves the HTML element of the OpenLayers element that handles interaction events\n\t * @returns The HTMLElement representing the map container.\n\t */\n\tpublic getMapEventElement() {\n\t\t// Each VectorLayer has a canvas element that is used to render the features, it orders\n\t\t// these in the order they are added to the map. The last canvas is the one that is on top\n\t\t// so we need to add the event listeners to this canvas so that the events are captured.\n\t\tconst canvases = Array.from(this._container.querySelectorAll(\"canvas\"));\n\t\tconst sortedCanvases = this.sortElementsByDOMOrder(\n\t\t\tcanvases,\n\t\t) as HTMLCanvasElement[];\n\t\tconst topCanvas = sortedCanvases[sortedCanvases.length - 1];\n\n\t\treturn topCanvas;\n\t}\n\n\t/**\n\t * Enables or disables the draggable functionality of the map.\n\t * @param enabled Set to true to enable map dragging, or false to disable it.\n\t */\n\tpublic setDraggability(enabled: boolean) {\n\t\tthis._map.getInteractions().forEach((interaction) => {\n\t\t\tif (interaction.constructor.name === \"DragPan\") {\n\t\t\t\tinteraction.setActive(enabled);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Converts longitude and latitude coordinates to pixel coordinates in the map container.\n\t * @param lng The longitude coordinate to project.\n\t * @param lat The latitude coordinate to project.\n\t * @returns An object with 'x' and 'y' properties representing the pixel coordinates within the map container.\n\t */\n\tpublic project(lng: number, lat: number) {\n\t\tconst [x, y] = this._map.getPixelFromCoordinate(\n\t\t\tthis._lib.fromLonLat([lng, lat], this._projection()) as Coordinate,\n\t\t);\n\t\treturn { x, y };\n\t}\n\n\t/**\n\t * Converts pixel coordinates in the map container to longitude and latitude coordinates.\n\t * @param x The x-coordinate in the map container to unproject.\n\t * @param y The y-coordinate in the map container to unproject.\n\t * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude coordinates.\n\t */\n\tpublic unproject(x: number, y: number) {\n\t\tconst [lng, lat] = this._lib.toLonLat(\n\t\t\tthis._map.getCoordinateFromPixel([x, y]) as Pixel,\n\t\t\tthis._projection(),\n\t\t);\n\t\treturn { lng, lat };\n\t}\n\n\t/**\n\t * Sets the cursor style for the map container.\n\t * @param cursor The CSS cursor style to apply, or 'unset' to remove any previously applied cursor style.\n\t */\n\tpublic setCursor(cursor: Parameters<SetCursor>[0]) {\n\t\tif (cursor === \"unset\") {\n\t\t\tthis.getMapEventElement().style.removeProperty(\"cursor\");\n\t\t} else {\n\t\t\tthis.getMapEventElement().style.cursor = cursor;\n\t\t}\n\t}\n\n\t/**\n\t * Enables or disables the double-click to zoom functionality on the map.\n\t * @param enabled Set to true to enable double-click to zoom, or false to disable it.\n\t */\n\tpublic setDoubleClickToZoom(enabled: boolean) {\n\t\tthis._map.getInteractions().forEach(function (interaction) {\n\t\t\tif (interaction.constructor.name === \"DoubleClickZoom\") {\n\t\t\t\tinteraction.setActive(enabled);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Renders GeoJSON features on the map using the provided styling configuration.\n\t * @param changes An object containing arrays of created, updated, and unchanged features to render.\n\t * @param styling An object mapping draw modes to feature styling functions\n\t */\n\tpublic render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction) {\n\t\tthis.stylingFunction = () => styling;\n\n\t\tchanges.deletedIds.forEach((id) => {\n\t\t\tthis.removeFeature(id);\n\t\t});\n\n\t\tchanges.updated.forEach((feature) => {\n\t\t\tthis.removeFeature(feature.id as TerraDrawExtend.FeatureId);\n\t\t\tthis.addFeature(feature);\n\t\t});\n\n\t\tchanges.created.forEach((feature) => {\n\t\t\tthis.addFeature(feature);\n\t\t});\n\t}\n\n\t/**\n\t * Clears the map and store of all rendered data layers\n\t * @returns void\n\t * */\n\tpublic clear() {\n\t\tif (this._currentModeCallbacks) {\n\t\t\t// Clean up state first\n\t\t\tthis._currentModeCallbacks.onClear();\n\n\t\t\t// Then clean up rendering\n\t\t\tthis.clearLayers();\n\t\t}\n\t}\n\n\tprivate registeredLayerHandlers:\n\t\t| undefined\n\t\t| { addLayers: () => void; removeLayers: () => void };\n\n\tpublic register(callbacks: TerraDrawExtend.TerraDrawCallbacks) {\n\t\tsuper.register(callbacks);\n\n\t\t// We need to handle the complex case in OpenLayers where adding and removing layers\n\t\t// can change the canvas ordering preventing the event listeners from working correctly\n\t\tif (!this.registeredLayerHandlers) {\n\t\t\tconst layerGroup = this._map.getLayerGroup();\n\t\t\tconst layers = layerGroup.getLayers();\n\n\t\t\tconst removeListeners = () => {\n\t\t\t\tthis._listeners.forEach((listener) => {\n\t\t\t\t\tlistener.unregister();\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tconst addListeners = () => {\n\t\t\t\tthis._listeners = this.getAdapterListeners();\n\n\t\t\t\tthis._listeners.forEach((listener) => {\n\t\t\t\t\tlistener.register();\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tthis.registeredLayerHandlers = {\n\t\t\t\taddLayers: () => {\n\t\t\t\t\tremoveListeners();\n\t\t\t\t\tthis._map.once(\"rendercomplete\", () => {\n\t\t\t\t\t\tif (this._currentModeCallbacks) {\n\t\t\t\t\t\t\taddListeners();\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tremoveLayers: () => {\n\t\t\t\t\tremoveListeners();\n\t\t\t\t\tthis._map.once(\"rendercomplete\", () => {\n\t\t\t\t\t\tif (this._currentModeCallbacks) {\n\t\t\t\t\t\t\taddListeners();\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tlayers.on(\"add\", () => {\n\t\t\t\tremoveListeners();\n\t\t\t\tthis._map.once(\"rendercomplete\", () => {\n\t\t\t\t\tif (this._currentModeCallbacks) {\n\t\t\t\t\t\taddListeners();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tlayers.on(\"remove\", () => {\n\t\t\t\tremoveListeners();\n\t\t\t\tthis._map.once(\"rendercomplete\", () => {\n\t\t\t\t\tif (this._currentModeCallbacks) {\n\t\t\t\t\t\taddListeners();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\tif (this._currentModeCallbacks?.onReady) {\n\t\t\tthis._currentModeCallbacks.onReady();\n\t\t}\n\t}\n\n\tpublic getCoordinatePrecision(): number {\n\t\treturn super.getCoordinatePrecision();\n\t}\n\n\tpublic unregister(): void {\n\t\tif (this.registeredLayerHandlers) {\n\t\t\tconst layerGroup = this._map.getLayerGroup();\n\t\t\tif (layerGroup) {\n\t\t\t\tconst layers = layerGroup.getLayers();\n\n\t\t\t\tif (layers) {\n\t\t\t\t\tlayers.un(\"add\", this.registeredLayerHandlers.addLayers);\n\t\t\t\t\tlayers.un(\"remove\", this.registeredLayerHandlers.removeLayers);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn super.unregister();\n\t}\n}\n"],"names":["TerraDrawOpenLayersAdapter","_TerraDrawExtend$Terr","config","_config$zIndex","_this","call","baseZIndex","stylingFunction","_lib","_map","_container","_projection","_vectorSource","_geoJSONReader","registeredLayerHandlers","map","lib","GeoJSON","_this$_lib$getUserPro","getUserProjection","Projection","code","getViewport","setAttribute","vectorSource","VectorSource","features","zIndex","vectorLayer","VectorLayer","source","style","feature","getStyles","addLayer","_proto","prototype","hexToRGB","hex","r","parseInt","slice","g","b","styling","_this2","geometry","getGeometry","Point","properties","getProperties","mode","type","coordinates","Style","image","Circle","radius","pointWidth","fill","Fill","color","pointColor","stroke","Stroke","pointOutlineColor","width","pointOutlineWidth","LineString","lineStringColor","lineStringWidth","Polygon","_this2$hexToRGB","polygonFillColor","polygonOutlineColor","polygonOutlineWidth","polygonFillOpacity","getType","clearLayers","this","clear","addFeature","olFeature","readFeature","dataProjection","featureProjection","removeFeature","id","deleted","getFeatureById","sortElementsByDOMOrder","elements","sort","a","position","compareDocumentPosition","Node","DOCUMENT_POSITION_FOLLOWING","DOCUMENT_POSITION_PRECEDING","getLngLatFromEvent","event","_this$getMapElementXY","getMapElementXYPosition","x","containerX","y","containerY","unproject","_","getMapEventElement","canvases","Array","from","querySelectorAll","sortedCanvases","length","setDraggability","enabled","getInteractions","forEach","interaction","constructor","name","setActive","project","lng","lat","_this$_map$getPixelFr","getPixelFromCoordinate","fromLonLat","_this$_lib$toLonLat","toLonLat","getCoordinateFromPixel","setCursor","cursor","removeProperty","setDoubleClickToZoom","render","changes","_this3","deletedIds","updated","created","_currentModeCallbacks","onClear","register","callbacks","_this$_currentModeCal","_this4","layers","getLayerGroup","getLayers","removeListeners","_listeners","listener","unregister","addListeners","getAdapterListeners","addLayers","once","removeLayers","on","onReady","getCoordinatePrecision","layerGroup","un","Terra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,OAAA/J,EAAAmC,UAAauH,WAAUtJ,KAAA0E,KACxB,EAAC/E,CAAA,CAnZsC,CAAQsK,EAAgBC"}
1
+ {"version":3,"file":"terra-draw-openlayers-adapter.module.js","sources":["../src/terra-draw-openlayers-adapter.ts"],"sourcesContent":["/**\n * @module terra-draw-openlayers-adapter\n */\nimport {\n\tTerraDrawChanges,\n\tSetCursor,\n\tTerraDrawStylingFunction,\n\tGeoJSONStoreFeatures,\n\tTerraDrawExtend,\n} from \"terra-draw\";\n\nimport Feature, { FeatureLike } from \"ol/Feature\";\nimport GeoJSON from \"ol/format/GeoJSON\";\nimport Map from \"ol/Map\";\nimport Circle from \"ol/style/Circle\";\nimport Fill from \"ol/style/Fill\";\nimport Stroke from \"ol/style/Stroke\";\nimport Style from \"ol/style/Style\";\nimport VectorSource from \"ol/source/Vector\";\nimport { Geometry } from \"ol/geom\";\nimport VectorLayer from \"ol/layer/Vector\";\nimport Projection from \"ol/proj/Projection\";\nimport { fromLonLat, toLonLat, getUserProjection } from \"ol/proj\";\nimport { Coordinate } from \"ol/coordinate\";\nimport { Pixel } from \"ol/pixel\";\nimport { Icon } from \"ol/style\";\n\nexport type InjectableOL = {\n\tIcon: typeof Icon;\n\tFill: typeof Fill;\n\tFeature: typeof Feature;\n\tGeoJSON: typeof GeoJSON;\n\tStyle: typeof Style;\n\tCircle: typeof Circle;\n\tVectorLayer: typeof VectorLayer;\n\tVectorSource: typeof VectorSource;\n\tStroke: typeof Stroke;\n\tProjection: typeof Projection;\n\tgetUserProjection: typeof getUserProjection;\n\tfromLonLat: typeof fromLonLat;\n\ttoLonLat: typeof toLonLat;\n};\n\nexport class TerraDrawOpenLayersAdapter extends TerraDrawExtend.TerraDrawBaseAdapter {\n\tconstructor(\n\t\tconfig: {\n\t\t\tmap: Map;\n\t\t\tlib: InjectableOL;\n\t\t\tzIndex?: number;\n\t\t} & TerraDrawExtend.BaseAdapterConfig,\n\t) {\n\t\tsuper(config);\n\n\t\tthis._map = config.map;\n\t\tthis._lib = config.lib;\n\n\t\tthis._geoJSONReader = new this._lib.GeoJSON();\n\t\tthis._projection = () =>\n\t\t\tthis._lib.getUserProjection() ??\n\t\t\tnew this._lib.Projection({ code: \"EPSG:3857\" });\n\n\t\tthis._container = this._map.getViewport();\n\n\t\t// TODO: Is this the best way to receive keyboard events\n\t\tthis._container.setAttribute(\"tabindex\", \"0\");\n\n\t\tconst vectorSource = new this._lib.VectorSource({\n\t\t\tfeatures: [],\n\t\t}) as unknown as VectorSource<Feature<Geometry>>;\n\n\t\tthis._vectorSource = vectorSource as unknown as VectorSource<\n\t\t\tFeature<Geometry>\n\t\t>;\n\n\t\tthis.baseZIndex = config.zIndex ?? 100000;\n\n\t\tconst vectorLayer = new this._lib.VectorLayer({\n\t\t\tsource: vectorSource as unknown as VectorSource<never>,\n\t\t\tstyle: (feature) => this.getStyles(feature, this.stylingFunction()),\n\t\t\tzIndex: this.baseZIndex,\n\t\t});\n\n\t\tthis._map.addLayer(vectorLayer);\n\t}\n\n\tprivate baseZIndex = 100000;\n\tprivate stylingFunction = () => ({});\n\n\tprivate _lib: InjectableOL;\n\tprivate _map: Map;\n\tprivate _container: HTMLElement;\n\tprivate _projection: () => Projection;\n\tprivate _vectorSource: VectorSource<Feature<Geometry>>;\n\tprivate _geoJSONReader: GeoJSON;\n\n\t/**\n\t * Converts a hexadecimal color to RGB\n\t * @param hex a string of the hexadecimal string\n\t * @returns an object to red green and blue (RGB) color\n\t */\n\tprivate hexToRGB(hex: string): { r: number; g: number; b: number } {\n\t\treturn {\n\t\t\tr: parseInt(hex.slice(1, 3), 16),\n\t\t\tg: parseInt(hex.slice(3, 5), 16),\n\t\t\tb: parseInt(hex.slice(5, 7), 16),\n\t\t};\n\t}\n\n\tprivate getStyles(feature: FeatureLike, styling: TerraDrawStylingFunction) {\n\t\tconst geometry = feature.getGeometry();\n\t\tif (!geometry) {\n\t\t\treturn;\n\t\t}\n\t\tconst key = geometry.getType() as \"Point\" | \"LineString\" | \"Polygon\";\n\n\t\treturn {\n\t\t\tPoint: (feature: FeatureLike) => {\n\t\t\t\tconst properties = feature.getProperties();\n\t\t\t\tconst style = styling[properties.mode]({\n\t\t\t\t\ttype: \"Feature\",\n\t\t\t\t\tgeometry: { type: \"Point\", coordinates: [] },\n\t\t\t\t\tproperties,\n\t\t\t\t});\n\n\t\t\t\tif (style.markerUrl && style.markerWidth && style.markerHeight) {\n\t\t\t\t\treturn new this._lib.Style({\n\t\t\t\t\t\tzIndex: this.baseZIndex + style.zIndex,\n\t\t\t\t\t\timage: new this._lib.Icon({\n\t\t\t\t\t\t\tsrc: style.markerUrl as string,\n\t\t\t\t\t\t\twidth: style.markerWidth,\n\t\t\t\t\t\t\theight: style.markerHeight,\n\t\t\t\t\t\t\tanchor: [0.5, 1], // Anchor the icon at the bottom center\n\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn new this._lib.Style({\n\t\t\t\t\tzIndex: this.baseZIndex + style.zIndex,\n\t\t\t\t\timage: new this._lib.Circle({\n\t\t\t\t\t\tradius: style.pointWidth,\n\t\t\t\t\t\tfill: new this._lib.Fill({\n\t\t\t\t\t\t\tcolor: style.pointColor,\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tstroke: new this._lib.Stroke({\n\t\t\t\t\t\t\tcolor: style.pointOutlineColor,\n\t\t\t\t\t\t\twidth: style.pointOutlineWidth,\n\t\t\t\t\t\t}),\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t},\n\t\t\tLineString: (feature: FeatureLike) => {\n\t\t\t\tconst properties = feature.getProperties();\n\t\t\t\tconst style = styling[properties.mode]({\n\t\t\t\t\ttype: \"Feature\",\n\t\t\t\t\tgeometry: { type: \"LineString\", coordinates: [] },\n\t\t\t\t\tproperties,\n\t\t\t\t});\n\t\t\t\treturn new this._lib.Style({\n\t\t\t\t\tzIndex: style.zIndex,\n\t\t\t\t\tstroke: new this._lib.Stroke({\n\t\t\t\t\t\tcolor: style.lineStringColor,\n\t\t\t\t\t\twidth: style.lineStringWidth,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t},\n\t\t\tPolygon: (feature: FeatureLike) => {\n\t\t\t\tconst properties = feature.getProperties();\n\t\t\t\tconst style = styling[properties.mode]({\n\t\t\t\t\ttype: \"Feature\",\n\t\t\t\t\tgeometry: { type: \"Polygon\", coordinates: [] },\n\n\t\t\t\t\tproperties,\n\t\t\t\t});\n\t\t\t\tconst { r, g, b } = this.hexToRGB(style.polygonFillColor);\n\n\t\t\t\treturn new this._lib.Style({\n\t\t\t\t\tzIndex: style.zIndex,\n\t\t\t\t\tstroke: new this._lib.Stroke({\n\t\t\t\t\t\tcolor: style.polygonOutlineColor,\n\t\t\t\t\t\twidth: style.polygonOutlineWidth,\n\t\t\t\t\t}),\n\t\t\t\t\tfill: new this._lib.Fill({\n\t\t\t\t\t\tcolor: `rgba(${r},${g},${b},${style.polygonFillOpacity})`,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t},\n\t\t}[key](feature);\n\t}\n\n\t/**\n\t * Clears the layers created by the adapter\n\t * @returns void\n\t * */\n\tprivate clearLayers() {\n\t\tif (this._vectorSource) {\n\t\t\tthis._vectorSource.clear();\n\t\t}\n\t}\n\n\tprivate addFeature(feature: GeoJSONStoreFeatures) {\n\t\tconst olFeature = this._geoJSONReader.readFeature(feature, {\n\t\t\tdataProjection: \"EPSG:4326\",\n\t\t\tfeatureProjection: this._projection(),\n\t\t}) as Feature<Geometry>;\n\t\tthis._vectorSource.addFeature(olFeature);\n\t}\n\n\tprivate removeFeature(id: TerraDrawExtend.FeatureId) {\n\t\tconst deleted = this._vectorSource.getFeatureById(id);\n\t\tif (!deleted) {\n\t\t\treturn;\n\t\t}\n\t\tthis._vectorSource.removeFeature(deleted);\n\t}\n\n\t/**\n\t * Sorts an array of DOM elements based on their order in the document, from earliest to latest.\n\t * @param elements - An array of `HTMLElement` objects to be sorted.\n\t * @returns A new array of `HTMLElement` objects sorted by their document order.\n\t */\n\tprivate sortElementsByDOMOrder(elements: HTMLElement[]) {\n\t\t// Sort the elements based on their DOM position\n\t\treturn elements.sort((a, b) => {\n\t\t\tconst position = a.compareDocumentPosition(b);\n\n\t\t\t// If a comes before b in the DOM\n\t\t\tif (position & Node.DOCUMENT_POSITION_FOLLOWING) {\n\t\t\t\treturn -1;\n\t\t\t}\n\n\t\t\t// If a comes after b in the DOM\n\t\t\tif (position & Node.DOCUMENT_POSITION_PRECEDING) {\n\t\t\t\treturn 1;\n\t\t\t}\n\n\t\t\t// If they are the same element\n\t\t\treturn 0;\n\t\t});\n\t}\n\n\t/**\n\t * Returns the longitude and latitude coordinates from a given PointerEvent on the map.\n\t * @param event The PointerEvent or MouseEvent containing the screen coordinates of the pointer.\n\t * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude, or null if the conversion is not possible.\n\t */\n\tpublic getLngLatFromEvent(event: PointerEvent | MouseEvent) {\n\t\tconst { containerX: x, containerY: y } =\n\t\t\tthis.getMapElementXYPosition(event);\n\t\ttry {\n\t\t\treturn this.unproject(x, y);\n\t\t} catch (_) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * Retrieves the HTML element of the OpenLayers element that handles interaction events\n\t * @returns The HTMLElement representing the map container.\n\t */\n\tpublic getMapEventElement() {\n\t\t// Each VectorLayer has a canvas element that is used to render the features, it orders\n\t\t// these in the order they are added to the map. The last canvas is the one that is on top\n\t\t// so we need to add the event listeners to this canvas so that the events are captured.\n\t\tconst canvases = Array.from(this._container.querySelectorAll(\"canvas\"));\n\t\tconst sortedCanvases = this.sortElementsByDOMOrder(\n\t\t\tcanvases,\n\t\t) as HTMLCanvasElement[];\n\t\tconst topCanvas = sortedCanvases[sortedCanvases.length - 1];\n\n\t\treturn topCanvas;\n\t}\n\n\t/**\n\t * Enables or disables the draggable functionality of the map.\n\t * @param enabled Set to true to enable map dragging, or false to disable it.\n\t */\n\tpublic setDraggability(enabled: boolean) {\n\t\tthis._map.getInteractions().forEach((interaction) => {\n\t\t\tif (interaction.constructor.name === \"DragPan\") {\n\t\t\t\tinteraction.setActive(enabled);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Converts longitude and latitude coordinates to pixel coordinates in the map container.\n\t * @param lng The longitude coordinate to project.\n\t * @param lat The latitude coordinate to project.\n\t * @returns An object with 'x' and 'y' properties representing the pixel coordinates within the map container.\n\t */\n\tpublic project(lng: number, lat: number) {\n\t\tconst [x, y] = this._map.getPixelFromCoordinate(\n\t\t\tthis._lib.fromLonLat([lng, lat], this._projection()) as Coordinate,\n\t\t);\n\t\treturn { x, y };\n\t}\n\n\t/**\n\t * Converts pixel coordinates in the map container to longitude and latitude coordinates.\n\t * @param x The x-coordinate in the map container to unproject.\n\t * @param y The y-coordinate in the map container to unproject.\n\t * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude coordinates.\n\t */\n\tpublic unproject(x: number, y: number) {\n\t\tconst [lng, lat] = this._lib.toLonLat(\n\t\t\tthis._map.getCoordinateFromPixel([x, y]) as Pixel,\n\t\t\tthis._projection(),\n\t\t);\n\t\treturn { lng, lat };\n\t}\n\n\t/**\n\t * Sets the cursor style for the map container.\n\t * @param cursor The CSS cursor style to apply, or 'unset' to remove any previously applied cursor style.\n\t */\n\tpublic setCursor(cursor: Parameters<SetCursor>[0]) {\n\t\tif (cursor === \"unset\") {\n\t\t\tthis.getMapEventElement().style.removeProperty(\"cursor\");\n\t\t} else {\n\t\t\tthis.getMapEventElement().style.cursor = cursor;\n\t\t}\n\t}\n\n\t/**\n\t * Enables or disables the double-click to zoom functionality on the map.\n\t * @param enabled Set to true to enable double-click to zoom, or false to disable it.\n\t */\n\tpublic setDoubleClickToZoom(enabled: boolean) {\n\t\tthis._map.getInteractions().forEach(function (interaction) {\n\t\t\tif (interaction.constructor.name === \"DoubleClickZoom\") {\n\t\t\t\tinteraction.setActive(enabled);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Renders GeoJSON features on the map using the provided styling configuration.\n\t * @param changes An object containing arrays of created, updated, and unchanged features to render.\n\t * @param styling An object mapping draw modes to feature styling functions\n\t */\n\tpublic render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction) {\n\t\tthis.stylingFunction = () => styling;\n\n\t\tchanges.deletedIds.forEach((id) => {\n\t\t\tthis.removeFeature(id);\n\t\t});\n\n\t\tchanges.updated.forEach((feature) => {\n\t\t\tthis.removeFeature(feature.id as TerraDrawExtend.FeatureId);\n\t\t\tthis.addFeature(feature);\n\t\t});\n\n\t\tchanges.created.forEach((feature) => {\n\t\t\tthis.addFeature(feature);\n\t\t});\n\t}\n\n\t/**\n\t * Clears the map and store of all rendered data layers\n\t * @returns void\n\t * */\n\tpublic clear() {\n\t\tif (this._currentModeCallbacks) {\n\t\t\t// Clean up state first\n\t\t\tthis._currentModeCallbacks.onClear();\n\n\t\t\t// Then clean up rendering\n\t\t\tthis.clearLayers();\n\t\t}\n\t}\n\n\tprivate registeredLayerHandlers:\n\t\t| undefined\n\t\t| { addLayers: () => void; removeLayers: () => void };\n\n\tpublic register(callbacks: TerraDrawExtend.TerraDrawCallbacks) {\n\t\tsuper.register(callbacks);\n\n\t\t// We need to handle the complex case in OpenLayers where adding and removing layers\n\t\t// can change the canvas ordering preventing the event listeners from working correctly\n\t\tif (!this.registeredLayerHandlers) {\n\t\t\tconst layerGroup = this._map.getLayerGroup();\n\t\t\tconst layers = layerGroup.getLayers();\n\n\t\t\tconst removeListeners = () => {\n\t\t\t\tthis._listeners.forEach((listener) => {\n\t\t\t\t\tlistener.unregister();\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tconst addListeners = () => {\n\t\t\t\tthis._listeners = this.getAdapterListeners();\n\n\t\t\t\tthis._listeners.forEach((listener) => {\n\t\t\t\t\tlistener.register();\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tthis.registeredLayerHandlers = {\n\t\t\t\taddLayers: () => {\n\t\t\t\t\tremoveListeners();\n\t\t\t\t\tthis._map.once(\"rendercomplete\", () => {\n\t\t\t\t\t\tif (this._currentModeCallbacks) {\n\t\t\t\t\t\t\taddListeners();\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tremoveLayers: () => {\n\t\t\t\t\tremoveListeners();\n\t\t\t\t\tthis._map.once(\"rendercomplete\", () => {\n\t\t\t\t\t\tif (this._currentModeCallbacks) {\n\t\t\t\t\t\t\taddListeners();\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tlayers.on(\"add\", () => {\n\t\t\t\tremoveListeners();\n\t\t\t\tthis._map.once(\"rendercomplete\", () => {\n\t\t\t\t\tif (this._currentModeCallbacks) {\n\t\t\t\t\t\taddListeners();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tlayers.on(\"remove\", () => {\n\t\t\t\tremoveListeners();\n\t\t\t\tthis._map.once(\"rendercomplete\", () => {\n\t\t\t\t\tif (this._currentModeCallbacks) {\n\t\t\t\t\t\taddListeners();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\tif (this._currentModeCallbacks?.onReady) {\n\t\t\tthis._currentModeCallbacks.onReady();\n\t\t}\n\t}\n\n\tpublic getCoordinatePrecision(): number {\n\t\treturn super.getCoordinatePrecision();\n\t}\n\n\tpublic unregister(): void {\n\t\tif (this.registeredLayerHandlers) {\n\t\t\tconst layerGroup = this._map.getLayerGroup();\n\t\t\tif (layerGroup) {\n\t\t\t\tconst layers = layerGroup.getLayers();\n\n\t\t\t\tif (layers) {\n\t\t\t\t\tlayers.un(\"add\", this.registeredLayerHandlers.addLayers);\n\t\t\t\t\tlayers.un(\"remove\", this.registeredLayerHandlers.removeLayers);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn super.unregister();\n\t}\n}\n"],"names":["TerraDrawOpenLayersAdapter","_TerraDrawExtend$Terr","config","_config$zIndex","_this","call","this","baseZIndex","stylingFunction","_lib","_map","_container","_projection","_vectorSource","_geoJSONReader","registeredLayerHandlers","map","lib","GeoJSON","_this$_lib$getUserPro","getUserProjection","Projection","code","getViewport","setAttribute","vectorSource","VectorSource","features","zIndex","vectorLayer","VectorLayer","source","style","feature","getStyles","addLayer","_proto","prototype","hexToRGB","hex","r","parseInt","slice","g","b","styling","_this2","geometry","getGeometry","Point","properties","getProperties","mode","type","coordinates","Style","markerUrl","markerWidth","markerHeight","image","Icon","src","width","height","anchor","Circle","radius","pointWidth","fill","Fill","color","pointColor","stroke","Stroke","pointOutlineColor","pointOutlineWidth","LineString","lineStringColor","lineStringWidth","Polygon","_this2$hexToRGB","polygonFillColor","polygonOutlineColor","polygonOutlineWidth","polygonFillOpacity","getType","clearLayers","clear","addFeature","olFeature","readFeature","dataProjection","featureProjection","removeFeature","id","deleted","getFeatureById","sortElementsByDOMOrder","elements","sort","a","position","compareDocumentPosition","Node","DOCUMENT_POSITION_FOLLOWING","DOCUMENT_POSITION_PRECEDING","getLngLatFromEvent","event","_this$getMapElementXY","getMapElementXYPosition","x","containerX","y","containerY","unproject","_","getMapEventElement","canvases","Array","from","querySelectorAll","sortedCanvases","length","setDraggability","enabled","getInteractions","forEach","interaction","constructor","name","setActive","project","lng","lat","_this$_map$getPixelFr","getPixelFromCoordinate","fromLonLat","_this$_lib$toLonLat","toLonLat","getCoordinateFromPixel","setCursor","cursor","removeProperty","setDoubleClickToZoom","render","changes","_this3","deletedIds","updated","created","_currentModeCallbacks","onClear","register","callbacks","_this$_currentModeCal","_this4","layers","getLayerGroup","getLayers","removeListeners","_listeners","listener","unregister","addListeners","getAdapterListeners","addLayers","once","removeLayers","on","onReady","getCoordinatePrecision","layerGroup","un","TerraDrawExtend","TerraDrawBaseAdapter"],"mappings":"sKA2Ca,IAAAA,eAA2B,SAAAC,GACvC,SAAAD,EACCE,GAIqC,IAAAC,EAAAC,GAErCA,EAAAH,EAAAI,KAAAC,KAAMJ,UAkCCK,WAAa,IAAMH,EACnBI,gBAAkB,WAAO,MAAA,CA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,KAAKS,wBAAwBwJ,cAEnD,CACD,CAEA,OAAAtK,EAAAoC,UAAa6H,WAAU7J,KAAAC,KACxB,EAACN,CAAA,CAhasC,CAAQ6K,EAAgBC"}
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("terra-draw")):"function"==typeof define&&define.amd?define(["exports","terra-draw"],t):t((e||self).terraDrawOpenlayersAdapter={},e.terraDraw)}(this,function(e,t){function r(e,t){return r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},r(e,t)}e.TerraDrawOpenLayersAdapter=/*#__PURE__*/function(e){function t(t){var r,n;(n=e.call(this,t)||this).baseZIndex=1e5,n.stylingFunction=function(){return{}},n._lib=void 0,n._map=void 0,n._container=void 0,n._projection=void 0,n._vectorSource=void 0,n._geoJSONReader=void 0,n.registeredLayerHandlers=void 0,n._map=t.map,n._lib=t.lib,n._geoJSONReader=new n._lib.GeoJSON,n._projection=function(){var e;return null!=(e=n._lib.getUserProjection())?e:new n._lib.Projection({code:"EPSG:3857"})},n._container=n._map.getViewport(),n._container.setAttribute("tabindex","0");var o=new n._lib.VectorSource({features:[]});n._vectorSource=o,n.baseZIndex=null!=(r=t.zIndex)?r:1e5;var i=new n._lib.VectorLayer({source:o,style:function(e){return n.getStyles(e,n.stylingFunction())},zIndex:n.baseZIndex});return n._map.addLayer(i),n}var n,o;o=e,(n=t).prototype=Object.create(o.prototype),n.prototype.constructor=n,r(n,o);var i=t.prototype;return i.hexToRGB=function(e){return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16)}},i.getStyles=function(e,t){var r=this,n=e.getGeometry();if(n)return{Point:function(e){var n=e.getProperties(),o=t[n.mode]({type:"Feature",geometry:{type:"Point",coordinates:[]},properties:n});return new r._lib.Style({zIndex:r.baseZIndex+o.zIndex,image:new r._lib.Circle({radius:o.pointWidth,fill:new r._lib.Fill({color:o.pointColor}),stroke:new r._lib.Stroke({color:o.pointOutlineColor,width:o.pointOutlineWidth})})})},LineString:function(e){var n=e.getProperties(),o=t[n.mode]({type:"Feature",geometry:{type:"LineString",coordinates:[]},properties:n});return new r._lib.Style({zIndex:o.zIndex,stroke:new r._lib.Stroke({color:o.lineStringColor,width:o.lineStringWidth})})},Polygon:function(e){var n=e.getProperties(),o=t[n.mode]({type:"Feature",geometry:{type:"Polygon",coordinates:[]},properties:n}),i=r.hexToRGB(o.polygonFillColor),a=i.r,c=i.g,s=i.b;return new r._lib.Style({zIndex:o.zIndex,stroke:new r._lib.Stroke({color:o.polygonOutlineColor,width:o.polygonOutlineWidth}),fill:new r._lib.Fill({color:"rgba("+a+","+c+","+s+","+o.polygonFillOpacity+")"})})}}[n.getType()](e)},i.clearLayers=function(){this._vectorSource&&this._vectorSource.clear()},i.addFeature=function(e){var t=this._geoJSONReader.readFeature(e,{dataProjection:"EPSG:4326",featureProjection:this._projection()});this._vectorSource.addFeature(t)},i.removeFeature=function(e){var t=this._vectorSource.getFeatureById(e);t&&this._vectorSource.removeFeature(t)},i.sortElementsByDOMOrder=function(e){return e.sort(function(e,t){var r=e.compareDocumentPosition(t);return r&Node.DOCUMENT_POSITION_FOLLOWING?-1:r&Node.DOCUMENT_POSITION_PRECEDING?1:0})},i.getLngLatFromEvent=function(e){var t=this.getMapElementXYPosition(e),r=t.containerX,n=t.containerY;try{return this.unproject(r,n)}catch(e){return null}},i.getMapEventElement=function(){var e=Array.from(this._container.querySelectorAll("canvas")),t=this.sortElementsByDOMOrder(e);return t[t.length-1]},i.setDraggability=function(e){this._map.getInteractions().forEach(function(t){"DragPan"===t.constructor.name&&t.setActive(e)})},i.project=function(e,t){var r=this._map.getPixelFromCoordinate(this._lib.fromLonLat([e,t],this._projection()));return{x:r[0],y:r[1]}},i.unproject=function(e,t){var r=this._lib.toLonLat(this._map.getCoordinateFromPixel([e,t]),this._projection());return{lng:r[0],lat:r[1]}},i.setCursor=function(e){"unset"===e?this.getMapEventElement().style.removeProperty("cursor"):this.getMapEventElement().style.cursor=e},i.setDoubleClickToZoom=function(e){this._map.getInteractions().forEach(function(t){"DoubleClickZoom"===t.constructor.name&&t.setActive(e)})},i.render=function(e,t){var r=this;this.stylingFunction=function(){return t},e.deletedIds.forEach(function(e){r.removeFeature(e)}),e.updated.forEach(function(e){r.removeFeature(e.id),r.addFeature(e)}),e.created.forEach(function(e){r.addFeature(e)})},i.clear=function(){this._currentModeCallbacks&&(this._currentModeCallbacks.onClear(),this.clearLayers())},i.register=function(t){var r,n=this;if(e.prototype.register.call(this,t),!this.registeredLayerHandlers){var o=this._map.getLayerGroup().getLayers(),i=function(){n._listeners.forEach(function(e){e.unregister()})},a=function(){n._listeners=n.getAdapterListeners(),n._listeners.forEach(function(e){e.register()})};this.registeredLayerHandlers={addLayers:function(){i(),n._map.once("rendercomplete",function(){n._currentModeCallbacks&&a()})},removeLayers:function(){i(),n._map.once("rendercomplete",function(){n._currentModeCallbacks&&a()})}},o.on("add",function(){i(),n._map.once("rendercomplete",function(){n._currentModeCallbacks&&a()})}),o.on("remove",function(){i(),n._map.once("rendercomplete",function(){n._currentModeCallbacks&&a()})})}null!=(r=this._currentModeCallbacks)&&r.onReady&&this._currentModeCallbacks.onReady()},i.getCoordinatePrecision=function(){return e.prototype.getCoordinatePrecision.call(this)},i.unregister=function(){if(this.registeredLayerHandlers){var t=this._map.getLayerGroup();if(t){var r=t.getLayers();r&&(r.un("add",this.registeredLayerHandlers.addLayers),r.un("remove",this.registeredLayerHandlers.removeLayers))}}return e.prototype.unregister.call(this)},t}(t.TerraDrawExtend.TerraDrawBaseAdapter)});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("terra-draw")):"function"==typeof define&&define.amd?define(["exports","terra-draw"],t):t((e||self).terraDrawOpenlayersAdapter={},e.terraDraw)}(this,function(e,t){function r(e,t){return r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},r(e,t)}e.TerraDrawOpenLayersAdapter=/*#__PURE__*/function(e){function t(t){var r,n;(n=e.call(this,t)||this).baseZIndex=1e5,n.stylingFunction=function(){return{}},n._lib=void 0,n._map=void 0,n._container=void 0,n._projection=void 0,n._vectorSource=void 0,n._geoJSONReader=void 0,n.registeredLayerHandlers=void 0,n._map=t.map,n._lib=t.lib,n._geoJSONReader=new n._lib.GeoJSON,n._projection=function(){var e;return null!=(e=n._lib.getUserProjection())?e:new n._lib.Projection({code:"EPSG:3857"})},n._container=n._map.getViewport(),n._container.setAttribute("tabindex","0");var o=new n._lib.VectorSource({features:[]});n._vectorSource=o,n.baseZIndex=null!=(r=t.zIndex)?r:1e5;var i=new n._lib.VectorLayer({source:o,style:function(e){return n.getStyles(e,n.stylingFunction())},zIndex:n.baseZIndex});return n._map.addLayer(i),n}var n,o;o=e,(n=t).prototype=Object.create(o.prototype),n.prototype.constructor=n,r(n,o);var i=t.prototype;return i.hexToRGB=function(e){return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16)}},i.getStyles=function(e,t){var r=this,n=e.getGeometry();if(n)return{Point:function(e){var n=e.getProperties(),o=t[n.mode]({type:"Feature",geometry:{type:"Point",coordinates:[]},properties:n});return new r._lib.Style(o.markerUrl&&o.markerWidth&&o.markerHeight?{zIndex:r.baseZIndex+o.zIndex,image:new r._lib.Icon({src:o.markerUrl,width:o.markerWidth,height:o.markerHeight,anchor:[.5,1]})}:{zIndex:r.baseZIndex+o.zIndex,image:new r._lib.Circle({radius:o.pointWidth,fill:new r._lib.Fill({color:o.pointColor}),stroke:new r._lib.Stroke({color:o.pointOutlineColor,width:o.pointOutlineWidth})})})},LineString:function(e){var n=e.getProperties(),o=t[n.mode]({type:"Feature",geometry:{type:"LineString",coordinates:[]},properties:n});return new r._lib.Style({zIndex:o.zIndex,stroke:new r._lib.Stroke({color:o.lineStringColor,width:o.lineStringWidth})})},Polygon:function(e){var n=e.getProperties(),o=t[n.mode]({type:"Feature",geometry:{type:"Polygon",coordinates:[]},properties:n}),i=r.hexToRGB(o.polygonFillColor),a=i.r,c=i.g,s=i.b;return new r._lib.Style({zIndex:o.zIndex,stroke:new r._lib.Stroke({color:o.polygonOutlineColor,width:o.polygonOutlineWidth}),fill:new r._lib.Fill({color:"rgba("+a+","+c+","+s+","+o.polygonFillOpacity+")"})})}}[n.getType()](e)},i.clearLayers=function(){this._vectorSource&&this._vectorSource.clear()},i.addFeature=function(e){var t=this._geoJSONReader.readFeature(e,{dataProjection:"EPSG:4326",featureProjection:this._projection()});this._vectorSource.addFeature(t)},i.removeFeature=function(e){var t=this._vectorSource.getFeatureById(e);t&&this._vectorSource.removeFeature(t)},i.sortElementsByDOMOrder=function(e){return e.sort(function(e,t){var r=e.compareDocumentPosition(t);return r&Node.DOCUMENT_POSITION_FOLLOWING?-1:r&Node.DOCUMENT_POSITION_PRECEDING?1:0})},i.getLngLatFromEvent=function(e){var t=this.getMapElementXYPosition(e),r=t.containerX,n=t.containerY;try{return this.unproject(r,n)}catch(e){return null}},i.getMapEventElement=function(){var e=Array.from(this._container.querySelectorAll("canvas")),t=this.sortElementsByDOMOrder(e);return t[t.length-1]},i.setDraggability=function(e){this._map.getInteractions().forEach(function(t){"DragPan"===t.constructor.name&&t.setActive(e)})},i.project=function(e,t){var r=this._map.getPixelFromCoordinate(this._lib.fromLonLat([e,t],this._projection()));return{x:r[0],y:r[1]}},i.unproject=function(e,t){var r=this._lib.toLonLat(this._map.getCoordinateFromPixel([e,t]),this._projection());return{lng:r[0],lat:r[1]}},i.setCursor=function(e){"unset"===e?this.getMapEventElement().style.removeProperty("cursor"):this.getMapEventElement().style.cursor=e},i.setDoubleClickToZoom=function(e){this._map.getInteractions().forEach(function(t){"DoubleClickZoom"===t.constructor.name&&t.setActive(e)})},i.render=function(e,t){var r=this;this.stylingFunction=function(){return t},e.deletedIds.forEach(function(e){r.removeFeature(e)}),e.updated.forEach(function(e){r.removeFeature(e.id),r.addFeature(e)}),e.created.forEach(function(e){r.addFeature(e)})},i.clear=function(){this._currentModeCallbacks&&(this._currentModeCallbacks.onClear(),this.clearLayers())},i.register=function(t){var r,n=this;if(e.prototype.register.call(this,t),!this.registeredLayerHandlers){var o=this._map.getLayerGroup().getLayers(),i=function(){n._listeners.forEach(function(e){e.unregister()})},a=function(){n._listeners=n.getAdapterListeners(),n._listeners.forEach(function(e){e.register()})};this.registeredLayerHandlers={addLayers:function(){i(),n._map.once("rendercomplete",function(){n._currentModeCallbacks&&a()})},removeLayers:function(){i(),n._map.once("rendercomplete",function(){n._currentModeCallbacks&&a()})}},o.on("add",function(){i(),n._map.once("rendercomplete",function(){n._currentModeCallbacks&&a()})}),o.on("remove",function(){i(),n._map.once("rendercomplete",function(){n._currentModeCallbacks&&a()})})}null!=(r=this._currentModeCallbacks)&&r.onReady&&this._currentModeCallbacks.onReady()},i.getCoordinatePrecision=function(){return e.prototype.getCoordinatePrecision.call(this)},i.unregister=function(){if(this.registeredLayerHandlers){var t=this._map.getLayerGroup();if(t){var r=t.getLayers();r&&(r.un("add",this.registeredLayerHandlers.addLayers),r.un("remove",this.registeredLayerHandlers.removeLayers))}}return e.prototype.unregister.call(this)},t}(t.TerraDrawExtend.TerraDrawBaseAdapter)});
2
2
  //# sourceMappingURL=terra-draw-openlayers-adapter.umd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"terra-draw-openlayers-adapter.umd.js","sources":["../src/terra-draw-openlayers-adapter.ts"],"sourcesContent":["/**\n * @module terra-draw-openlayers-adapter\n */\nimport {\n\tTerraDrawChanges,\n\tSetCursor,\n\tTerraDrawStylingFunction,\n\tGeoJSONStoreFeatures,\n\tTerraDrawExtend,\n} from \"terra-draw\";\n\nimport Feature, { FeatureLike } from \"ol/Feature\";\nimport GeoJSON from \"ol/format/GeoJSON\";\nimport Map from \"ol/Map\";\nimport Circle from \"ol/style/Circle\";\nimport Fill from \"ol/style/Fill\";\nimport Stroke from \"ol/style/Stroke\";\nimport Style from \"ol/style/Style\";\nimport VectorSource from \"ol/source/Vector\";\nimport { Geometry } from \"ol/geom\";\nimport VectorLayer from \"ol/layer/Vector\";\nimport Projection from \"ol/proj/Projection\";\nimport { fromLonLat, toLonLat, getUserProjection } from \"ol/proj\";\nimport { Coordinate } from \"ol/coordinate\";\nimport { Pixel } from \"ol/pixel\";\n\nexport type InjectableOL = {\n\tFill: typeof Fill;\n\tFeature: typeof Feature;\n\tGeoJSON: typeof GeoJSON;\n\tStyle: typeof Style;\n\tCircle: typeof Circle;\n\tVectorLayer: typeof VectorLayer;\n\tVectorSource: typeof VectorSource;\n\tStroke: typeof Stroke;\n\tProjection: typeof Projection;\n\tgetUserProjection: typeof getUserProjection;\n\tfromLonLat: typeof fromLonLat;\n\ttoLonLat: typeof toLonLat;\n};\n\nexport class TerraDrawOpenLayersAdapter extends TerraDrawExtend.TerraDrawBaseAdapter {\n\tconstructor(\n\t\tconfig: {\n\t\t\tmap: Map;\n\t\t\tlib: InjectableOL;\n\t\t\tzIndex?: number;\n\t\t} & TerraDrawExtend.BaseAdapterConfig,\n\t) {\n\t\tsuper(config);\n\n\t\tthis._map = config.map;\n\t\tthis._lib = config.lib;\n\n\t\tthis._geoJSONReader = new this._lib.GeoJSON();\n\t\tthis._projection = () =>\n\t\t\tthis._lib.getUserProjection() ??\n\t\t\tnew this._lib.Projection({ code: \"EPSG:3857\" });\n\n\t\tthis._container = this._map.getViewport();\n\n\t\t// TODO: Is this the best way to receive keyboard events\n\t\tthis._container.setAttribute(\"tabindex\", \"0\");\n\n\t\tconst vectorSource = new this._lib.VectorSource({\n\t\t\tfeatures: [],\n\t\t}) as unknown as VectorSource<Feature<Geometry>>;\n\n\t\tthis._vectorSource = vectorSource as unknown as VectorSource<\n\t\t\tFeature<Geometry>\n\t\t>;\n\n\t\tthis.baseZIndex = config.zIndex ?? 100000;\n\n\t\tconst vectorLayer = new this._lib.VectorLayer({\n\t\t\tsource: vectorSource as unknown as VectorSource<never>,\n\t\t\tstyle: (feature) => this.getStyles(feature, this.stylingFunction()),\n\t\t\tzIndex: this.baseZIndex,\n\t\t});\n\n\t\tthis._map.addLayer(vectorLayer);\n\t}\n\n\tprivate baseZIndex = 100000;\n\tprivate stylingFunction = () => ({});\n\n\tprivate _lib: InjectableOL;\n\tprivate _map: Map;\n\tprivate _container: HTMLElement;\n\tprivate _projection: () => Projection;\n\tprivate _vectorSource: VectorSource<Feature<Geometry>>;\n\tprivate _geoJSONReader: GeoJSON;\n\n\t/**\n\t * Converts a hexadecimal color to RGB\n\t * @param hex a string of the hexadecimal string\n\t * @returns an object to red green and blue (RGB) color\n\t */\n\tprivate hexToRGB(hex: string): { r: number; g: number; b: number } {\n\t\treturn {\n\t\t\tr: parseInt(hex.slice(1, 3), 16),\n\t\t\tg: parseInt(hex.slice(3, 5), 16),\n\t\t\tb: parseInt(hex.slice(5, 7), 16),\n\t\t};\n\t}\n\n\tprivate getStyles(feature: FeatureLike, styling: TerraDrawStylingFunction) {\n\t\tconst geometry = feature.getGeometry();\n\t\tif (!geometry) {\n\t\t\treturn;\n\t\t}\n\t\tconst key = geometry.getType() as \"Point\" | \"LineString\" | \"Polygon\";\n\n\t\treturn {\n\t\t\tPoint: (feature: FeatureLike) => {\n\t\t\t\tconst properties = feature.getProperties();\n\t\t\t\tconst style = styling[properties.mode]({\n\t\t\t\t\ttype: \"Feature\",\n\t\t\t\t\tgeometry: { type: \"Point\", coordinates: [] },\n\t\t\t\t\tproperties,\n\t\t\t\t});\n\t\t\t\treturn new this._lib.Style({\n\t\t\t\t\tzIndex: this.baseZIndex + style.zIndex,\n\t\t\t\t\timage: new this._lib.Circle({\n\t\t\t\t\t\tradius: style.pointWidth,\n\t\t\t\t\t\tfill: new this._lib.Fill({\n\t\t\t\t\t\t\tcolor: style.pointColor,\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tstroke: new this._lib.Stroke({\n\t\t\t\t\t\t\tcolor: style.pointOutlineColor,\n\t\t\t\t\t\t\twidth: style.pointOutlineWidth,\n\t\t\t\t\t\t}),\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t},\n\t\t\tLineString: (feature: FeatureLike) => {\n\t\t\t\tconst properties = feature.getProperties();\n\t\t\t\tconst style = styling[properties.mode]({\n\t\t\t\t\ttype: \"Feature\",\n\t\t\t\t\tgeometry: { type: \"LineString\", coordinates: [] },\n\t\t\t\t\tproperties,\n\t\t\t\t});\n\t\t\t\treturn new this._lib.Style({\n\t\t\t\t\tzIndex: style.zIndex,\n\t\t\t\t\tstroke: new this._lib.Stroke({\n\t\t\t\t\t\tcolor: style.lineStringColor,\n\t\t\t\t\t\twidth: style.lineStringWidth,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t},\n\t\t\tPolygon: (feature: FeatureLike) => {\n\t\t\t\tconst properties = feature.getProperties();\n\t\t\t\tconst style = styling[properties.mode]({\n\t\t\t\t\ttype: \"Feature\",\n\t\t\t\t\tgeometry: { type: \"Polygon\", coordinates: [] },\n\n\t\t\t\t\tproperties,\n\t\t\t\t});\n\t\t\t\tconst { r, g, b } = this.hexToRGB(style.polygonFillColor);\n\n\t\t\t\treturn new this._lib.Style({\n\t\t\t\t\tzIndex: style.zIndex,\n\t\t\t\t\tstroke: new this._lib.Stroke({\n\t\t\t\t\t\tcolor: style.polygonOutlineColor,\n\t\t\t\t\t\twidth: style.polygonOutlineWidth,\n\t\t\t\t\t}),\n\t\t\t\t\tfill: new this._lib.Fill({\n\t\t\t\t\t\tcolor: `rgba(${r},${g},${b},${style.polygonFillOpacity})`,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t},\n\t\t}[key](feature);\n\t}\n\n\t/**\n\t * Clears the layers created by the adapter\n\t * @returns void\n\t * */\n\tprivate clearLayers() {\n\t\tif (this._vectorSource) {\n\t\t\tthis._vectorSource.clear();\n\t\t}\n\t}\n\n\tprivate addFeature(feature: GeoJSONStoreFeatures) {\n\t\tconst olFeature = this._geoJSONReader.readFeature(feature, {\n\t\t\tdataProjection: \"EPSG:4326\",\n\t\t\tfeatureProjection: this._projection(),\n\t\t}) as Feature<Geometry>;\n\t\tthis._vectorSource.addFeature(olFeature);\n\t}\n\n\tprivate removeFeature(id: TerraDrawExtend.FeatureId) {\n\t\tconst deleted = this._vectorSource.getFeatureById(id);\n\t\tif (!deleted) {\n\t\t\treturn;\n\t\t}\n\t\tthis._vectorSource.removeFeature(deleted);\n\t}\n\n\t/**\n\t * Sorts an array of DOM elements based on their order in the document, from earliest to latest.\n\t * @param elements - An array of `HTMLElement` objects to be sorted.\n\t * @returns A new array of `HTMLElement` objects sorted by their document order.\n\t */\n\tprivate sortElementsByDOMOrder(elements: HTMLElement[]) {\n\t\t// Sort the elements based on their DOM position\n\t\treturn elements.sort((a, b) => {\n\t\t\tconst position = a.compareDocumentPosition(b);\n\n\t\t\t// If a comes before b in the DOM\n\t\t\tif (position & Node.DOCUMENT_POSITION_FOLLOWING) {\n\t\t\t\treturn -1;\n\t\t\t}\n\n\t\t\t// If a comes after b in the DOM\n\t\t\tif (position & Node.DOCUMENT_POSITION_PRECEDING) {\n\t\t\t\treturn 1;\n\t\t\t}\n\n\t\t\t// If they are the same element\n\t\t\treturn 0;\n\t\t});\n\t}\n\n\t/**\n\t * Returns the longitude and latitude coordinates from a given PointerEvent on the map.\n\t * @param event The PointerEvent or MouseEvent containing the screen coordinates of the pointer.\n\t * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude, or null if the conversion is not possible.\n\t */\n\tpublic getLngLatFromEvent(event: PointerEvent | MouseEvent) {\n\t\tconst { containerX: x, containerY: y } =\n\t\t\tthis.getMapElementXYPosition(event);\n\t\ttry {\n\t\t\treturn this.unproject(x, y);\n\t\t} catch (_) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * Retrieves the HTML element of the OpenLayers element that handles interaction events\n\t * @returns The HTMLElement representing the map container.\n\t */\n\tpublic getMapEventElement() {\n\t\t// Each VectorLayer has a canvas element that is used to render the features, it orders\n\t\t// these in the order they are added to the map. The last canvas is the one that is on top\n\t\t// so we need to add the event listeners to this canvas so that the events are captured.\n\t\tconst canvases = Array.from(this._container.querySelectorAll(\"canvas\"));\n\t\tconst sortedCanvases = this.sortElementsByDOMOrder(\n\t\t\tcanvases,\n\t\t) as HTMLCanvasElement[];\n\t\tconst topCanvas = sortedCanvases[sortedCanvases.length - 1];\n\n\t\treturn topCanvas;\n\t}\n\n\t/**\n\t * Enables or disables the draggable functionality of the map.\n\t * @param enabled Set to true to enable map dragging, or false to disable it.\n\t */\n\tpublic setDraggability(enabled: boolean) {\n\t\tthis._map.getInteractions().forEach((interaction) => {\n\t\t\tif (interaction.constructor.name === \"DragPan\") {\n\t\t\t\tinteraction.setActive(enabled);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Converts longitude and latitude coordinates to pixel coordinates in the map container.\n\t * @param lng The longitude coordinate to project.\n\t * @param lat The latitude coordinate to project.\n\t * @returns An object with 'x' and 'y' properties representing the pixel coordinates within the map container.\n\t */\n\tpublic project(lng: number, lat: number) {\n\t\tconst [x, y] = this._map.getPixelFromCoordinate(\n\t\t\tthis._lib.fromLonLat([lng, lat], this._projection()) as Coordinate,\n\t\t);\n\t\treturn { x, y };\n\t}\n\n\t/**\n\t * Converts pixel coordinates in the map container to longitude and latitude coordinates.\n\t * @param x The x-coordinate in the map container to unproject.\n\t * @param y The y-coordinate in the map container to unproject.\n\t * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude coordinates.\n\t */\n\tpublic unproject(x: number, y: number) {\n\t\tconst [lng, lat] = this._lib.toLonLat(\n\t\t\tthis._map.getCoordinateFromPixel([x, y]) as Pixel,\n\t\t\tthis._projection(),\n\t\t);\n\t\treturn { lng, lat };\n\t}\n\n\t/**\n\t * Sets the cursor style for the map container.\n\t * @param cursor The CSS cursor style to apply, or 'unset' to remove any previously applied cursor style.\n\t */\n\tpublic setCursor(cursor: Parameters<SetCursor>[0]) {\n\t\tif (cursor === \"unset\") {\n\t\t\tthis.getMapEventElement().style.removeProperty(\"cursor\");\n\t\t} else {\n\t\t\tthis.getMapEventElement().style.cursor = cursor;\n\t\t}\n\t}\n\n\t/**\n\t * Enables or disables the double-click to zoom functionality on the map.\n\t * @param enabled Set to true to enable double-click to zoom, or false to disable it.\n\t */\n\tpublic setDoubleClickToZoom(enabled: boolean) {\n\t\tthis._map.getInteractions().forEach(function (interaction) {\n\t\t\tif (interaction.constructor.name === \"DoubleClickZoom\") {\n\t\t\t\tinteraction.setActive(enabled);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Renders GeoJSON features on the map using the provided styling configuration.\n\t * @param changes An object containing arrays of created, updated, and unchanged features to render.\n\t * @param styling An object mapping draw modes to feature styling functions\n\t */\n\tpublic render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction) {\n\t\tthis.stylingFunction = () => styling;\n\n\t\tchanges.deletedIds.forEach((id) => {\n\t\t\tthis.removeFeature(id);\n\t\t});\n\n\t\tchanges.updated.forEach((feature) => {\n\t\t\tthis.removeFeature(feature.id as TerraDrawExtend.FeatureId);\n\t\t\tthis.addFeature(feature);\n\t\t});\n\n\t\tchanges.created.forEach((feature) => {\n\t\t\tthis.addFeature(feature);\n\t\t});\n\t}\n\n\t/**\n\t * Clears the map and store of all rendered data layers\n\t * @returns void\n\t * */\n\tpublic clear() {\n\t\tif (this._currentModeCallbacks) {\n\t\t\t// Clean up state first\n\t\t\tthis._currentModeCallbacks.onClear();\n\n\t\t\t// Then clean up rendering\n\t\t\tthis.clearLayers();\n\t\t}\n\t}\n\n\tprivate registeredLayerHandlers:\n\t\t| undefined\n\t\t| { addLayers: () => void; removeLayers: () => void };\n\n\tpublic register(callbacks: TerraDrawExtend.TerraDrawCallbacks) {\n\t\tsuper.register(callbacks);\n\n\t\t// We need to handle the complex case in OpenLayers where adding and removing layers\n\t\t// can change the canvas ordering preventing the event listeners from working correctly\n\t\tif (!this.registeredLayerHandlers) {\n\t\t\tconst layerGroup = this._map.getLayerGroup();\n\t\t\tconst layers = layerGroup.getLayers();\n\n\t\t\tconst removeListeners = () => {\n\t\t\t\tthis._listeners.forEach((listener) => {\n\t\t\t\t\tlistener.unregister();\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tconst addListeners = () => {\n\t\t\t\tthis._listeners = this.getAdapterListeners();\n\n\t\t\t\tthis._listeners.forEach((listener) => {\n\t\t\t\t\tlistener.register();\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tthis.registeredLayerHandlers = {\n\t\t\t\taddLayers: () => {\n\t\t\t\t\tremoveListeners();\n\t\t\t\t\tthis._map.once(\"rendercomplete\", () => {\n\t\t\t\t\t\tif (this._currentModeCallbacks) {\n\t\t\t\t\t\t\taddListeners();\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tremoveLayers: () => {\n\t\t\t\t\tremoveListeners();\n\t\t\t\t\tthis._map.once(\"rendercomplete\", () => {\n\t\t\t\t\t\tif (this._currentModeCallbacks) {\n\t\t\t\t\t\t\taddListeners();\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tlayers.on(\"add\", () => {\n\t\t\t\tremoveListeners();\n\t\t\t\tthis._map.once(\"rendercomplete\", () => {\n\t\t\t\t\tif (this._currentModeCallbacks) {\n\t\t\t\t\t\taddListeners();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tlayers.on(\"remove\", () => {\n\t\t\t\tremoveListeners();\n\t\t\t\tthis._map.once(\"rendercomplete\", () => {\n\t\t\t\t\tif (this._currentModeCallbacks) {\n\t\t\t\t\t\taddListeners();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\tif (this._currentModeCallbacks?.onReady) {\n\t\t\tthis._currentModeCallbacks.onReady();\n\t\t}\n\t}\n\n\tpublic getCoordinatePrecision(): number {\n\t\treturn super.getCoordinatePrecision();\n\t}\n\n\tpublic unregister(): void {\n\t\tif (this.registeredLayerHandlers) {\n\t\t\tconst layerGroup = this._map.getLayerGroup();\n\t\t\tif (layerGroup) {\n\t\t\t\tconst layers = layerGroup.getLayers();\n\n\t\t\t\tif (layers) {\n\t\t\t\t\tlayers.un(\"add\", this.registeredLayerHandlers.addLayers);\n\t\t\t\t\tlayers.un(\"remove\", this.registeredLayerHandlers.removeLayers);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn super.unregister();\n\t}\n}\n"],"names":["_TerraDrawExtend$Terr","TerraDrawOpenLayersAdapter","config","_config$zIndex","_this","call","baseZIndex","stylingFunction","_lib","_map","_container","_projection","_vectorSource","_geoJSONReader","registeredLayerHandlers","map","lib","GeoJSON","_this$_lib$getUserPro","getUserProjection","Projection","code","getViewport","setAttribute","vectorSource","VectorSource","features","zIndex","vectorLayer","VectorLayer","source","style","feature","getStyles","addLayer","_proto","prototype","hexToRGB","hex","r","parseInt","slice","g","b","styling","_this2","geometry","getGeometry","Point","properties","getProperties","mode","type","coordinates","Style","image","Circle","radius","pointWidth","fill","Fill","color","pointColor","stroke","Stroke","pointOutlineColor","width","pointOutlineWidth","LineString","lineStringColor","lineStringWidth","Polygon","_this2$hexToRGB","polygonFillColor","polygonOutlineColor","polygonOutlineWidth","polygonFillOpacity","getType","clearLayers","this","clear","addFeature","olFeature","readFeature","dataProjection","featureProjection","removeFeature","id","deleted","getFeatureById","sortElementsByDOMOrder","elements","sort","a","position","compareDocumentPosition","Node","DOCUMENT_POSITION_FOLLOWING","DOCUMENT_POSITION_PRECEDING","getLngLatFromEvent","event","_this$getMapElementXY","getMapElementXYPosition","x","containerX","y","containerY","unproject","_","getMapEventElement","canvases","Array","from","querySelectorAll","sortedCanvases","length","setDraggability","enabled","getInteractions","forEach","interaction","constructor","name","setActive","project","lng","lat","_this$_map$getPixelFr","getPixelFromCoordinate","fromLonLat","_this$_lib$toLonLat","toLonLat","getCoordinateFromPixel","setCursor","cursor","removeProperty","setDoubleClickToZoom","render","changes","_this3","deletedIds","updated","created","_currentModeCallbacks","onClear","register","callbacks","_this$_currentModeCal","_this4","layers","getLayerGroup","getLayers","removeListeners","_listeners","listener","unregister","addListeners","getAdapterListeners","addLayers","once","removeLayers","on","onReady","getCoordinatePrecision","layerGroup","un","TerraDrawExtend","TerraDrawBaseAdapter"],"mappings":"wcAyCwC,SAAAA,GACvC,SAAAC,EACCC,GAIqC,IAAAC,EAAAC,GAErCA,EAAAJ,EAAAK,KAAMH,KAAAA,IAAQE,MAkCPE,WAAa,IAAMF,EACnBG,gBAAkB,WAAO,MAAA,CAAA,CAAE,EAACH,EAE5BI,UAAI,EAAAJ,EACJK,UAAI,EAAAL,EACJM,gBAAU,EAAAN,EACVO,iBAAWP,EAAAA,EACXQ,qBAAaR,EACbS,oBAAc,EAAAT,EAyQdU,6BAjTPV,EAAAA,EAAKK,KAAOP,EAAOa,IACnBX,EAAKI,KAAON,EAAOc,IAEnBZ,EAAKS,eAAiB,IAAIT,EAAKI,KAAKS,QACpCb,EAAKO,YAAc,WAAA,IAAAO,EAAA,OACWA,OADXA,EAClBd,EAAKI,KAAKW,qBAAmBD,EAC7B,IAAId,EAAKI,KAAKY,WAAW,CAAEC,KAAM,aAAc,EAEhDjB,EAAKM,WAAaN,EAAKK,KAAKa,cAG5BlB,EAAKM,WAAWa,aAAa,WAAY,KAEzC,IAAMC,EAAe,IAAIpB,EAAKI,KAAKiB,aAAa,CAC/CC,SAAU,KAGXtB,EAAKQ,cAAgBY,EAIrBpB,EAAKE,WAA0BH,OAAhBA,EAAGD,EAAOyB,QAAMxB,EAAI,IAEnC,IAAMyB,EAAc,IAAIxB,EAAKI,KAAKqB,YAAY,CAC7CC,OAAQN,EACRO,MAAO,SAACC,GAAY,OAAA5B,EAAK6B,UAAUD,EAAS5B,EAAKG,kBAAkB,EACnEoB,OAAQvB,EAAKE,aAGkB,OAAhCF,EAAKK,KAAKyB,SAASN,GAAaxB,CACjC,WAACJ,KAAAC,yEAAA,IAAAkC,EAAAlC,EAAAmC,UA2WA,OA3WAD,EAiBOE,SAAA,SAASC,GAChB,MAAO,CACNC,E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AOtF,KAAKjE,wBAAwBgJ,WAC9CT,EAAOgB,GAAG,SAAUtF,KAAKjE,wBAAwBkJ,cAEnD,CACD,CAEA,OAAAhK,EAAAoC,UAAauH,WAAUtJ,KAAA0E,KACxB,EAAC9E,CAAA,CAnZsC,CAAQqK,EAAeA,gBAACC"}
1
+ {"version":3,"file":"terra-draw-openlayers-adapter.umd.js","sources":["../src/terra-draw-openlayers-adapter.ts"],"sourcesContent":["/**\n * @module terra-draw-openlayers-adapter\n */\nimport {\n\tTerraDrawChanges,\n\tSetCursor,\n\tTerraDrawStylingFunction,\n\tGeoJSONStoreFeatures,\n\tTerraDrawExtend,\n} from \"terra-draw\";\n\nimport Feature, { FeatureLike } from \"ol/Feature\";\nimport GeoJSON from \"ol/format/GeoJSON\";\nimport Map from \"ol/Map\";\nimport Circle from \"ol/style/Circle\";\nimport Fill from \"ol/style/Fill\";\nimport Stroke from \"ol/style/Stroke\";\nimport Style from \"ol/style/Style\";\nimport VectorSource from \"ol/source/Vector\";\nimport { Geometry } from \"ol/geom\";\nimport VectorLayer from \"ol/layer/Vector\";\nimport Projection from \"ol/proj/Projection\";\nimport { fromLonLat, toLonLat, getUserProjection } from \"ol/proj\";\nimport { Coordinate } from \"ol/coordinate\";\nimport { Pixel } from \"ol/pixel\";\nimport { Icon } from \"ol/style\";\n\nexport type InjectableOL = {\n\tIcon: typeof Icon;\n\tFill: typeof Fill;\n\tFeature: typeof Feature;\n\tGeoJSON: typeof GeoJSON;\n\tStyle: typeof Style;\n\tCircle: typeof Circle;\n\tVectorLayer: typeof VectorLayer;\n\tVectorSource: typeof VectorSource;\n\tStroke: typeof Stroke;\n\tProjection: typeof Projection;\n\tgetUserProjection: typeof getUserProjection;\n\tfromLonLat: typeof fromLonLat;\n\ttoLonLat: typeof toLonLat;\n};\n\nexport class TerraDrawOpenLayersAdapter extends TerraDrawExtend.TerraDrawBaseAdapter {\n\tconstructor(\n\t\tconfig: {\n\t\t\tmap: Map;\n\t\t\tlib: InjectableOL;\n\t\t\tzIndex?: number;\n\t\t} & TerraDrawExtend.BaseAdapterConfig,\n\t) {\n\t\tsuper(config);\n\n\t\tthis._map = config.map;\n\t\tthis._lib = config.lib;\n\n\t\tthis._geoJSONReader = new this._lib.GeoJSON();\n\t\tthis._projection = () =>\n\t\t\tthis._lib.getUserProjection() ??\n\t\t\tnew this._lib.Projection({ code: \"EPSG:3857\" });\n\n\t\tthis._container = this._map.getViewport();\n\n\t\t// TODO: Is this the best way to receive keyboard events\n\t\tthis._container.setAttribute(\"tabindex\", \"0\");\n\n\t\tconst vectorSource = new this._lib.VectorSource({\n\t\t\tfeatures: [],\n\t\t}) as unknown as VectorSource<Feature<Geometry>>;\n\n\t\tthis._vectorSource = vectorSource as unknown as VectorSource<\n\t\t\tFeature<Geometry>\n\t\t>;\n\n\t\tthis.baseZIndex = config.zIndex ?? 100000;\n\n\t\tconst vectorLayer = new this._lib.VectorLayer({\n\t\t\tsource: vectorSource as unknown as VectorSource<never>,\n\t\t\tstyle: (feature) => this.getStyles(feature, this.stylingFunction()),\n\t\t\tzIndex: this.baseZIndex,\n\t\t});\n\n\t\tthis._map.addLayer(vectorLayer);\n\t}\n\n\tprivate baseZIndex = 100000;\n\tprivate stylingFunction = () => ({});\n\n\tprivate _lib: InjectableOL;\n\tprivate _map: Map;\n\tprivate _container: HTMLElement;\n\tprivate _projection: () => Projection;\n\tprivate _vectorSource: VectorSource<Feature<Geometry>>;\n\tprivate _geoJSONReader: GeoJSON;\n\n\t/**\n\t * Converts a hexadecimal color to RGB\n\t * @param hex a string of the hexadecimal string\n\t * @returns an object to red green and blue (RGB) color\n\t */\n\tprivate hexToRGB(hex: string): { r: number; g: number; b: number } {\n\t\treturn {\n\t\t\tr: parseInt(hex.slice(1, 3), 16),\n\t\t\tg: parseInt(hex.slice(3, 5), 16),\n\t\t\tb: parseInt(hex.slice(5, 7), 16),\n\t\t};\n\t}\n\n\tprivate getStyles(feature: FeatureLike, styling: TerraDrawStylingFunction) {\n\t\tconst geometry = feature.getGeometry();\n\t\tif (!geometry) {\n\t\t\treturn;\n\t\t}\n\t\tconst key = geometry.getType() as \"Point\" | \"LineString\" | \"Polygon\";\n\n\t\treturn {\n\t\t\tPoint: (feature: FeatureLike) => {\n\t\t\t\tconst properties = feature.getProperties();\n\t\t\t\tconst style = styling[properties.mode]({\n\t\t\t\t\ttype: \"Feature\",\n\t\t\t\t\tgeometry: { type: \"Point\", coordinates: [] },\n\t\t\t\t\tproperties,\n\t\t\t\t});\n\n\t\t\t\tif (style.markerUrl && style.markerWidth && style.markerHeight) {\n\t\t\t\t\treturn new this._lib.Style({\n\t\t\t\t\t\tzIndex: this.baseZIndex + style.zIndex,\n\t\t\t\t\t\timage: new this._lib.Icon({\n\t\t\t\t\t\t\tsrc: style.markerUrl as string,\n\t\t\t\t\t\t\twidth: style.markerWidth,\n\t\t\t\t\t\t\theight: style.markerHeight,\n\t\t\t\t\t\t\tanchor: [0.5, 1], // Anchor the icon at the bottom center\n\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn new this._lib.Style({\n\t\t\t\t\tzIndex: this.baseZIndex + style.zIndex,\n\t\t\t\t\timage: new this._lib.Circle({\n\t\t\t\t\t\tradius: style.pointWidth,\n\t\t\t\t\t\tfill: new this._lib.Fill({\n\t\t\t\t\t\t\tcolor: style.pointColor,\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tstroke: new this._lib.Stroke({\n\t\t\t\t\t\t\tcolor: style.pointOutlineColor,\n\t\t\t\t\t\t\twidth: style.pointOutlineWidth,\n\t\t\t\t\t\t}),\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t},\n\t\t\tLineString: (feature: FeatureLike) => {\n\t\t\t\tconst properties = feature.getProperties();\n\t\t\t\tconst style = styling[properties.mode]({\n\t\t\t\t\ttype: \"Feature\",\n\t\t\t\t\tgeometry: { type: \"LineString\", coordinates: [] },\n\t\t\t\t\tproperties,\n\t\t\t\t});\n\t\t\t\treturn new this._lib.Style({\n\t\t\t\t\tzIndex: style.zIndex,\n\t\t\t\t\tstroke: new this._lib.Stroke({\n\t\t\t\t\t\tcolor: style.lineStringColor,\n\t\t\t\t\t\twidth: style.lineStringWidth,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t},\n\t\t\tPolygon: (feature: FeatureLike) => {\n\t\t\t\tconst properties = feature.getProperties();\n\t\t\t\tconst style = styling[properties.mode]({\n\t\t\t\t\ttype: \"Feature\",\n\t\t\t\t\tgeometry: { type: \"Polygon\", coordinates: [] },\n\n\t\t\t\t\tproperties,\n\t\t\t\t});\n\t\t\t\tconst { r, g, b } = this.hexToRGB(style.polygonFillColor);\n\n\t\t\t\treturn new this._lib.Style({\n\t\t\t\t\tzIndex: style.zIndex,\n\t\t\t\t\tstroke: new this._lib.Stroke({\n\t\t\t\t\t\tcolor: style.polygonOutlineColor,\n\t\t\t\t\t\twidth: style.polygonOutlineWidth,\n\t\t\t\t\t}),\n\t\t\t\t\tfill: new this._lib.Fill({\n\t\t\t\t\t\tcolor: `rgba(${r},${g},${b},${style.polygonFillOpacity})`,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t},\n\t\t}[key](feature);\n\t}\n\n\t/**\n\t * Clears the layers created by the adapter\n\t * @returns void\n\t * */\n\tprivate clearLayers() {\n\t\tif (this._vectorSource) {\n\t\t\tthis._vectorSource.clear();\n\t\t}\n\t}\n\n\tprivate addFeature(feature: GeoJSONStoreFeatures) {\n\t\tconst olFeature = this._geoJSONReader.readFeature(feature, {\n\t\t\tdataProjection: \"EPSG:4326\",\n\t\t\tfeatureProjection: this._projection(),\n\t\t}) as Feature<Geometry>;\n\t\tthis._vectorSource.addFeature(olFeature);\n\t}\n\n\tprivate removeFeature(id: TerraDrawExtend.FeatureId) {\n\t\tconst deleted = this._vectorSource.getFeatureById(id);\n\t\tif (!deleted) {\n\t\t\treturn;\n\t\t}\n\t\tthis._vectorSource.removeFeature(deleted);\n\t}\n\n\t/**\n\t * Sorts an array of DOM elements based on their order in the document, from earliest to latest.\n\t * @param elements - An array of `HTMLElement` objects to be sorted.\n\t * @returns A new array of `HTMLElement` objects sorted by their document order.\n\t */\n\tprivate sortElementsByDOMOrder(elements: HTMLElement[]) {\n\t\t// Sort the elements based on their DOM position\n\t\treturn elements.sort((a, b) => {\n\t\t\tconst position = a.compareDocumentPosition(b);\n\n\t\t\t// If a comes before b in the DOM\n\t\t\tif (position & Node.DOCUMENT_POSITION_FOLLOWING) {\n\t\t\t\treturn -1;\n\t\t\t}\n\n\t\t\t// If a comes after b in the DOM\n\t\t\tif (position & Node.DOCUMENT_POSITION_PRECEDING) {\n\t\t\t\treturn 1;\n\t\t\t}\n\n\t\t\t// If they are the same element\n\t\t\treturn 0;\n\t\t});\n\t}\n\n\t/**\n\t * Returns the longitude and latitude coordinates from a given PointerEvent on the map.\n\t * @param event The PointerEvent or MouseEvent containing the screen coordinates of the pointer.\n\t * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude, or null if the conversion is not possible.\n\t */\n\tpublic getLngLatFromEvent(event: PointerEvent | MouseEvent) {\n\t\tconst { containerX: x, containerY: y } =\n\t\t\tthis.getMapElementXYPosition(event);\n\t\ttry {\n\t\t\treturn this.unproject(x, y);\n\t\t} catch (_) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * Retrieves the HTML element of the OpenLayers element that handles interaction events\n\t * @returns The HTMLElement representing the map container.\n\t */\n\tpublic getMapEventElement() {\n\t\t// Each VectorLayer has a canvas element that is used to render the features, it orders\n\t\t// these in the order they are added to the map. The last canvas is the one that is on top\n\t\t// so we need to add the event listeners to this canvas so that the events are captured.\n\t\tconst canvases = Array.from(this._container.querySelectorAll(\"canvas\"));\n\t\tconst sortedCanvases = this.sortElementsByDOMOrder(\n\t\t\tcanvases,\n\t\t) as HTMLCanvasElement[];\n\t\tconst topCanvas = sortedCanvases[sortedCanvases.length - 1];\n\n\t\treturn topCanvas;\n\t}\n\n\t/**\n\t * Enables or disables the draggable functionality of the map.\n\t * @param enabled Set to true to enable map dragging, or false to disable it.\n\t */\n\tpublic setDraggability(enabled: boolean) {\n\t\tthis._map.getInteractions().forEach((interaction) => {\n\t\t\tif (interaction.constructor.name === \"DragPan\") {\n\t\t\t\tinteraction.setActive(enabled);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Converts longitude and latitude coordinates to pixel coordinates in the map container.\n\t * @param lng The longitude coordinate to project.\n\t * @param lat The latitude coordinate to project.\n\t * @returns An object with 'x' and 'y' properties representing the pixel coordinates within the map container.\n\t */\n\tpublic project(lng: number, lat: number) {\n\t\tconst [x, y] = this._map.getPixelFromCoordinate(\n\t\t\tthis._lib.fromLonLat([lng, lat], this._projection()) as Coordinate,\n\t\t);\n\t\treturn { x, y };\n\t}\n\n\t/**\n\t * Converts pixel coordinates in the map container to longitude and latitude coordinates.\n\t * @param x The x-coordinate in the map container to unproject.\n\t * @param y The y-coordinate in the map container to unproject.\n\t * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude coordinates.\n\t */\n\tpublic unproject(x: number, y: number) {\n\t\tconst [lng, lat] = this._lib.toLonLat(\n\t\t\tthis._map.getCoordinateFromPixel([x, y]) as Pixel,\n\t\t\tthis._projection(),\n\t\t);\n\t\treturn { lng, lat };\n\t}\n\n\t/**\n\t * Sets the cursor style for the map container.\n\t * @param cursor The CSS cursor style to apply, or 'unset' to remove any previously applied cursor style.\n\t */\n\tpublic setCursor(cursor: Parameters<SetCursor>[0]) {\n\t\tif (cursor === \"unset\") {\n\t\t\tthis.getMapEventElement().style.removeProperty(\"cursor\");\n\t\t} else {\n\t\t\tthis.getMapEventElement().style.cursor = cursor;\n\t\t}\n\t}\n\n\t/**\n\t * Enables or disables the double-click to zoom functionality on the map.\n\t * @param enabled Set to true to enable double-click to zoom, or false to disable it.\n\t */\n\tpublic setDoubleClickToZoom(enabled: boolean) {\n\t\tthis._map.getInteractions().forEach(function (interaction) {\n\t\t\tif (interaction.constructor.name === \"DoubleClickZoom\") {\n\t\t\t\tinteraction.setActive(enabled);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Renders GeoJSON features on the map using the provided styling configuration.\n\t * @param changes An object containing arrays of created, updated, and unchanged features to render.\n\t * @param styling An object mapping draw modes to feature styling functions\n\t */\n\tpublic render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction) {\n\t\tthis.stylingFunction = () => styling;\n\n\t\tchanges.deletedIds.forEach((id) => {\n\t\t\tthis.removeFeature(id);\n\t\t});\n\n\t\tchanges.updated.forEach((feature) => {\n\t\t\tthis.removeFeature(feature.id as TerraDrawExtend.FeatureId);\n\t\t\tthis.addFeature(feature);\n\t\t});\n\n\t\tchanges.created.forEach((feature) => {\n\t\t\tthis.addFeature(feature);\n\t\t});\n\t}\n\n\t/**\n\t * Clears the map and store of all rendered data layers\n\t * @returns void\n\t * */\n\tpublic clear() {\n\t\tif (this._currentModeCallbacks) {\n\t\t\t// Clean up state first\n\t\t\tthis._currentModeCallbacks.onClear();\n\n\t\t\t// Then clean up rendering\n\t\t\tthis.clearLayers();\n\t\t}\n\t}\n\n\tprivate registeredLayerHandlers:\n\t\t| undefined\n\t\t| { addLayers: () => void; removeLayers: () => void };\n\n\tpublic register(callbacks: TerraDrawExtend.TerraDrawCallbacks) {\n\t\tsuper.register(callbacks);\n\n\t\t// We need to handle the complex case in OpenLayers where adding and removing layers\n\t\t// can change the canvas ordering preventing the event listeners from working correctly\n\t\tif (!this.registeredLayerHandlers) {\n\t\t\tconst layerGroup = this._map.getLayerGroup();\n\t\t\tconst layers = layerGroup.getLayers();\n\n\t\t\tconst removeListeners = () => {\n\t\t\t\tthis._listeners.forEach((listener) => {\n\t\t\t\t\tlistener.unregister();\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tconst addListeners = () => {\n\t\t\t\tthis._listeners = this.getAdapterListeners();\n\n\t\t\t\tthis._listeners.forEach((listener) => {\n\t\t\t\t\tlistener.register();\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tthis.registeredLayerHandlers = {\n\t\t\t\taddLayers: () => {\n\t\t\t\t\tremoveListeners();\n\t\t\t\t\tthis._map.once(\"rendercomplete\", () => {\n\t\t\t\t\t\tif (this._currentModeCallbacks) {\n\t\t\t\t\t\t\taddListeners();\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tremoveLayers: () => {\n\t\t\t\t\tremoveListeners();\n\t\t\t\t\tthis._map.once(\"rendercomplete\", () => {\n\t\t\t\t\t\tif (this._currentModeCallbacks) {\n\t\t\t\t\t\t\taddListeners();\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tlayers.on(\"add\", () => {\n\t\t\t\tremoveListeners();\n\t\t\t\tthis._map.once(\"rendercomplete\", () => {\n\t\t\t\t\tif (this._currentModeCallbacks) {\n\t\t\t\t\t\taddListeners();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tlayers.on(\"remove\", () => {\n\t\t\t\tremoveListeners();\n\t\t\t\tthis._map.once(\"rendercomplete\", () => {\n\t\t\t\t\tif (this._currentModeCallbacks) {\n\t\t\t\t\t\taddListeners();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\tif (this._currentModeCallbacks?.onReady) {\n\t\t\tthis._currentModeCallbacks.onReady();\n\t\t}\n\t}\n\n\tpublic getCoordinatePrecision(): number {\n\t\treturn super.getCoordinatePrecision();\n\t}\n\n\tpublic unregister(): void {\n\t\tif (this.registeredLayerHandlers) {\n\t\t\tconst layerGroup = this._map.getLayerGroup();\n\t\t\tif (layerGroup) {\n\t\t\t\tconst layers = layerGroup.getLayers();\n\n\t\t\t\tif (layers) {\n\t\t\t\t\tlayers.un(\"add\", this.registeredLayerHandlers.addLayers);\n\t\t\t\t\tlayers.un(\"remove\", this.registeredLayerHandlers.removeLayers);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn super.unregister();\n\t}\n}\n"],"names":["_TerraDrawExtend$Terr","TerraDrawOpenLayersAdapter","config","_config$zIndex","_this","call","this","baseZIndex","stylingFunction","_lib","_map","_container","_projection","_vectorSource","_geoJSONReader","registeredLayerHandlers","map","lib","GeoJSON","_this$_lib$getUserPro","getUserProjection","Projection","code","getViewport","setAttribute","vectorSource","VectorSource","features","zIndex","vectorLayer","VectorLayer","source","style","feature","getStyles","addLayer","_proto","prototype","hexToRGB","hex","r","parseInt","slice","g","b","styling","_this2","geometry","getGeometry","Point","properties","getProperties","mode","type","coordinates","Style","markerUrl","markerWidth","markerHeight","image","Icon","src","width","height","anchor","Circle","radius","pointWidth","fill","Fill","color","pointColor","stroke","Stroke","pointOutlineColor","pointOutlineWidth","LineString","lineStringColor","lineStringWidth","Polygon","_this2$hexToRGB","polygonFillColor","polygonOutlineColor","polygonOutlineWidth","polygonFillOpacity","getType","clearLayers","clear","addFeature","olFeature","readFeature","dataProjection","featureProjection","removeFeature","id","deleted","getFeatureById","sortElementsByDOMOrder","elements","sort","a","position","compareDocumentPosition","Node","DOCUMENT_POSITION_FOLLOWING","DOCUMENT_POSITION_PRECEDING","getLngLatFromEvent","event","_this$getMapElementXY","getMapElementXYPosition","x","containerX","y","containerY","unproject","_","getMapEventElement","canvases","Array","from","querySelectorAll","sortedCanvases","length","setDraggability","enabled","getInteractions","forEach","interaction","constructor","name","setActive","project","lng","lat","_this$_map$getPixelFr","getPixelFromCoordinate","fromLonLat","_this$_lib$toLonLat","toLonLat","getCoordinateFromPixel","setCursor","cursor","removeProperty","setDoubleClickToZoom","render","changes","_this3","deletedIds","updated","created","_currentModeCallbacks","onClear","register","callbacks","_this$_currentModeCal","_this4","layers","getLayerGroup","getLayers","removeListeners","_listeners","listener","unregister","addListeners","getAdapterListeners","addLayers","once","removeLayers","on","onReady","getCoordinatePrecision","layerGroup","un","TerraDrawExtend","TerraDrawBaseAdapter"],"mappings":"wcA2CwC,SAAAA,GACvC,SAAAC,EACCC,GAIqC,IAAAC,EAAAC,G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AWb,YAEtBF,IACHA,EAAOgB,GAAG,MAAOtK,KAAKS,wBAAwBsJ,WAC9CT,EAAOgB,GAAG,SAAUtK,KAAKS,wBAAwBwJ,cAEnD,CACD,CAEA,OAAAvK,EAAAqC,UAAa6H,WAAU7J,KAAAC,KACxB,EAACL,CAAA,CAhasC,CAAQ4K,EAAeA,gBAACC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "terra-draw-openlayers-adapter",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "Terra Draw Adapter to OpenLayers",
5
5
  "peerDependencies": {
6
6
  "terra-draw": "^1.0.0",