terra-draw-google-maps-adapter 1.0.2 → 1.0.3

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)}function r(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}exports.TerraDrawGoogleMapsAdapter=/*#__PURE__*/function(e){function o(t){var r;if((r=e.call(this,t)||this)._cursor=void 0,r._cursorStyleSheet=void 0,r._lib=void 0,r._map=void 0,r._overlay=void 0,r._clickEventListener=void 0,r._mouseMoveEventListener=void 0,r._readyCalled=!1,r.renderedFeatureIds=new Set,r._lib=t.lib,r._map=t.map,!r._map.getDiv().id)throw new Error("Google Map container div requires and id to be set");return r._coordinatePrecision="number"==typeof t.coordinatePrecision?t.coordinatePrecision:9,r}var n,i;i=e,(n=o).prototype=Object.create(i.prototype),n.prototype.constructor=n,t(n,i);var a,l,s=o.prototype;return s.circlePath=function(e,t,r){var o=2*r;return"M "+e+" "+t+" m -"+r+", 0 a "+r+","+r+" 0 1,0 "+o+",0 a "+r+","+r+" 0 1,0 -"+o+",0"},s.register=function(t){var r=this;e.prototype.register.call(this,t),this._overlay=new this._lib.OverlayView,this._overlay.draw=function(){},this._overlay.onAdd=function(){var e;null!=(e=r._currentModeCallbacks)&&e.onReady&&!r._readyCalled&&(r._currentModeCallbacks.onReady(),r._readyCalled=!0)},this._overlay.setMap(this._map),this._overlay.onRemove=function(){},this._clickEventListener=this._map.data.addListener("click",function(e){var t=r._listeners.find(function(e){return"click"===e.name});t&&t.callback(e)}),this._mouseMoveEventListener=this._map.data.addListener("mousemove",function(e){var t=r._listeners.find(function(e){return"mousemove"===e.name});t&&t.callback(e)})},s.unregister=function(){var t,r;e.prototype.unregister.call(this),null==(t=this._clickEventListener)||t.remove(),null==(r=this._mouseMoveEventListener)||r.remove(),this._overlay&&this._overlay.getMap()&&this._overlay.setMap(null),this._overlay=void 0,this._readyCalled=!1},s.getLngLatFromEvent=function(e){if(!this._overlay)throw new Error("cannot get overlay");var t=this._map.getBounds();if(!t)return null;var r=t.getNorthEast(),o=t.getSouthWest(),n=new this._lib.LatLngBounds(o,r),i=this._map.getDiv(),a=e.clientX-i.getBoundingClientRect().left,l=e.clientY-i.getBoundingClientRect().top,s=new this._lib.Point(a,l),c=this._overlay.getProjection();if(!c)return null;var d=c.fromContainerPixelToLatLng(s);return d&&n.contains(d)?{lng:d.lng(),lat:d.lat()}:null},s.getMapEventElement=function(){return this._map.getDiv().querySelector('div[style*="z-index: 3;"]')},s.project=function(e,t){if(!this._overlay)throw new Error("cannot get overlay");if(void 0===this._map.getBounds())throw new Error("cannot get bounds");var r=this._overlay.getProjection();if(void 0===r)throw new Error("cannot get projection");var o=r.fromLatLngToContainerPixel(new this._lib.LatLng(t,e));if(null===o)throw new Error("cannot project coordinates");return{x:o.x,y:o.y}},s.unproject=function(e,t){if(!this._overlay)throw new Error("cannot get overlay");var r=this._overlay.getProjection();if(void 0===r)throw new Error("cannot get projection");var o=r.fromContainerPixelToLatLng(new this._lib.Point(e,t));if(null===o)throw new Error("cannot unproject coordinates");return{lng:o.lng(),lat:o.lat()}},s.setCursor=function(e){if(e!==this._cursor){if(this._cursorStyleSheet&&(this._cursorStyleSheet.remove(),this._cursorStyleSheet=void 0),"unset"!==e){var t=this._map.getDiv(),r=document.querySelector("#"+t.id+" .gm-style > div");if(r){r.classList.add("terra-draw-google-maps");var o=document.createElement("style");o.innerHTML=".terra-draw-google-maps { cursor: "+e+" !important; }",document.getElementsByTagName("head")[0].appendChild(o),this._cursorStyleSheet=o}}this._cursor=e}},s.setDoubleClickToZoom=function(e){this._map.setOptions(e?{disableDoubleClickZoom:!1}:{disableDoubleClickZoom:!0})},s.setDraggability=function(e){this._map.setOptions({draggable:e})},s.render=function(e,t){var r=this;this._layers&&(e.deletedIds.forEach(function(e){var t=r._map.data.getFeatureById(e);t&&(r._map.data.remove(t),r.renderedFeatureIds.delete(e))}),e.updated.forEach(function(e){if(!e||!e.id)throw new Error("Feature is not valid");var t=r._map.data.getFeatureById(e.id);if(!t)throw new Error("Feature could not be found by Google Maps API");switch(t.forEachProperty(function(e,r){t.setProperty(r,void 0)}),Object.keys(e.properties).forEach(function(r){t.setProperty(r,e.properties[r])}),e.geometry.type){case"Point":var o=e.geometry.coordinates;t.setGeometry(new r._lib.Data.Point(new r._lib.LatLng(o[1],o[0])));break;case"LineString":for(var n=e.geometry.coordinates,i=[],a=0;a<n.length;a++){var l=n[a],s=new r._lib.LatLng(l[1],l[0]);i.push(s)}t.setGeometry(new r._lib.Data.LineString(i));break;case"Polygon":for(var c=e.geometry.coordinates,d=[],u=0;u<c.length;u++){for(var h=[],p=0;p<c[u].length;p++){var v=new r._lib.LatLng(c[u][p][1],c[u][p][0]);h.push(v)}d.push(h)}t.setGeometry(new r._lib.Data.Polygon(d))}}),e.created.forEach(function(e){r.renderedFeatureIds.add(e.id),r._map.data.addGeoJson(e)})),e.created.forEach(function(e){r.renderedFeatureIds.add(e.id)});var o={type:"FeatureCollection",features:[].concat(e.created)};this._map.data.addGeoJson(o),this._map.data.setStyle(function(e){var o=e.getProperty("mode"),n=e.getGeometry();if(!n)throw new Error("Google Maps geometry not found");var i=n.getType(),a={};e.forEachProperty(function(e,t){a[t]=e});var l=t[o]({type:"Feature",geometry:{type:i,coordinates:[]},properties:a});switch(i){case"Point":return{clickable:!1,icon:{path:r.circlePath(0,0,l.pointWidth),fillColor:l.pointColor,fillOpacity:1,strokeColor:l.pointOutlineColor,strokeWeight:l.pointOutlineWidth,rotation:0,scale:1},zIndex:l.zIndex};case"LineString":return{strokeColor:l.lineStringColor,strokeWeight:l.lineStringWidth,zIndex:l.zIndex};case"Polygon":return{strokeColor:l.polygonOutlineColor,strokeWeight:l.polygonOutlineWidth,fillOpacity:l.polygonFillOpacity,fillColor:l.polygonFillColor,zIndex:l.zIndex}}throw Error("Unknown feature type")})},s.clearLayers=function(){var e=this;this._layers&&(this._map.data.forEach(function(t){var r=t.getId();e.renderedFeatureIds.has(r)&&e._map.data.remove(t)}),this.renderedFeatureIds=new Set)},s.clear=function(){this._currentModeCallbacks&&(this._currentModeCallbacks.onClear(),this.clearLayers())},s.getCoordinatePrecision=function(){return e.prototype.getCoordinatePrecision.call(this)},a=o,(l=[{key:"_layers",get:function(){var e;return Boolean((null==(e=this.renderedFeatureIds)?void 0:e.size)>0)}}])&&function(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,r(n.key),n)}}(a.prototype,l),Object.defineProperty(a,"prototype",{writable:!1}),a}(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)}function r(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}exports.TerraDrawGoogleMapsAdapter=/*#__PURE__*/function(e){function o(t){var r;if((r=e.call(this,t)||this)._cursor=void 0,r._cursorStyleSheet=void 0,r._lib=void 0,r._map=void 0,r._overlay=void 0,r._clickEventListener=void 0,r._mouseMoveEventListener=void 0,r._readyCalled=!1,r.renderedFeatureIds=new Set,r._lib=t.lib,r._map=t.map,!r._map.getDiv().id)throw new Error("Google Map container div requires and id to be set");return r._coordinatePrecision="number"==typeof t.coordinatePrecision?t.coordinatePrecision:9,r}var n,i;i=e,(n=o).prototype=Object.create(i.prototype),n.prototype.constructor=n,t(n,i);var a,l,s=o.prototype;return s.circlePath=function(e,t,r){var o=2*r;return"M "+e+" "+t+" m -"+r+", 0 a "+r+","+r+" 0 1,0 "+o+",0 a "+r+","+r+" 0 1,0 -"+o+",0"},s.register=function(t){var r=this;e.prototype.register.call(this,t),this._overlay=new this._lib.OverlayView,this._overlay.draw=function(){},this._overlay.onAdd=function(){var e;null!=(e=r._currentModeCallbacks)&&e.onReady&&!r._readyCalled&&(r._currentModeCallbacks.onReady(),r._readyCalled=!0)},this._overlay.setMap(this._map),this._overlay.onRemove=function(){},this._clickEventListener=this._map.data.addListener("click",function(e){var t=r._listeners.find(function(e){return"click"===e.name});t&&t.callback(e)}),this._mouseMoveEventListener=this._map.data.addListener("mousemove",function(e){var t=r._listeners.find(function(e){return"mousemove"===e.name});t&&t.callback(e)})},s.unregister=function(){var t,r;e.prototype.unregister.call(this),null==(t=this._clickEventListener)||t.remove(),null==(r=this._mouseMoveEventListener)||r.remove(),this._overlay&&this._overlay.getMap()&&this._overlay.setMap(null),this._overlay=void 0,this._readyCalled=!1},s.getLngLatFromEvent=function(e){if(!this._overlay)throw new Error("cannot get overlay");var t=this._map.getBounds();if(!t)return null;var r=t.getNorthEast(),o=t.getSouthWest(),n=new this._lib.LatLngBounds(o,r),i=this._map.getDiv(),a=e.clientX-i.getBoundingClientRect().left,l=e.clientY-i.getBoundingClientRect().top,s=new this._lib.Point(a,l),c=this._overlay.getProjection();if(!c)return null;var d=c.fromContainerPixelToLatLng(s);return d&&n.contains(d)?{lng:d.lng(),lat:d.lat()}:null},s.getMapEventElement=function(){return this._map.getDiv().querySelector('div[style*="z-index: 3;"]')},s.project=function(e,t){if(!this._overlay)throw new Error("cannot get overlay");if(void 0===this._map.getBounds())throw new Error("cannot get bounds");var r=this._overlay.getProjection();if(void 0===r)throw new Error("cannot get projection");var o=r.fromLatLngToContainerPixel(new this._lib.LatLng(t,e));if(null===o)throw new Error("cannot project coordinates");return{x:o.x,y:o.y}},s.unproject=function(e,t){if(!this._overlay)throw new Error("cannot get overlay");var r=this._overlay.getProjection();if(void 0===r)throw new Error("cannot get projection");var o=r.fromContainerPixelToLatLng(new this._lib.Point(e,t));if(null===o)throw new Error("cannot unproject coordinates");return{lng:o.lng(),lat:o.lat()}},s.setCursor=function(e){if(e!==this._cursor){if(this._cursorStyleSheet&&(this._cursorStyleSheet.remove(),this._cursorStyleSheet=void 0),"unset"!==e){var t=this._map.getDiv(),r=document.querySelector("#"+t.id+" .gm-style > div");if(r){r.classList.add("terra-draw-google-maps");var o=document.createElement("style");o.innerHTML=".terra-draw-google-maps { cursor: "+e+" !important; }",document.getElementsByTagName("head")[0].appendChild(o),this._cursorStyleSheet=o}}this._cursor=e}},s.setDoubleClickToZoom=function(e){this._map.setOptions(e?{disableDoubleClickZoom:!1}:{disableDoubleClickZoom:!0})},s.setDraggability=function(e){this._map.setOptions({draggable:e})},s.render=function(e,t){var r=this;this._layers&&(e.deletedIds.forEach(function(e){var t=r._map.data.getFeatureById(e);t&&(r._map.data.remove(t),r.renderedFeatureIds.delete(e))}),e.updated.forEach(function(e){if(!e||!e.id)throw new Error("Feature is not valid");var t=r._map.data.getFeatureById(e.id);if(!t)throw new Error("Feature could not be found by Google Maps API");switch(t.forEachProperty(function(e,r){t.setProperty(r,void 0)}),Object.keys(e.properties).forEach(function(r){t.setProperty(r,e.properties[r])}),e.geometry.type){case"Point":var o=e.geometry.coordinates;t.setGeometry(new r._lib.Data.Point(new r._lib.LatLng(o[1],o[0])));break;case"LineString":for(var n=e.geometry.coordinates,i=[],a=0;a<n.length;a++){var l=n[a],s=new r._lib.LatLng(l[1],l[0]);i.push(s)}t.setGeometry(new r._lib.Data.LineString(i));break;case"Polygon":for(var c=e.geometry.coordinates,d=[],u=0;u<c.length;u++){for(var h=[],p=0;p<c[u].length;p++){var v=new r._lib.LatLng(c[u][p][1],c[u][p][0]);h.push(v)}d.push(h)}t.setGeometry(new r._lib.Data.Polygon(d))}}),e.created.forEach(function(e){r.renderedFeatureIds.add(e.id),r._map.data.addGeoJson(e)})),e.created.forEach(function(e){r.renderedFeatureIds.add(e.id)});var o={type:"FeatureCollection",features:[].concat(e.created)};this._map.data.addGeoJson(o),this._map.data.setStyle(function(e){var o=e.getProperty("mode"),n=e.getGeometry();if(!n)throw new Error("Google Maps geometry not found");var i=n.getType(),a={},l=e.getId();e.forEachProperty(function(e,t){a[t]=e});var s=t[o]({type:"Feature",id:l,geometry:{type:i,coordinates:[]},properties:a});switch(i){case"Point":return{clickable:!1,icon:{path:r.circlePath(0,0,s.pointWidth),fillColor:s.pointColor,fillOpacity:1,strokeColor:s.pointOutlineColor,strokeWeight:s.pointOutlineWidth,rotation:0,scale:1},zIndex:s.zIndex};case"LineString":return{strokeColor:s.lineStringColor,strokeWeight:s.lineStringWidth,zIndex:s.zIndex};case"Polygon":return{strokeColor:s.polygonOutlineColor,strokeWeight:s.polygonOutlineWidth,fillOpacity:s.polygonFillOpacity,fillColor:s.polygonFillColor,zIndex:s.zIndex}}throw Error("Unknown feature type")})},s.clearLayers=function(){var e=this;this._layers&&(this._map.data.forEach(function(t){var r=t.getId();e.renderedFeatureIds.has(r)&&e._map.data.remove(t)}),this.renderedFeatureIds=new Set)},s.clear=function(){this._currentModeCallbacks&&(this._currentModeCallbacks.onClear(),this.clearLayers())},s.getCoordinatePrecision=function(){return e.prototype.getCoordinatePrecision.call(this)},a=o,(l=[{key:"_layers",get:function(){var e;return Boolean((null==(e=this.renderedFeatureIds)?void 0:e.size)>0)}}])&&function(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,r(n.key),n)}}(a.prototype,l),Object.defineProperty(a,"prototype",{writable:!1}),a}(e.TerraDrawExtend.TerraDrawBaseAdapter);
2
2
  //# sourceMappingURL=terra-draw-google-maps-adapter.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"terra-draw-google-maps-adapter.cjs","sources":["../src/terra-draw-google-maps-adapter.ts"],"sourcesContent":["/**\n * @module terra-draw-google-maps-adapter\n */\nimport {\n\tTerraDrawChanges,\n\tSetCursor,\n\tTerraDrawStylingFunction,\n\tTerraDrawExtend,\n} from \"terra-draw\";\nimport { GeoJsonObject } from \"geojson\";\n\nexport class TerraDrawGoogleMapsAdapter extends TerraDrawExtend.TerraDrawBaseAdapter {\n\tconstructor(\n\t\tconfig: {\n\t\t\tlib: typeof google.maps;\n\t\t\tmap: google.maps.Map;\n\t\t} & TerraDrawExtend.BaseAdapterConfig,\n\t) {\n\t\tsuper(config);\n\t\tthis._lib = config.lib;\n\t\tthis._map = config.map;\n\n\t\t// In order for the internals of the adapter to work we require an ID to\n\t\t// allow query selectors to work\n\t\tif (!this._map.getDiv().id) {\n\t\t\tthrow new Error(\"Google Map container div requires and id to be set\");\n\t\t}\n\n\t\tthis._coordinatePrecision =\n\t\t\ttypeof config.coordinatePrecision === \"number\"\n\t\t\t\t? config.coordinatePrecision\n\t\t\t\t: 9;\n\t}\n\n\tprivate _cursor: string | undefined;\n\tprivate _cursorStyleSheet: HTMLStyleElement | undefined;\n\tprivate _lib: typeof google.maps;\n\tprivate _map: google.maps.Map;\n\tprivate _overlay: google.maps.OverlayView | undefined;\n\tprivate _clickEventListener: google.maps.MapsEventListener | undefined;\n\tprivate _mouseMoveEventListener: google.maps.MapsEventListener | undefined;\n\tprivate _readyCalled = false;\n\n\tprivate get _layers(): boolean {\n\t\treturn Boolean(this.renderedFeatureIds?.size > 0);\n\t}\n\n\t/**\n\t * Generates an SVG path string for a circle with the given center coordinates and radius.\n\t * Based off this StackOverflow answer: https://stackoverflow.com/a/27905268/1363484\n\t * @param cx The x-coordinate of the circle's center.\n\t * @param cy The y-coordinate of the circle's center.\n\t * @param r The radius of the circle.\n\t * @returns The SVG path string representing the circle.\n\t */\n\tprivate circlePath(cx: number, cy: number, r: number) {\n\t\tconst d = r * 2;\n\t\treturn `M ${cx} ${cy} m -${r}, 0 a ${r},${r} 0 1,0 ${d},0 a ${r},${r} 0 1,0 -${d},0`;\n\t}\n\n\tpublic register(callbacks: TerraDrawExtend.TerraDrawCallbacks) {\n\t\tsuper.register(callbacks);\n\n\t\t// The overlay is responsible for allow us to\n\t\t// get the projection, which in turn allows us to\n\t\t// go through lng/lat to pixel space and vice versa\n\t\tthis._overlay = new this._lib.OverlayView();\n\t\tthis._overlay.draw = function () {\n\t\t\t// No-op\n\t\t};\n\n\t\t// Unfortunately it is only ready after the onAdd\n\t\t// method is called, which is why we need to use the 'ready'\n\t\t// listener with the Google Maps adapter\n\t\tthis._overlay.onAdd = () => {\n\t\t\tif (this._currentModeCallbacks?.onReady && !this._readyCalled) {\n\t\t\t\tthis._currentModeCallbacks.onReady();\n\t\t\t\tthis._readyCalled = true;\n\t\t\t}\n\t\t};\n\t\tthis._overlay.setMap(this._map);\n\n\t\t// Required to avoid runtime error in Google Maps API\n\t\tthis._overlay.onRemove = () => {\n\t\t\t// No-op\n\t\t};\n\n\t\t// Clicking on data geometries triggers\n\t\t// swallows the map onclick event,\n\t\t// so we need to forward it to the click callback handler\n\t\tthis._clickEventListener = this._map.data.addListener(\n\t\t\t\"click\",\n\t\t\t(\n\t\t\t\tevent: google.maps.MapMouseEvent & {\n\t\t\t\t\tdomEvent: MouseEvent;\n\t\t\t\t},\n\t\t\t) => {\n\t\t\t\tconst clickListener = this._listeners.find(\n\t\t\t\t\t({ name }) => name === \"click\",\n\t\t\t\t);\n\t\t\t\tif (clickListener) {\n\t\t\t\t\tclickListener.callback(event);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\n\t\tthis._mouseMoveEventListener = this._map.data.addListener(\n\t\t\t\"mousemove\",\n\t\t\t(\n\t\t\t\tevent: google.maps.MapMouseEvent & {\n\t\t\t\t\tdomEvent: MouseEvent;\n\t\t\t\t},\n\t\t\t) => {\n\t\t\t\tconst mouseMoveListener = this._listeners.find(\n\t\t\t\t\t({ name }) => name === \"mousemove\",\n\t\t\t\t);\n\t\t\t\tif (mouseMoveListener) {\n\t\t\t\t\tmouseMoveListener.callback(event);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t}\n\n\tpublic unregister(): void {\n\t\tsuper.unregister();\n\t\tthis._clickEventListener?.remove();\n\t\tthis._mouseMoveEventListener?.remove();\n\n\t\tif (this._overlay && this._overlay.getMap()) {\n\t\t\tthis._overlay.setMap(null);\n\t\t}\n\t\tthis._overlay = undefined;\n\t\tthis._readyCalled = false;\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\tgetLngLatFromEvent(event: PointerEvent | MouseEvent) {\n\t\tif (!this._overlay) {\n\t\t\tthrow new Error(\"cannot get overlay\");\n\t\t}\n\n\t\tconst bounds = this._map.getBounds();\n\n\t\tif (!bounds) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst ne = bounds.getNorthEast();\n\t\tconst sw = bounds.getSouthWest();\n\t\tconst latLngBounds = new this._lib.LatLngBounds(sw, ne);\n\n\t\tconst mapCanvas = this._map.getDiv();\n\t\tconst offsetX = event.clientX - mapCanvas.getBoundingClientRect().left;\n\t\tconst offsetY = event.clientY - mapCanvas.getBoundingClientRect().top;\n\t\tconst screenCoord = new this._lib.Point(offsetX, offsetY);\n\n\t\tconst projection = this._overlay.getProjection();\n\t\tif (!projection) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst latLng = projection.fromContainerPixelToLatLng(screenCoord);\n\n\t\tif (latLng && latLngBounds.contains(latLng)) {\n\t\t\treturn { lng: latLng.lng(), lat: latLng.lat() };\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * Retrieves the HTML element of the Google Map element that handles interaction events\n\t * @returns The HTMLElement representing the map container.\n\t */\n\tpublic getMapEventElement() {\n\t\t// TODO: This is a bit hacky, maybe there is a better solution here\n\t\tconst selector = 'div[style*=\"z-index: 3;\"]';\n\t\treturn this._map.getDiv().querySelector(selector) as HTMLDivElement;\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\tproject(lng: number, lat: number) {\n\t\tif (!this._overlay) {\n\t\t\tthrow new Error(\"cannot get overlay\");\n\t\t}\n\n\t\tconst bounds = this._map.getBounds();\n\n\t\tif (bounds === undefined) {\n\t\t\tthrow new Error(\"cannot get bounds\");\n\t\t}\n\n\t\tconst projection = this._overlay.getProjection();\n\t\tif (projection === undefined) {\n\t\t\tthrow new Error(\"cannot get projection\");\n\t\t}\n\n\t\tconst point = projection.fromLatLngToContainerPixel(\n\t\t\tnew this._lib.LatLng(lat, lng),\n\t\t);\n\n\t\tif (point === null) {\n\t\t\tthrow new Error(\"cannot project coordinates\");\n\t\t}\n\n\t\treturn { x: point.x, y: point.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\tunproject(x: number, y: number) {\n\t\tif (!this._overlay) {\n\t\t\tthrow new Error(\"cannot get overlay\");\n\t\t}\n\n\t\tconst projection = this._overlay.getProjection();\n\t\tif (projection === undefined) {\n\t\t\tthrow new Error(\"cannot get projection\");\n\t\t}\n\n\t\tconst latLng = projection.fromContainerPixelToLatLng(\n\t\t\tnew this._lib.Point(x, y),\n\t\t);\n\n\t\tif (latLng === null) {\n\t\t\tthrow new Error(\"cannot unproject coordinates\");\n\t\t}\n\n\t\treturn { lng: latLng.lng(), lat: latLng.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\tsetCursor(cursor: Parameters<SetCursor>[0]) {\n\t\tif (cursor === this._cursor) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this._cursorStyleSheet) {\n\t\t\tthis._cursorStyleSheet.remove();\n\t\t\tthis._cursorStyleSheet = undefined;\n\t\t}\n\n\t\tif (cursor !== \"unset\") {\n\t\t\t// TODO: We could cache these individually per cursor\n\n\t\t\tconst div = this._map.getDiv();\n\t\t\tconst styleDivSelector = `#${div.id} .gm-style > div`;\n\t\t\tconst styleDiv = document.querySelector(styleDivSelector);\n\n\t\t\tif (styleDiv) {\n\t\t\t\tstyleDiv.classList.add(\"terra-draw-google-maps\");\n\n\t\t\t\tconst style = document.createElement(\"style\");\n\t\t\t\tstyle.innerHTML = `.terra-draw-google-maps { cursor: ${cursor} !important; }`;\n\t\t\t\tdocument.getElementsByTagName(\"head\")[0].appendChild(style);\n\t\t\t\tthis._cursorStyleSheet = style;\n\t\t\t}\n\t\t}\n\n\t\tthis._cursor = cursor;\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\tsetDoubleClickToZoom(enabled: boolean) {\n\t\tif (enabled) {\n\t\t\tthis._map.setOptions({ disableDoubleClickZoom: false });\n\t\t} else {\n\t\t\tthis._map.setOptions({ disableDoubleClickZoom: true });\n\t\t}\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\tsetDraggability(enabled: boolean) {\n\t\tthis._map.setOptions({ draggable: enabled });\n\t}\n\n\tprivate renderedFeatureIds: Set<TerraDrawExtend.FeatureId> = new Set();\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\trender(changes: TerraDrawChanges, styling: TerraDrawStylingFunction) {\n\t\tif (this._layers) {\n\t\t\tchanges.deletedIds.forEach((deletedId) => {\n\t\t\t\tconst featureToDelete = this._map.data.getFeatureById(deletedId);\n\t\t\t\tif (featureToDelete) {\n\t\t\t\t\tthis._map.data.remove(featureToDelete);\n\t\t\t\t\tthis.renderedFeatureIds.delete(deletedId);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tchanges.updated.forEach((updatedFeature) => {\n\t\t\t\tif (!updatedFeature || !updatedFeature.id) {\n\t\t\t\t\tthrow new Error(\"Feature is not valid\");\n\t\t\t\t}\n\n\t\t\t\tconst featureToUpdate = this._map.data.getFeatureById(\n\t\t\t\t\tupdatedFeature.id,\n\t\t\t\t);\n\n\t\t\t\tif (!featureToUpdate) {\n\t\t\t\t\tthrow new Error(\"Feature could not be found by Google Maps API\");\n\t\t\t\t}\n\n\t\t\t\t// Remove all keys\n\t\t\t\tfeatureToUpdate.forEachProperty((property, name) => {\n\t\t\t\t\tfeatureToUpdate.setProperty(name, undefined);\n\t\t\t\t});\n\n\t\t\t\t// Update all keys\n\t\t\t\tObject.keys(updatedFeature.properties).forEach((property) => {\n\t\t\t\t\tfeatureToUpdate.setProperty(\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\tupdatedFeature.properties[property],\n\t\t\t\t\t);\n\t\t\t\t});\n\n\t\t\t\tswitch (updatedFeature.geometry.type) {\n\t\t\t\t\tcase \"Point\":\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconst coordinates = updatedFeature.geometry.coordinates;\n\n\t\t\t\t\t\t\tfeatureToUpdate.setGeometry(\n\t\t\t\t\t\t\t\tnew this._lib.Data.Point(\n\t\t\t\t\t\t\t\t\tnew this._lib.LatLng(coordinates[1], coordinates[0]),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"LineString\":\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconst coordinates = updatedFeature.geometry.coordinates;\n\n\t\t\t\t\t\t\tconst path: google.maps.LatLng[] = [];\n\t\t\t\t\t\t\tfor (let i = 0; i < coordinates.length; i++) {\n\t\t\t\t\t\t\t\tconst coordinate = coordinates[i];\n\t\t\t\t\t\t\t\tconst latLng = new this._lib.LatLng(\n\t\t\t\t\t\t\t\t\tcoordinate[1],\n\t\t\t\t\t\t\t\t\tcoordinate[0],\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tpath.push(latLng);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tfeatureToUpdate.setGeometry(new this._lib.Data.LineString(path));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Polygon\":\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconst coordinates = updatedFeature.geometry.coordinates;\n\n\t\t\t\t\t\t\tconst paths: google.maps.LatLng[][] = [];\n\t\t\t\t\t\t\tfor (let i = 0; i < coordinates.length; i++) {\n\t\t\t\t\t\t\t\tconst path: google.maps.LatLng[] = [];\n\t\t\t\t\t\t\t\tfor (let j = 0; j < coordinates[i].length; j++) {\n\t\t\t\t\t\t\t\t\tconst latLng = new this._lib.LatLng(\n\t\t\t\t\t\t\t\t\t\tcoordinates[i][j][1],\n\t\t\t\t\t\t\t\t\t\tcoordinates[i][j][0],\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tpath.push(latLng);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tpaths.push(path);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tfeatureToUpdate.setGeometry(new this._lib.Data.Polygon(paths));\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// Create new features\n\t\t\tchanges.created.forEach((createdFeature) => {\n\t\t\t\tthis.renderedFeatureIds.add(createdFeature.id as string);\n\t\t\t\tthis._map.data.addGeoJson(createdFeature);\n\t\t\t});\n\t\t}\n\n\t\tchanges.created.forEach((feature) => {\n\t\t\tthis.renderedFeatureIds.add(feature.id as string);\n\t\t});\n\n\t\tconst featureCollection = {\n\t\t\ttype: \"FeatureCollection\",\n\t\t\tfeatures: [...changes.created],\n\t\t} as GeoJsonObject;\n\n\t\tthis._map.data.addGeoJson(featureCollection);\n\n\t\tthis._map.data.setStyle((feature) => {\n\t\t\tconst mode = feature.getProperty(\"mode\");\n\t\t\tconst gmGeometry = feature.getGeometry();\n\t\t\tif (!gmGeometry) {\n\t\t\t\tthrow new Error(\"Google Maps geometry not found\");\n\t\t\t}\n\t\t\tconst type = gmGeometry.getType();\n\t\t\tconst properties: Record<string, any> = {};\n\n\t\t\tfeature.forEachProperty((value, property) => {\n\t\t\t\tproperties[property] = value;\n\t\t\t});\n\n\t\t\tconst calculatedStyles = styling[mode]({\n\t\t\t\ttype: \"Feature\",\n\t\t\t\tgeometry: {\n\t\t\t\t\ttype: type as \"Point\" | \"LineString\" | \"Polygon\",\n\t\t\t\t\tcoordinates: [],\n\t\t\t\t},\n\t\t\t\tproperties,\n\t\t\t});\n\n\t\t\tswitch (type) {\n\t\t\t\tcase \"Point\":\n\t\t\t\t\tconst path = this.circlePath(0, 0, calculatedStyles.pointWidth);\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tclickable: false,\n\t\t\t\t\t\ticon: {\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\tfillColor: calculatedStyles.pointColor,\n\t\t\t\t\t\t\tfillOpacity: 1,\n\t\t\t\t\t\t\tstrokeColor: calculatedStyles.pointOutlineColor,\n\t\t\t\t\t\t\tstrokeWeight: calculatedStyles.pointOutlineWidth,\n\t\t\t\t\t\t\trotation: 0,\n\t\t\t\t\t\t\tscale: 1,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tzIndex: calculatedStyles.zIndex,\n\t\t\t\t\t};\n\n\t\t\t\tcase \"LineString\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstrokeColor: calculatedStyles.lineStringColor,\n\t\t\t\t\t\tstrokeWeight: calculatedStyles.lineStringWidth,\n\t\t\t\t\t\tzIndex: calculatedStyles.zIndex,\n\t\t\t\t\t};\n\t\t\t\tcase \"Polygon\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstrokeColor: calculatedStyles.polygonOutlineColor,\n\t\t\t\t\t\tstrokeWeight: calculatedStyles.polygonOutlineWidth,\n\t\t\t\t\t\tfillOpacity: calculatedStyles.polygonFillOpacity,\n\t\t\t\t\t\tfillColor: calculatedStyles.polygonFillColor,\n\t\t\t\t\t\tzIndex: calculatedStyles.zIndex,\n\t\t\t\t\t};\n\t\t\t}\n\n\t\t\tthrow Error(\"Unknown feature type\");\n\t\t});\n\t}\n\n\tprivate clearLayers() {\n\t\tif (this._layers) {\n\t\t\tthis._map.data.forEach((feature) => {\n\t\t\t\tconst id = feature.getId() as string;\n\t\t\t\tconst hasFeature = this.renderedFeatureIds.has(id);\n\t\t\t\tif (hasFeature) {\n\t\t\t\t\tthis._map.data.remove(feature);\n\t\t\t\t}\n\t\t\t});\n\t\t\tthis.renderedFeatureIds = new Set();\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\tpublic getCoordinatePrecision(): number {\n\t\t// TODO: It seems this shouldn't be necessary as extends BaseAdapter which as this method\n\t\treturn super.getCoordinatePrecision();\n\t}\n}\n"],"names":["_TerraDrawExtend$Terr","TerraDrawGoogleMapsAdapter","config","_this","call","this","_cursor","_cursorStyleSheet","_lib","_map","_overlay","_clickEventListener","_mouseMoveEventListener","_readyCalled","renderedFeatureIds","Set","lib","map","getDiv","id","Error","_coordinatePrecision","coordinatePrecision","_proto","prototype","circlePath","cx","cy","r","d","register","callbacks","_this2","OverlayView","draw","onAdd","_this2$_currentModeCa","_currentModeCallbacks","onReady","setMap","onRemove","data","addListener","event","clickListener","_listeners","find","_ref","name","callback","mouseMoveListener","_ref2","unregister","_this$_clickEventList","_this$_mouseMoveEvent","remove","getMap","undefined","getLngLatFromEvent","bounds","getBounds","ne","getNorthEast","sw","getSouthWest","latLngBounds","LatLngBounds","mapCanvas","offsetX","clientX","getBoundingClientRect","left","offsetY","clientY","top","screenCoord","Point","projection","getProjection","latLng","fromContainerPixelToLatLng","contains","lng","lat","getMapEventElement","querySelector","project","point","fromLatLngToContainerPixel","LatLng","x","y","unproject","setCursor","cursor","div","styleDiv","document","classList","add","style","createElement","innerHTML","getElementsByTagName","appendChild","setDoubleClickToZoom","enabled","setOptions","disableDoubleClickZoom","setDraggability","draggable","render","changes","styling","_this3","_layers","deletedIds","forEach","deletedId","featureToDelete","getFeatureById","updated","updatedFeature","featureToUpdate","forEachProperty","property","setProperty","Object","keys","properties","geometry","type","coordinates","setGeometry","Data","path","i","length","coordinate","push","LineString","paths","j","Polygon","created","createdFeature","addGeoJson","feature","featureCollection","features","concat","setStyle","mode","getProperty","gmGeometry","getGeometry","getType","value","calculatedStyles","clickable","icon","pointWidth","fillColor","pointColor","fillOpacity","strokeColor","pointOutlineColor","strokeWeight","pointOutlineWidth","rotation","scale","zIndex","lineStringColor","lineStringWidth","polygonOutlineColor","polygonOutlineWidth","polygonFillOpacity","polygonFillColor","clearLayers","_this4","getId","has","clear","onClear","getCoordinatePrecision","key","get","_this$renderedFeature","Boolean","size","TerraDrawExtend","TerraDrawBaseAdapter"],"mappings":"oeAWwC,SAAAA,GACvC,SAAAC,EACCC,GAGqCC,IAAAA,EAQrC,IANAA,EAAAH,EAAAI,KAAMF,KAAAA,IAAOG,MAgBNC,aAAOH,EAAAA,EACPI,uBAAiBJ,EAAAA,EACjBK,UAAIL,EAAAA,EACJM,UAAIN,EAAAA,EACJO,gBAAQP,EACRQ,yBAAmB,EAAAR,EACnBS,6BAAuB,EAAAT,EACvBU,cAAe,EAAKV,EAiQpBW,mBAAqD,IAAI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,kBAC9BC,aAAcT,EAAiBU,kBAC/BC,SAAU,EACVC,MAAO,GAERC,OAAQb,EAAiBa,QAG3B,IAAK,aACJ,MAAO,CACNN,YAAaP,EAAiBc,gBAC9BL,aAAcT,EAAiBe,gBAC/BF,OAAQb,EAAiBa,QAE3B,IAAK,UACJ,MAAO,CACNN,YAAaP,EAAiBgB,oBAC9BP,aAAcT,EAAiBiB,oBAC/BX,YAAaN,EAAiBkB,mBAC9Bd,UAAWJ,EAAiBmB,iBAC5BN,OAAQb,EAAiBa,QAI5B,MAAMvJ,MAAM,uBACb,EACD,EAACG,EAEO2J,YAAA,WAAWC,IAAAA,EAClB9K,KAAIA,KAAK8G,UACR9G,KAAKI,KAAKgC,KAAK4E,QAAQ,SAAC8B,GACvB,IAAMhI,EAAKgI,EAAQiC,QACAD,EAAKrK,mBAAmBuK,IAAIlK,IAE9CgK,EAAK1K,KAAKgC,KAAKc,OAAO4F,EAExB,GACA9I,KAAKS,mBAAqB,IAAIC,IAEhC,EAACQ,EAMM+J,MAAA,WACFjL,KAAKgC,wBAERhC,KAAKgC,sBAAsBkJ,UAG3BlL,KAAK6K,cAEP,EAAC3J,EAEMiK,uBAAA,WAEN,OAAAxL,EAAAwB,UAAagK,uBAAsBpL,KACpCC,KAAA,IAACJ,KAAA,CAAA,CAAAwL,IAAA,UAAAC,IA3cD,WAAmB,IAAAC,EAClB,OAAOC,SAAQD,OAAAA,EAAAtL,KAAKS,yBAAL6K,EAAAA,EAAyBE,MAAO,EAChD,iPAlC+CC,CAAR,CAAQA,EAAAA,gBAAgBC"}
1
+ {"version":3,"file":"terra-draw-google-maps-adapter.cjs","sources":["../src/terra-draw-google-maps-adapter.ts"],"sourcesContent":["/**\n * @module terra-draw-google-maps-adapter\n */\nimport {\n\tTerraDrawChanges,\n\tSetCursor,\n\tTerraDrawStylingFunction,\n\tTerraDrawExtend,\n} from \"terra-draw\";\nimport { GeoJsonObject } from \"geojson\";\n\nexport class TerraDrawGoogleMapsAdapter extends TerraDrawExtend.TerraDrawBaseAdapter {\n\tconstructor(\n\t\tconfig: {\n\t\t\tlib: typeof google.maps;\n\t\t\tmap: google.maps.Map;\n\t\t} & TerraDrawExtend.BaseAdapterConfig,\n\t) {\n\t\tsuper(config);\n\t\tthis._lib = config.lib;\n\t\tthis._map = config.map;\n\n\t\t// In order for the internals of the adapter to work we require an ID to\n\t\t// allow query selectors to work\n\t\tif (!this._map.getDiv().id) {\n\t\t\tthrow new Error(\"Google Map container div requires and id to be set\");\n\t\t}\n\n\t\tthis._coordinatePrecision =\n\t\t\ttypeof config.coordinatePrecision === \"number\"\n\t\t\t\t? config.coordinatePrecision\n\t\t\t\t: 9;\n\t}\n\n\tprivate _cursor: string | undefined;\n\tprivate _cursorStyleSheet: HTMLStyleElement | undefined;\n\tprivate _lib: typeof google.maps;\n\tprivate _map: google.maps.Map;\n\tprivate _overlay: google.maps.OverlayView | undefined;\n\tprivate _clickEventListener: google.maps.MapsEventListener | undefined;\n\tprivate _mouseMoveEventListener: google.maps.MapsEventListener | undefined;\n\tprivate _readyCalled = false;\n\n\tprivate get _layers(): boolean {\n\t\treturn Boolean(this.renderedFeatureIds?.size > 0);\n\t}\n\n\t/**\n\t * Generates an SVG path string for a circle with the given center coordinates and radius.\n\t * Based off this StackOverflow answer: https://stackoverflow.com/a/27905268/1363484\n\t * @param cx The x-coordinate of the circle's center.\n\t * @param cy The y-coordinate of the circle's center.\n\t * @param r The radius of the circle.\n\t * @returns The SVG path string representing the circle.\n\t */\n\tprivate circlePath(cx: number, cy: number, r: number) {\n\t\tconst d = r * 2;\n\t\treturn `M ${cx} ${cy} m -${r}, 0 a ${r},${r} 0 1,0 ${d},0 a ${r},${r} 0 1,0 -${d},0`;\n\t}\n\n\tpublic register(callbacks: TerraDrawExtend.TerraDrawCallbacks) {\n\t\tsuper.register(callbacks);\n\n\t\t// The overlay is responsible for allow us to\n\t\t// get the projection, which in turn allows us to\n\t\t// go through lng/lat to pixel space and vice versa\n\t\tthis._overlay = new this._lib.OverlayView();\n\t\tthis._overlay.draw = function () {\n\t\t\t// No-op\n\t\t};\n\n\t\t// Unfortunately it is only ready after the onAdd\n\t\t// method is called, which is why we need to use the 'ready'\n\t\t// listener with the Google Maps adapter\n\t\tthis._overlay.onAdd = () => {\n\t\t\tif (this._currentModeCallbacks?.onReady && !this._readyCalled) {\n\t\t\t\tthis._currentModeCallbacks.onReady();\n\t\t\t\tthis._readyCalled = true;\n\t\t\t}\n\t\t};\n\t\tthis._overlay.setMap(this._map);\n\n\t\t// Required to avoid runtime error in Google Maps API\n\t\tthis._overlay.onRemove = () => {\n\t\t\t// No-op\n\t\t};\n\n\t\t// Clicking on data geometries triggers\n\t\t// swallows the map onclick event,\n\t\t// so we need to forward it to the click callback handler\n\t\tthis._clickEventListener = this._map.data.addListener(\n\t\t\t\"click\",\n\t\t\t(\n\t\t\t\tevent: google.maps.MapMouseEvent & {\n\t\t\t\t\tdomEvent: MouseEvent;\n\t\t\t\t},\n\t\t\t) => {\n\t\t\t\tconst clickListener = this._listeners.find(\n\t\t\t\t\t({ name }) => name === \"click\",\n\t\t\t\t);\n\t\t\t\tif (clickListener) {\n\t\t\t\t\tclickListener.callback(event);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\n\t\tthis._mouseMoveEventListener = this._map.data.addListener(\n\t\t\t\"mousemove\",\n\t\t\t(\n\t\t\t\tevent: google.maps.MapMouseEvent & {\n\t\t\t\t\tdomEvent: MouseEvent;\n\t\t\t\t},\n\t\t\t) => {\n\t\t\t\tconst mouseMoveListener = this._listeners.find(\n\t\t\t\t\t({ name }) => name === \"mousemove\",\n\t\t\t\t);\n\t\t\t\tif (mouseMoveListener) {\n\t\t\t\t\tmouseMoveListener.callback(event);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t}\n\n\tpublic unregister(): void {\n\t\tsuper.unregister();\n\t\tthis._clickEventListener?.remove();\n\t\tthis._mouseMoveEventListener?.remove();\n\n\t\tif (this._overlay && this._overlay.getMap()) {\n\t\t\tthis._overlay.setMap(null);\n\t\t}\n\t\tthis._overlay = undefined;\n\t\tthis._readyCalled = false;\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\tgetLngLatFromEvent(event: PointerEvent | MouseEvent) {\n\t\tif (!this._overlay) {\n\t\t\tthrow new Error(\"cannot get overlay\");\n\t\t}\n\n\t\tconst bounds = this._map.getBounds();\n\n\t\tif (!bounds) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst ne = bounds.getNorthEast();\n\t\tconst sw = bounds.getSouthWest();\n\t\tconst latLngBounds = new this._lib.LatLngBounds(sw, ne);\n\n\t\tconst mapCanvas = this._map.getDiv();\n\t\tconst offsetX = event.clientX - mapCanvas.getBoundingClientRect().left;\n\t\tconst offsetY = event.clientY - mapCanvas.getBoundingClientRect().top;\n\t\tconst screenCoord = new this._lib.Point(offsetX, offsetY);\n\n\t\tconst projection = this._overlay.getProjection();\n\t\tif (!projection) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst latLng = projection.fromContainerPixelToLatLng(screenCoord);\n\n\t\tif (latLng && latLngBounds.contains(latLng)) {\n\t\t\treturn { lng: latLng.lng(), lat: latLng.lat() };\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * Retrieves the HTML element of the Google Map element that handles interaction events\n\t * @returns The HTMLElement representing the map container.\n\t */\n\tpublic getMapEventElement() {\n\t\t// TODO: This is a bit hacky, maybe there is a better solution here\n\t\tconst selector = 'div[style*=\"z-index: 3;\"]';\n\t\treturn this._map.getDiv().querySelector(selector) as HTMLDivElement;\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\tproject(lng: number, lat: number) {\n\t\tif (!this._overlay) {\n\t\t\tthrow new Error(\"cannot get overlay\");\n\t\t}\n\n\t\tconst bounds = this._map.getBounds();\n\n\t\tif (bounds === undefined) {\n\t\t\tthrow new Error(\"cannot get bounds\");\n\t\t}\n\n\t\tconst projection = this._overlay.getProjection();\n\t\tif (projection === undefined) {\n\t\t\tthrow new Error(\"cannot get projection\");\n\t\t}\n\n\t\tconst point = projection.fromLatLngToContainerPixel(\n\t\t\tnew this._lib.LatLng(lat, lng),\n\t\t);\n\n\t\tif (point === null) {\n\t\t\tthrow new Error(\"cannot project coordinates\");\n\t\t}\n\n\t\treturn { x: point.x, y: point.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\tunproject(x: number, y: number) {\n\t\tif (!this._overlay) {\n\t\t\tthrow new Error(\"cannot get overlay\");\n\t\t}\n\n\t\tconst projection = this._overlay.getProjection();\n\t\tif (projection === undefined) {\n\t\t\tthrow new Error(\"cannot get projection\");\n\t\t}\n\n\t\tconst latLng = projection.fromContainerPixelToLatLng(\n\t\t\tnew this._lib.Point(x, y),\n\t\t);\n\n\t\tif (latLng === null) {\n\t\t\tthrow new Error(\"cannot unproject coordinates\");\n\t\t}\n\n\t\treturn { lng: latLng.lng(), lat: latLng.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\tsetCursor(cursor: Parameters<SetCursor>[0]) {\n\t\tif (cursor === this._cursor) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this._cursorStyleSheet) {\n\t\t\tthis._cursorStyleSheet.remove();\n\t\t\tthis._cursorStyleSheet = undefined;\n\t\t}\n\n\t\tif (cursor !== \"unset\") {\n\t\t\t// TODO: We could cache these individually per cursor\n\n\t\t\tconst div = this._map.getDiv();\n\t\t\tconst styleDivSelector = `#${div.id} .gm-style > div`;\n\t\t\tconst styleDiv = document.querySelector(styleDivSelector);\n\n\t\t\tif (styleDiv) {\n\t\t\t\tstyleDiv.classList.add(\"terra-draw-google-maps\");\n\n\t\t\t\tconst style = document.createElement(\"style\");\n\t\t\t\tstyle.innerHTML = `.terra-draw-google-maps { cursor: ${cursor} !important; }`;\n\t\t\t\tdocument.getElementsByTagName(\"head\")[0].appendChild(style);\n\t\t\t\tthis._cursorStyleSheet = style;\n\t\t\t}\n\t\t}\n\n\t\tthis._cursor = cursor;\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\tsetDoubleClickToZoom(enabled: boolean) {\n\t\tif (enabled) {\n\t\t\tthis._map.setOptions({ disableDoubleClickZoom: false });\n\t\t} else {\n\t\t\tthis._map.setOptions({ disableDoubleClickZoom: true });\n\t\t}\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\tsetDraggability(enabled: boolean) {\n\t\tthis._map.setOptions({ draggable: enabled });\n\t}\n\n\tprivate renderedFeatureIds: Set<TerraDrawExtend.FeatureId> = new Set();\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\trender(changes: TerraDrawChanges, styling: TerraDrawStylingFunction) {\n\t\tif (this._layers) {\n\t\t\tchanges.deletedIds.forEach((deletedId) => {\n\t\t\t\tconst featureToDelete = this._map.data.getFeatureById(deletedId);\n\t\t\t\tif (featureToDelete) {\n\t\t\t\t\tthis._map.data.remove(featureToDelete);\n\t\t\t\t\tthis.renderedFeatureIds.delete(deletedId);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tchanges.updated.forEach((updatedFeature) => {\n\t\t\t\tif (!updatedFeature || !updatedFeature.id) {\n\t\t\t\t\tthrow new Error(\"Feature is not valid\");\n\t\t\t\t}\n\n\t\t\t\tconst featureToUpdate = this._map.data.getFeatureById(\n\t\t\t\t\tupdatedFeature.id,\n\t\t\t\t);\n\n\t\t\t\tif (!featureToUpdate) {\n\t\t\t\t\tthrow new Error(\"Feature could not be found by Google Maps API\");\n\t\t\t\t}\n\n\t\t\t\t// Remove all keys\n\t\t\t\tfeatureToUpdate.forEachProperty((property, name) => {\n\t\t\t\t\tfeatureToUpdate.setProperty(name, undefined);\n\t\t\t\t});\n\n\t\t\t\t// Update all keys\n\t\t\t\tObject.keys(updatedFeature.properties).forEach((property) => {\n\t\t\t\t\tfeatureToUpdate.setProperty(\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\tupdatedFeature.properties[property],\n\t\t\t\t\t);\n\t\t\t\t});\n\n\t\t\t\tswitch (updatedFeature.geometry.type) {\n\t\t\t\t\tcase \"Point\":\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconst coordinates = updatedFeature.geometry.coordinates;\n\n\t\t\t\t\t\t\tfeatureToUpdate.setGeometry(\n\t\t\t\t\t\t\t\tnew this._lib.Data.Point(\n\t\t\t\t\t\t\t\t\tnew this._lib.LatLng(coordinates[1], coordinates[0]),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"LineString\":\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconst coordinates = updatedFeature.geometry.coordinates;\n\n\t\t\t\t\t\t\tconst path: google.maps.LatLng[] = [];\n\t\t\t\t\t\t\tfor (let i = 0; i < coordinates.length; i++) {\n\t\t\t\t\t\t\t\tconst coordinate = coordinates[i];\n\t\t\t\t\t\t\t\tconst latLng = new this._lib.LatLng(\n\t\t\t\t\t\t\t\t\tcoordinate[1],\n\t\t\t\t\t\t\t\t\tcoordinate[0],\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tpath.push(latLng);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tfeatureToUpdate.setGeometry(new this._lib.Data.LineString(path));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Polygon\":\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconst coordinates = updatedFeature.geometry.coordinates;\n\n\t\t\t\t\t\t\tconst paths: google.maps.LatLng[][] = [];\n\t\t\t\t\t\t\tfor (let i = 0; i < coordinates.length; i++) {\n\t\t\t\t\t\t\t\tconst path: google.maps.LatLng[] = [];\n\t\t\t\t\t\t\t\tfor (let j = 0; j < coordinates[i].length; j++) {\n\t\t\t\t\t\t\t\t\tconst latLng = new this._lib.LatLng(\n\t\t\t\t\t\t\t\t\t\tcoordinates[i][j][1],\n\t\t\t\t\t\t\t\t\t\tcoordinates[i][j][0],\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tpath.push(latLng);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tpaths.push(path);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tfeatureToUpdate.setGeometry(new this._lib.Data.Polygon(paths));\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// Create new features\n\t\t\tchanges.created.forEach((createdFeature) => {\n\t\t\t\tthis.renderedFeatureIds.add(createdFeature.id as string);\n\t\t\t\tthis._map.data.addGeoJson(createdFeature);\n\t\t\t});\n\t\t}\n\n\t\tchanges.created.forEach((feature) => {\n\t\t\tthis.renderedFeatureIds.add(feature.id as string);\n\t\t});\n\n\t\tconst featureCollection = {\n\t\t\ttype: \"FeatureCollection\",\n\t\t\tfeatures: [...changes.created],\n\t\t} as GeoJsonObject;\n\n\t\tthis._map.data.addGeoJson(featureCollection);\n\n\t\tthis._map.data.setStyle((feature) => {\n\t\t\tconst mode = feature.getProperty(\"mode\");\n\t\t\tconst gmGeometry = feature.getGeometry();\n\t\t\tif (!gmGeometry) {\n\t\t\t\tthrow new Error(\"Google Maps geometry not found\");\n\t\t\t}\n\t\t\tconst type = gmGeometry.getType();\n\t\t\tconst properties: Record<string, any> = {};\n\t\t\tconst id = feature.getId();\n\n\t\t\tfeature.forEachProperty((value, property) => {\n\t\t\t\tproperties[property] = value;\n\t\t\t});\n\n\t\t\tconst calculatedStyles = styling[mode]({\n\t\t\t\ttype: \"Feature\",\n\t\t\t\tid,\n\t\t\t\tgeometry: {\n\t\t\t\t\ttype: type as \"Point\" | \"LineString\" | \"Polygon\",\n\t\t\t\t\tcoordinates: [],\n\t\t\t\t},\n\t\t\t\tproperties,\n\t\t\t});\n\n\t\t\tswitch (type) {\n\t\t\t\tcase \"Point\":\n\t\t\t\t\tconst path = this.circlePath(0, 0, calculatedStyles.pointWidth);\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tclickable: false,\n\t\t\t\t\t\ticon: {\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\tfillColor: calculatedStyles.pointColor,\n\t\t\t\t\t\t\tfillOpacity: 1,\n\t\t\t\t\t\t\tstrokeColor: calculatedStyles.pointOutlineColor,\n\t\t\t\t\t\t\tstrokeWeight: calculatedStyles.pointOutlineWidth,\n\t\t\t\t\t\t\trotation: 0,\n\t\t\t\t\t\t\tscale: 1,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tzIndex: calculatedStyles.zIndex,\n\t\t\t\t\t};\n\n\t\t\t\tcase \"LineString\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstrokeColor: calculatedStyles.lineStringColor,\n\t\t\t\t\t\tstrokeWeight: calculatedStyles.lineStringWidth,\n\t\t\t\t\t\tzIndex: calculatedStyles.zIndex,\n\t\t\t\t\t};\n\t\t\t\tcase \"Polygon\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstrokeColor: calculatedStyles.polygonOutlineColor,\n\t\t\t\t\t\tstrokeWeight: calculatedStyles.polygonOutlineWidth,\n\t\t\t\t\t\tfillOpacity: calculatedStyles.polygonFillOpacity,\n\t\t\t\t\t\tfillColor: calculatedStyles.polygonFillColor,\n\t\t\t\t\t\tzIndex: calculatedStyles.zIndex,\n\t\t\t\t\t};\n\t\t\t}\n\n\t\t\tthrow Error(\"Unknown feature type\");\n\t\t});\n\t}\n\n\tprivate clearLayers() {\n\t\tif (this._layers) {\n\t\t\tthis._map.data.forEach((feature) => {\n\t\t\t\tconst id = feature.getId() as string;\n\t\t\t\tconst hasFeature = this.renderedFeatureIds.has(id);\n\t\t\t\tif (hasFeature) {\n\t\t\t\t\tthis._map.data.remove(feature);\n\t\t\t\t}\n\t\t\t});\n\t\t\tthis.renderedFeatureIds = new Set();\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\tpublic getCoordinatePrecision(): number {\n\t\t// TODO: It seems this shouldn't be necessary as extends BaseAdapter which as this method\n\t\treturn super.getCoordinatePrecision();\n\t}\n}\n"],"names":["_TerraDrawExtend$Terr","TerraDrawGoogleMapsAdapter","config","_this","call","this","_cursor","_cursorStyleSheet","_lib","_map","_overlay","_clickEventListener","_mouseMoveEventListener","_readyCalled","renderedFeatureIds","Set","lib","map","getDiv","id","Error","_coordinatePrecision","coordinatePrecision","_proto","prototype","circlePath","cx","cy","r","d","register","callbacks","_this2","OverlayView","draw","onAdd","_this2$_currentModeCa","_currentModeCallbacks","onReady","setMap","onRemove","data","addListener","event","clickListener","_listeners","find","_ref","name","callback","mouseMoveListener","_ref2","unregister","_this$_clickEventList","_this$_mouseMoveEvent","remove","getMap","undefined","getLngLatFromEvent","bounds","getBounds","ne","getNorthEast","sw","getSouthWest","latLngBounds","LatLngBounds","mapCanvas","offsetX","clientX","getBoundingClientRect","left","offsetY","clientY","top","screenCoord","Point","projection","getProjection","latLng","fromContainerPixelToLatLng","contains","lng","lat","getMapEventElement","querySelector","project","point","fromLatLngToContainerPixel","LatLng","x","y","unproject","setCursor","cursor","div","styleDiv","document","classList","add","style","createElement","innerHTML","getElementsByTagName","appendChild","setDoubleClickToZoom","enabled","setOptions","disableDoubleClickZoom","setDraggability","draggable","render","changes","styling","_this3","_layers","deletedIds","forEach","deletedId","featureToDelete","getFeatureById","updated","updatedFeature","featureToUpdate","forEachProperty","property","setProperty","Object","keys","properties","geometry","type","coordinates","setGeometry","Data","path","i","length","coordinate","push","LineString","paths","j","Polygon","created","createdFeature","addGeoJson","feature","featureCollection","features","concat","setStyle","mode","getProperty","gmGeometry","getGeometry","getType","getId","value","calculatedStyles","clickable","icon","pointWidth","fillColor","pointColor","fillOpacity","strokeColor","pointOutlineColor","strokeWeight","pointOutlineWidth","rotation","scale","zIndex","lineStringColor","lineStringWidth","polygonOutlineColor","polygonOutlineWidth","polygonFillOpacity","polygonFillColor","clearLayers","_this4","has","clear","onClear","getCoordinatePrecision","key","get","_this$renderedFeature","Boolean","size","TerraDrawExtend","TerraDrawBaseAdapter"],"mappings":"oeAWwC,SAAAA,GACvC,SAAAC,EACCC,GAGqCC,IAAAA,EAQrC,IANAA,EAAAH,EAAAI,KAAMF,KAAAA,IAAOG,MAgBNC,aAAOH,EAAAA,EACPI,uBAAiBJ,EAAAA,EACjBK,UAAIL,EAAAA,EACJM,UAAIN,EAAAA,EACJO,gBAAQP,EACRQ,yBAAmB,EAAAR,EACnBS,6BAAuB,EAAAT,EACvBU,cAAe,EAAKV,EAiQpBW,mBAAqD,IAAIC,IAvRhEZ,EAAKK,KAAON,EAAOc,IACnBb,EAAKM,KAAOP,EAAOe,KAIdd,EAAKM,KAAKS,SAASC,GACvB,MAAM,IAAIC,MAAM,sDAMX,OAHNjB,EAAKkB,qBACkC,iB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AaP,EAAiBc,gBAC9BL,aAAcT,EAAiBe,gBAC/BF,OAAQb,EAAiBa,QAE3B,IAAK,UACJ,MAAO,CACNN,YAAaP,EAAiBgB,oBAC9BP,aAAcT,EAAiBiB,oBAC/BX,YAAaN,EAAiBkB,mBAC9Bd,UAAWJ,EAAiBmB,iBAC5BN,OAAQb,EAAiBa,QAI5B,MAAMxJ,MAAM,uBACb,EACD,EAACG,EAEO4J,YAAA,WAAW,IAAAC,EAAA/K,KACdA,KAAK8G,UACR9G,KAAKI,KAAKgC,KAAK4E,QAAQ,SAAC8B,GACvB,IAAMhI,EAAKgI,EAAQU,QACAuB,EAAKtK,mBAAmBuK,IAAIlK,IAE9CiK,EAAK3K,KAAKgC,KAAKc,OAAO4F,EAExB,GACA9I,KAAKS,mBAAqB,IAAIC,IAEhC,EAACQ,EAMM+J,MAAA,WACFjL,KAAKgC,wBAERhC,KAAKgC,sBAAsBkJ,UAG3BlL,KAAK8K,cAEP,EAAC5J,EAEMiK,uBAAA,WAEN,OAAAxL,EAAAwB,UAAagK,uBAAsBpL,KACpCC,KAAA,IAACJ,KAAA,CAAA,CAAAwL,IAAA,UAAAC,IA7cD,WAAmB,IAAAC,EAClB,OAAOC,SAAQD,OAAAA,EAAAtL,KAAKS,yBAAL6K,EAAAA,EAAyBE,MAAO,EAChD,iPAlC+CC,CAAR,CAAQA,EAAAA,gBAAgBC"}
@@ -1,2 +1,2 @@
1
- import{TerraDrawExtend as e}from"terra-draw";class t extends e.TerraDrawBaseAdapter{constructor(e){if(super(e),this._cursor=void 0,this._cursorStyleSheet=void 0,this._lib=void 0,this._map=void 0,this._overlay=void 0,this._clickEventListener=void 0,this._mouseMoveEventListener=void 0,this._readyCalled=!1,this.renderedFeatureIds=new Set,this._lib=e.lib,this._map=e.map,!this._map.getDiv().id)throw new Error("Google Map container div requires and id to be set");this._coordinatePrecision="number"==typeof e.coordinatePrecision?e.coordinatePrecision:9}get _layers(){var e;return Boolean((null==(e=this.renderedFeatureIds)?void 0:e.size)>0)}circlePath(e,t,r){const o=2*r;return`M ${e} ${t} m -${r}, 0 a ${r},${r} 0 1,0 ${o},0 a ${r},${r} 0 1,0 -${o},0`}register(e){super.register(e),this._overlay=new this._lib.OverlayView,this._overlay.draw=function(){},this._overlay.onAdd=()=>{var e;null!=(e=this._currentModeCallbacks)&&e.onReady&&!this._readyCalled&&(this._currentModeCallbacks.onReady(),this._readyCalled=!0)},this._overlay.setMap(this._map),this._overlay.onRemove=()=>{},this._clickEventListener=this._map.data.addListener("click",e=>{const t=this._listeners.find(({name:e})=>"click"===e);t&&t.callback(e)}),this._mouseMoveEventListener=this._map.data.addListener("mousemove",e=>{const t=this._listeners.find(({name:e})=>"mousemove"===e);t&&t.callback(e)})}unregister(){var e,t;super.unregister(),null==(e=this._clickEventListener)||e.remove(),null==(t=this._mouseMoveEventListener)||t.remove(),this._overlay&&this._overlay.getMap()&&this._overlay.setMap(null),this._overlay=void 0,this._readyCalled=!1}getLngLatFromEvent(e){if(!this._overlay)throw new Error("cannot get overlay");const t=this._map.getBounds();if(!t)return null;const r=t.getNorthEast(),o=t.getSouthWest(),i=new this._lib.LatLngBounds(o,r),n=this._map.getDiv(),s=e.clientX-n.getBoundingClientRect().left,a=e.clientY-n.getBoundingClientRect().top,l=new this._lib.Point(s,a),d=this._overlay.getProjection();if(!d)return null;const c=d.fromContainerPixelToLatLng(l);return c&&i.contains(c)?{lng:c.lng(),lat:c.lat()}:null}getMapEventElement(){return this._map.getDiv().querySelector('div[style*="z-index: 3;"]')}project(e,t){if(!this._overlay)throw new Error("cannot get overlay");if(void 0===this._map.getBounds())throw new Error("cannot get bounds");const r=this._overlay.getProjection();if(void 0===r)throw new Error("cannot get projection");const o=r.fromLatLngToContainerPixel(new this._lib.LatLng(t,e));if(null===o)throw new Error("cannot project coordinates");return{x:o.x,y:o.y}}unproject(e,t){if(!this._overlay)throw new Error("cannot get overlay");const r=this._overlay.getProjection();if(void 0===r)throw new Error("cannot get projection");const o=r.fromContainerPixelToLatLng(new this._lib.Point(e,t));if(null===o)throw new Error("cannot unproject coordinates");return{lng:o.lng(),lat:o.lat()}}setCursor(e){if(e!==this._cursor){if(this._cursorStyleSheet&&(this._cursorStyleSheet.remove(),this._cursorStyleSheet=void 0),"unset"!==e){const t=this._map.getDiv(),r=document.querySelector(`#${t.id} .gm-style > div`);if(r){r.classList.add("terra-draw-google-maps");const t=document.createElement("style");t.innerHTML=`.terra-draw-google-maps { cursor: ${e} !important; }`,document.getElementsByTagName("head")[0].appendChild(t),this._cursorStyleSheet=t}}this._cursor=e}}setDoubleClickToZoom(e){this._map.setOptions(e?{disableDoubleClickZoom:!1}:{disableDoubleClickZoom:!0})}setDraggability(e){this._map.setOptions({draggable:e})}render(e,t){this._layers&&(e.deletedIds.forEach(e=>{const t=this._map.data.getFeatureById(e);t&&(this._map.data.remove(t),this.renderedFeatureIds.delete(e))}),e.updated.forEach(e=>{if(!e||!e.id)throw new Error("Feature is not valid");const t=this._map.data.getFeatureById(e.id);if(!t)throw new Error("Feature could not be found by Google Maps API");switch(t.forEachProperty((e,r)=>{t.setProperty(r,void 0)}),Object.keys(e.properties).forEach(r=>{t.setProperty(r,e.properties[r])}),e.geometry.type){case"Point":{const r=e.geometry.coordinates;t.setGeometry(new this._lib.Data.Point(new this._lib.LatLng(r[1],r[0])))}break;case"LineString":{const r=e.geometry.coordinates,o=[];for(let e=0;e<r.length;e++){const t=r[e],i=new this._lib.LatLng(t[1],t[0]);o.push(i)}t.setGeometry(new this._lib.Data.LineString(o))}break;case"Polygon":{const r=e.geometry.coordinates,o=[];for(let e=0;e<r.length;e++){const t=[];for(let o=0;o<r[e].length;o++){const i=new this._lib.LatLng(r[e][o][1],r[e][o][0]);t.push(i)}o.push(t)}t.setGeometry(new this._lib.Data.Polygon(o))}}}),e.created.forEach(e=>{this.renderedFeatureIds.add(e.id),this._map.data.addGeoJson(e)})),e.created.forEach(e=>{this.renderedFeatureIds.add(e.id)});const r={type:"FeatureCollection",features:[...e.created]};this._map.data.addGeoJson(r),this._map.data.setStyle(e=>{const r=e.getProperty("mode"),o=e.getGeometry();if(!o)throw new Error("Google Maps geometry not found");const i=o.getType(),n={};e.forEachProperty((e,t)=>{n[t]=e});const s=t[r]({type:"Feature",geometry:{type:i,coordinates:[]},properties:n});switch(i){case"Point":return{clickable:!1,icon:{path:this.circlePath(0,0,s.pointWidth),fillColor:s.pointColor,fillOpacity:1,strokeColor:s.pointOutlineColor,strokeWeight:s.pointOutlineWidth,rotation:0,scale:1},zIndex:s.zIndex};case"LineString":return{strokeColor:s.lineStringColor,strokeWeight:s.lineStringWidth,zIndex:s.zIndex};case"Polygon":return{strokeColor:s.polygonOutlineColor,strokeWeight:s.polygonOutlineWidth,fillOpacity:s.polygonFillOpacity,fillColor:s.polygonFillColor,zIndex:s.zIndex}}throw Error("Unknown feature type")})}clearLayers(){this._layers&&(this._map.data.forEach(e=>{const t=e.getId();this.renderedFeatureIds.has(t)&&this._map.data.remove(e)}),this.renderedFeatureIds=new Set)}clear(){this._currentModeCallbacks&&(this._currentModeCallbacks.onClear(),this.clearLayers())}getCoordinatePrecision(){return super.getCoordinatePrecision()}}export{t as TerraDrawGoogleMapsAdapter};
1
+ import{TerraDrawExtend as e}from"terra-draw";class t extends e.TerraDrawBaseAdapter{constructor(e){if(super(e),this._cursor=void 0,this._cursorStyleSheet=void 0,this._lib=void 0,this._map=void 0,this._overlay=void 0,this._clickEventListener=void 0,this._mouseMoveEventListener=void 0,this._readyCalled=!1,this.renderedFeatureIds=new Set,this._lib=e.lib,this._map=e.map,!this._map.getDiv().id)throw new Error("Google Map container div requires and id to be set");this._coordinatePrecision="number"==typeof e.coordinatePrecision?e.coordinatePrecision:9}get _layers(){var e;return Boolean((null==(e=this.renderedFeatureIds)?void 0:e.size)>0)}circlePath(e,t,r){const o=2*r;return`M ${e} ${t} m -${r}, 0 a ${r},${r} 0 1,0 ${o},0 a ${r},${r} 0 1,0 -${o},0`}register(e){super.register(e),this._overlay=new this._lib.OverlayView,this._overlay.draw=function(){},this._overlay.onAdd=()=>{var e;null!=(e=this._currentModeCallbacks)&&e.onReady&&!this._readyCalled&&(this._currentModeCallbacks.onReady(),this._readyCalled=!0)},this._overlay.setMap(this._map),this._overlay.onRemove=()=>{},this._clickEventListener=this._map.data.addListener("click",e=>{const t=this._listeners.find(({name:e})=>"click"===e);t&&t.callback(e)}),this._mouseMoveEventListener=this._map.data.addListener("mousemove",e=>{const t=this._listeners.find(({name:e})=>"mousemove"===e);t&&t.callback(e)})}unregister(){var e,t;super.unregister(),null==(e=this._clickEventListener)||e.remove(),null==(t=this._mouseMoveEventListener)||t.remove(),this._overlay&&this._overlay.getMap()&&this._overlay.setMap(null),this._overlay=void 0,this._readyCalled=!1}getLngLatFromEvent(e){if(!this._overlay)throw new Error("cannot get overlay");const t=this._map.getBounds();if(!t)return null;const r=t.getNorthEast(),o=t.getSouthWest(),i=new this._lib.LatLngBounds(o,r),n=this._map.getDiv(),s=e.clientX-n.getBoundingClientRect().left,a=e.clientY-n.getBoundingClientRect().top,l=new this._lib.Point(s,a),d=this._overlay.getProjection();if(!d)return null;const c=d.fromContainerPixelToLatLng(l);return c&&i.contains(c)?{lng:c.lng(),lat:c.lat()}:null}getMapEventElement(){return this._map.getDiv().querySelector('div[style*="z-index: 3;"]')}project(e,t){if(!this._overlay)throw new Error("cannot get overlay");if(void 0===this._map.getBounds())throw new Error("cannot get bounds");const r=this._overlay.getProjection();if(void 0===r)throw new Error("cannot get projection");const o=r.fromLatLngToContainerPixel(new this._lib.LatLng(t,e));if(null===o)throw new Error("cannot project coordinates");return{x:o.x,y:o.y}}unproject(e,t){if(!this._overlay)throw new Error("cannot get overlay");const r=this._overlay.getProjection();if(void 0===r)throw new Error("cannot get projection");const o=r.fromContainerPixelToLatLng(new this._lib.Point(e,t));if(null===o)throw new Error("cannot unproject coordinates");return{lng:o.lng(),lat:o.lat()}}setCursor(e){if(e!==this._cursor){if(this._cursorStyleSheet&&(this._cursorStyleSheet.remove(),this._cursorStyleSheet=void 0),"unset"!==e){const t=this._map.getDiv(),r=document.querySelector(`#${t.id} .gm-style > div`);if(r){r.classList.add("terra-draw-google-maps");const t=document.createElement("style");t.innerHTML=`.terra-draw-google-maps { cursor: ${e} !important; }`,document.getElementsByTagName("head")[0].appendChild(t),this._cursorStyleSheet=t}}this._cursor=e}}setDoubleClickToZoom(e){this._map.setOptions(e?{disableDoubleClickZoom:!1}:{disableDoubleClickZoom:!0})}setDraggability(e){this._map.setOptions({draggable:e})}render(e,t){this._layers&&(e.deletedIds.forEach(e=>{const t=this._map.data.getFeatureById(e);t&&(this._map.data.remove(t),this.renderedFeatureIds.delete(e))}),e.updated.forEach(e=>{if(!e||!e.id)throw new Error("Feature is not valid");const t=this._map.data.getFeatureById(e.id);if(!t)throw new Error("Feature could not be found by Google Maps API");switch(t.forEachProperty((e,r)=>{t.setProperty(r,void 0)}),Object.keys(e.properties).forEach(r=>{t.setProperty(r,e.properties[r])}),e.geometry.type){case"Point":{const r=e.geometry.coordinates;t.setGeometry(new this._lib.Data.Point(new this._lib.LatLng(r[1],r[0])))}break;case"LineString":{const r=e.geometry.coordinates,o=[];for(let e=0;e<r.length;e++){const t=r[e],i=new this._lib.LatLng(t[1],t[0]);o.push(i)}t.setGeometry(new this._lib.Data.LineString(o))}break;case"Polygon":{const r=e.geometry.coordinates,o=[];for(let e=0;e<r.length;e++){const t=[];for(let o=0;o<r[e].length;o++){const i=new this._lib.LatLng(r[e][o][1],r[e][o][0]);t.push(i)}o.push(t)}t.setGeometry(new this._lib.Data.Polygon(o))}}}),e.created.forEach(e=>{this.renderedFeatureIds.add(e.id),this._map.data.addGeoJson(e)})),e.created.forEach(e=>{this.renderedFeatureIds.add(e.id)});const r={type:"FeatureCollection",features:[...e.created]};this._map.data.addGeoJson(r),this._map.data.setStyle(e=>{const r=e.getProperty("mode"),o=e.getGeometry();if(!o)throw new Error("Google Maps geometry not found");const i=o.getType(),n={},s=e.getId();e.forEachProperty((e,t)=>{n[t]=e});const a=t[r]({type:"Feature",id:s,geometry:{type:i,coordinates:[]},properties:n});switch(i){case"Point":return{clickable:!1,icon:{path:this.circlePath(0,0,a.pointWidth),fillColor:a.pointColor,fillOpacity:1,strokeColor:a.pointOutlineColor,strokeWeight:a.pointOutlineWidth,rotation:0,scale:1},zIndex:a.zIndex};case"LineString":return{strokeColor:a.lineStringColor,strokeWeight:a.lineStringWidth,zIndex:a.zIndex};case"Polygon":return{strokeColor:a.polygonOutlineColor,strokeWeight:a.polygonOutlineWidth,fillOpacity:a.polygonFillOpacity,fillColor:a.polygonFillColor,zIndex:a.zIndex}}throw Error("Unknown feature type")})}clearLayers(){this._layers&&(this._map.data.forEach(e=>{const t=e.getId();this.renderedFeatureIds.has(t)&&this._map.data.remove(e)}),this.renderedFeatureIds=new Set)}clear(){this._currentModeCallbacks&&(this._currentModeCallbacks.onClear(),this.clearLayers())}getCoordinatePrecision(){return super.getCoordinatePrecision()}}export{t as TerraDrawGoogleMapsAdapter};
2
2
  //# sourceMappingURL=terra-draw-google-maps-adapter.modern.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"terra-draw-google-maps-adapter.modern.js","sources":["../src/terra-draw-google-maps-adapter.ts"],"sourcesContent":["/**\n * @module terra-draw-google-maps-adapter\n */\nimport {\n\tTerraDrawChanges,\n\tSetCursor,\n\tTerraDrawStylingFunction,\n\tTerraDrawExtend,\n} from \"terra-draw\";\nimport { GeoJsonObject } from \"geojson\";\n\nexport class TerraDrawGoogleMapsAdapter extends TerraDrawExtend.TerraDrawBaseAdapter {\n\tconstructor(\n\t\tconfig: {\n\t\t\tlib: typeof google.maps;\n\t\t\tmap: google.maps.Map;\n\t\t} & TerraDrawExtend.BaseAdapterConfig,\n\t) {\n\t\tsuper(config);\n\t\tthis._lib = config.lib;\n\t\tthis._map = config.map;\n\n\t\t// In order for the internals of the adapter to work we require an ID to\n\t\t// allow query selectors to work\n\t\tif (!this._map.getDiv().id) {\n\t\t\tthrow new Error(\"Google Map container div requires and id to be set\");\n\t\t}\n\n\t\tthis._coordinatePrecision =\n\t\t\ttypeof config.coordinatePrecision === \"number\"\n\t\t\t\t? config.coordinatePrecision\n\t\t\t\t: 9;\n\t}\n\n\tprivate _cursor: string | undefined;\n\tprivate _cursorStyleSheet: HTMLStyleElement | undefined;\n\tprivate _lib: typeof google.maps;\n\tprivate _map: google.maps.Map;\n\tprivate _overlay: google.maps.OverlayView | undefined;\n\tprivate _clickEventListener: google.maps.MapsEventListener | undefined;\n\tprivate _mouseMoveEventListener: google.maps.MapsEventListener | undefined;\n\tprivate _readyCalled = false;\n\n\tprivate get _layers(): boolean {\n\t\treturn Boolean(this.renderedFeatureIds?.size > 0);\n\t}\n\n\t/**\n\t * Generates an SVG path string for a circle with the given center coordinates and radius.\n\t * Based off this StackOverflow answer: https://stackoverflow.com/a/27905268/1363484\n\t * @param cx The x-coordinate of the circle's center.\n\t * @param cy The y-coordinate of the circle's center.\n\t * @param r The radius of the circle.\n\t * @returns The SVG path string representing the circle.\n\t */\n\tprivate circlePath(cx: number, cy: number, r: number) {\n\t\tconst d = r * 2;\n\t\treturn `M ${cx} ${cy} m -${r}, 0 a ${r},${r} 0 1,0 ${d},0 a ${r},${r} 0 1,0 -${d},0`;\n\t}\n\n\tpublic register(callbacks: TerraDrawExtend.TerraDrawCallbacks) {\n\t\tsuper.register(callbacks);\n\n\t\t// The overlay is responsible for allow us to\n\t\t// get the projection, which in turn allows us to\n\t\t// go through lng/lat to pixel space and vice versa\n\t\tthis._overlay = new this._lib.OverlayView();\n\t\tthis._overlay.draw = function () {\n\t\t\t// No-op\n\t\t};\n\n\t\t// Unfortunately it is only ready after the onAdd\n\t\t// method is called, which is why we need to use the 'ready'\n\t\t// listener with the Google Maps adapter\n\t\tthis._overlay.onAdd = () => {\n\t\t\tif (this._currentModeCallbacks?.onReady && !this._readyCalled) {\n\t\t\t\tthis._currentModeCallbacks.onReady();\n\t\t\t\tthis._readyCalled = true;\n\t\t\t}\n\t\t};\n\t\tthis._overlay.setMap(this._map);\n\n\t\t// Required to avoid runtime error in Google Maps API\n\t\tthis._overlay.onRemove = () => {\n\t\t\t// No-op\n\t\t};\n\n\t\t// Clicking on data geometries triggers\n\t\t// swallows the map onclick event,\n\t\t// so we need to forward it to the click callback handler\n\t\tthis._clickEventListener = this._map.data.addListener(\n\t\t\t\"click\",\n\t\t\t(\n\t\t\t\tevent: google.maps.MapMouseEvent & {\n\t\t\t\t\tdomEvent: MouseEvent;\n\t\t\t\t},\n\t\t\t) => {\n\t\t\t\tconst clickListener = this._listeners.find(\n\t\t\t\t\t({ name }) => name === \"click\",\n\t\t\t\t);\n\t\t\t\tif (clickListener) {\n\t\t\t\t\tclickListener.callback(event);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\n\t\tthis._mouseMoveEventListener = this._map.data.addListener(\n\t\t\t\"mousemove\",\n\t\t\t(\n\t\t\t\tevent: google.maps.MapMouseEvent & {\n\t\t\t\t\tdomEvent: MouseEvent;\n\t\t\t\t},\n\t\t\t) => {\n\t\t\t\tconst mouseMoveListener = this._listeners.find(\n\t\t\t\t\t({ name }) => name === \"mousemove\",\n\t\t\t\t);\n\t\t\t\tif (mouseMoveListener) {\n\t\t\t\t\tmouseMoveListener.callback(event);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t}\n\n\tpublic unregister(): void {\n\t\tsuper.unregister();\n\t\tthis._clickEventListener?.remove();\n\t\tthis._mouseMoveEventListener?.remove();\n\n\t\tif (this._overlay && this._overlay.getMap()) {\n\t\t\tthis._overlay.setMap(null);\n\t\t}\n\t\tthis._overlay = undefined;\n\t\tthis._readyCalled = false;\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\tgetLngLatFromEvent(event: PointerEvent | MouseEvent) {\n\t\tif (!this._overlay) {\n\t\t\tthrow new Error(\"cannot get overlay\");\n\t\t}\n\n\t\tconst bounds = this._map.getBounds();\n\n\t\tif (!bounds) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst ne = bounds.getNorthEast();\n\t\tconst sw = bounds.getSouthWest();\n\t\tconst latLngBounds = new this._lib.LatLngBounds(sw, ne);\n\n\t\tconst mapCanvas = this._map.getDiv();\n\t\tconst offsetX = event.clientX - mapCanvas.getBoundingClientRect().left;\n\t\tconst offsetY = event.clientY - mapCanvas.getBoundingClientRect().top;\n\t\tconst screenCoord = new this._lib.Point(offsetX, offsetY);\n\n\t\tconst projection = this._overlay.getProjection();\n\t\tif (!projection) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst latLng = projection.fromContainerPixelToLatLng(screenCoord);\n\n\t\tif (latLng && latLngBounds.contains(latLng)) {\n\t\t\treturn { lng: latLng.lng(), lat: latLng.lat() };\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * Retrieves the HTML element of the Google Map element that handles interaction events\n\t * @returns The HTMLElement representing the map container.\n\t */\n\tpublic getMapEventElement() {\n\t\t// TODO: This is a bit hacky, maybe there is a better solution here\n\t\tconst selector = 'div[style*=\"z-index: 3;\"]';\n\t\treturn this._map.getDiv().querySelector(selector) as HTMLDivElement;\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\tproject(lng: number, lat: number) {\n\t\tif (!this._overlay) {\n\t\t\tthrow new Error(\"cannot get overlay\");\n\t\t}\n\n\t\tconst bounds = this._map.getBounds();\n\n\t\tif (bounds === undefined) {\n\t\t\tthrow new Error(\"cannot get bounds\");\n\t\t}\n\n\t\tconst projection = this._overlay.getProjection();\n\t\tif (projection === undefined) {\n\t\t\tthrow new Error(\"cannot get projection\");\n\t\t}\n\n\t\tconst point = projection.fromLatLngToContainerPixel(\n\t\t\tnew this._lib.LatLng(lat, lng),\n\t\t);\n\n\t\tif (point === null) {\n\t\t\tthrow new Error(\"cannot project coordinates\");\n\t\t}\n\n\t\treturn { x: point.x, y: point.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\tunproject(x: number, y: number) {\n\t\tif (!this._overlay) {\n\t\t\tthrow new Error(\"cannot get overlay\");\n\t\t}\n\n\t\tconst projection = this._overlay.getProjection();\n\t\tif (projection === undefined) {\n\t\t\tthrow new Error(\"cannot get projection\");\n\t\t}\n\n\t\tconst latLng = projection.fromContainerPixelToLatLng(\n\t\t\tnew this._lib.Point(x, y),\n\t\t);\n\n\t\tif (latLng === null) {\n\t\t\tthrow new Error(\"cannot unproject coordinates\");\n\t\t}\n\n\t\treturn { lng: latLng.lng(), lat: latLng.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\tsetCursor(cursor: Parameters<SetCursor>[0]) {\n\t\tif (cursor === this._cursor) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this._cursorStyleSheet) {\n\t\t\tthis._cursorStyleSheet.remove();\n\t\t\tthis._cursorStyleSheet = undefined;\n\t\t}\n\n\t\tif (cursor !== \"unset\") {\n\t\t\t// TODO: We could cache these individually per cursor\n\n\t\t\tconst div = this._map.getDiv();\n\t\t\tconst styleDivSelector = `#${div.id} .gm-style > div`;\n\t\t\tconst styleDiv = document.querySelector(styleDivSelector);\n\n\t\t\tif (styleDiv) {\n\t\t\t\tstyleDiv.classList.add(\"terra-draw-google-maps\");\n\n\t\t\t\tconst style = document.createElement(\"style\");\n\t\t\t\tstyle.innerHTML = `.terra-draw-google-maps { cursor: ${cursor} !important; }`;\n\t\t\t\tdocument.getElementsByTagName(\"head\")[0].appendChild(style);\n\t\t\t\tthis._cursorStyleSheet = style;\n\t\t\t}\n\t\t}\n\n\t\tthis._cursor = cursor;\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\tsetDoubleClickToZoom(enabled: boolean) {\n\t\tif (enabled) {\n\t\t\tthis._map.setOptions({ disableDoubleClickZoom: false });\n\t\t} else {\n\t\t\tthis._map.setOptions({ disableDoubleClickZoom: true });\n\t\t}\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\tsetDraggability(enabled: boolean) {\n\t\tthis._map.setOptions({ draggable: enabled });\n\t}\n\n\tprivate renderedFeatureIds: Set<TerraDrawExtend.FeatureId> = new Set();\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\trender(changes: TerraDrawChanges, styling: TerraDrawStylingFunction) {\n\t\tif (this._layers) {\n\t\t\tchanges.deletedIds.forEach((deletedId) => {\n\t\t\t\tconst featureToDelete = this._map.data.getFeatureById(deletedId);\n\t\t\t\tif (featureToDelete) {\n\t\t\t\t\tthis._map.data.remove(featureToDelete);\n\t\t\t\t\tthis.renderedFeatureIds.delete(deletedId);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tchanges.updated.forEach((updatedFeature) => {\n\t\t\t\tif (!updatedFeature || !updatedFeature.id) {\n\t\t\t\t\tthrow new Error(\"Feature is not valid\");\n\t\t\t\t}\n\n\t\t\t\tconst featureToUpdate = this._map.data.getFeatureById(\n\t\t\t\t\tupdatedFeature.id,\n\t\t\t\t);\n\n\t\t\t\tif (!featureToUpdate) {\n\t\t\t\t\tthrow new Error(\"Feature could not be found by Google Maps API\");\n\t\t\t\t}\n\n\t\t\t\t// Remove all keys\n\t\t\t\tfeatureToUpdate.forEachProperty((property, name) => {\n\t\t\t\t\tfeatureToUpdate.setProperty(name, undefined);\n\t\t\t\t});\n\n\t\t\t\t// Update all keys\n\t\t\t\tObject.keys(updatedFeature.properties).forEach((property) => {\n\t\t\t\t\tfeatureToUpdate.setProperty(\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\tupdatedFeature.properties[property],\n\t\t\t\t\t);\n\t\t\t\t});\n\n\t\t\t\tswitch (updatedFeature.geometry.type) {\n\t\t\t\t\tcase \"Point\":\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconst coordinates = updatedFeature.geometry.coordinates;\n\n\t\t\t\t\t\t\tfeatureToUpdate.setGeometry(\n\t\t\t\t\t\t\t\tnew this._lib.Data.Point(\n\t\t\t\t\t\t\t\t\tnew this._lib.LatLng(coordinates[1], coordinates[0]),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"LineString\":\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconst coordinates = updatedFeature.geometry.coordinates;\n\n\t\t\t\t\t\t\tconst path: google.maps.LatLng[] = [];\n\t\t\t\t\t\t\tfor (let i = 0; i < coordinates.length; i++) {\n\t\t\t\t\t\t\t\tconst coordinate = coordinates[i];\n\t\t\t\t\t\t\t\tconst latLng = new this._lib.LatLng(\n\t\t\t\t\t\t\t\t\tcoordinate[1],\n\t\t\t\t\t\t\t\t\tcoordinate[0],\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tpath.push(latLng);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tfeatureToUpdate.setGeometry(new this._lib.Data.LineString(path));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Polygon\":\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconst coordinates = updatedFeature.geometry.coordinates;\n\n\t\t\t\t\t\t\tconst paths: google.maps.LatLng[][] = [];\n\t\t\t\t\t\t\tfor (let i = 0; i < coordinates.length; i++) {\n\t\t\t\t\t\t\t\tconst path: google.maps.LatLng[] = [];\n\t\t\t\t\t\t\t\tfor (let j = 0; j < coordinates[i].length; j++) {\n\t\t\t\t\t\t\t\t\tconst latLng = new this._lib.LatLng(\n\t\t\t\t\t\t\t\t\t\tcoordinates[i][j][1],\n\t\t\t\t\t\t\t\t\t\tcoordinates[i][j][0],\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tpath.push(latLng);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tpaths.push(path);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tfeatureToUpdate.setGeometry(new this._lib.Data.Polygon(paths));\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// Create new features\n\t\t\tchanges.created.forEach((createdFeature) => {\n\t\t\t\tthis.renderedFeatureIds.add(createdFeature.id as string);\n\t\t\t\tthis._map.data.addGeoJson(createdFeature);\n\t\t\t});\n\t\t}\n\n\t\tchanges.created.forEach((feature) => {\n\t\t\tthis.renderedFeatureIds.add(feature.id as string);\n\t\t});\n\n\t\tconst featureCollection = {\n\t\t\ttype: \"FeatureCollection\",\n\t\t\tfeatures: [...changes.created],\n\t\t} as GeoJsonObject;\n\n\t\tthis._map.data.addGeoJson(featureCollection);\n\n\t\tthis._map.data.setStyle((feature) => {\n\t\t\tconst mode = feature.getProperty(\"mode\");\n\t\t\tconst gmGeometry = feature.getGeometry();\n\t\t\tif (!gmGeometry) {\n\t\t\t\tthrow new Error(\"Google Maps geometry not found\");\n\t\t\t}\n\t\t\tconst type = gmGeometry.getType();\n\t\t\tconst properties: Record<string, any> = {};\n\n\t\t\tfeature.forEachProperty((value, property) => {\n\t\t\t\tproperties[property] = value;\n\t\t\t});\n\n\t\t\tconst calculatedStyles = styling[mode]({\n\t\t\t\ttype: \"Feature\",\n\t\t\t\tgeometry: {\n\t\t\t\t\ttype: type as \"Point\" | \"LineString\" | \"Polygon\",\n\t\t\t\t\tcoordinates: [],\n\t\t\t\t},\n\t\t\t\tproperties,\n\t\t\t});\n\n\t\t\tswitch (type) {\n\t\t\t\tcase \"Point\":\n\t\t\t\t\tconst path = this.circlePath(0, 0, calculatedStyles.pointWidth);\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tclickable: false,\n\t\t\t\t\t\ticon: {\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\tfillColor: calculatedStyles.pointColor,\n\t\t\t\t\t\t\tfillOpacity: 1,\n\t\t\t\t\t\t\tstrokeColor: calculatedStyles.pointOutlineColor,\n\t\t\t\t\t\t\tstrokeWeight: calculatedStyles.pointOutlineWidth,\n\t\t\t\t\t\t\trotation: 0,\n\t\t\t\t\t\t\tscale: 1,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tzIndex: calculatedStyles.zIndex,\n\t\t\t\t\t};\n\n\t\t\t\tcase \"LineString\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstrokeColor: calculatedStyles.lineStringColor,\n\t\t\t\t\t\tstrokeWeight: calculatedStyles.lineStringWidth,\n\t\t\t\t\t\tzIndex: calculatedStyles.zIndex,\n\t\t\t\t\t};\n\t\t\t\tcase \"Polygon\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstrokeColor: calculatedStyles.polygonOutlineColor,\n\t\t\t\t\t\tstrokeWeight: calculatedStyles.polygonOutlineWidth,\n\t\t\t\t\t\tfillOpacity: calculatedStyles.polygonFillOpacity,\n\t\t\t\t\t\tfillColor: calculatedStyles.polygonFillColor,\n\t\t\t\t\t\tzIndex: calculatedStyles.zIndex,\n\t\t\t\t\t};\n\t\t\t}\n\n\t\t\tthrow Error(\"Unknown feature type\");\n\t\t});\n\t}\n\n\tprivate clearLayers() {\n\t\tif (this._layers) {\n\t\t\tthis._map.data.forEach((feature) => {\n\t\t\t\tconst id = feature.getId() as string;\n\t\t\t\tconst hasFeature = this.renderedFeatureIds.has(id);\n\t\t\t\tif (hasFeature) {\n\t\t\t\t\tthis._map.data.remove(feature);\n\t\t\t\t}\n\t\t\t});\n\t\t\tthis.renderedFeatureIds = new Set();\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\tpublic getCoordinatePrecision(): number {\n\t\t// TODO: It seems this shouldn't be necessary as extends BaseAdapter which as this method\n\t\treturn super.getCoordinatePrecision();\n\t}\n}\n"],"names":["TerraDrawGoogleMapsAdapter","TerraDrawExtend","TerraDrawBaseAdapter","constructor","config","super","this","_cursor","_cursorStyleSheet","_lib","_map","_overlay","_clickEventListener","_mouseMoveEventListener","_readyCalled","renderedFeatureIds","Set","lib","map","getDiv","id","Error","_coordinatePrecision","coordinatePrecision","_layers","_this$renderedFeature","Boolean","size","circlePath","cx","cy","r","d","register","callbacks","OverlayView","draw","onAdd","_this$_currentModeCal","_currentModeCallbacks","onReady","setMap","onRemove","data","addListener","event","clickListener","_listeners","find","name","callback","mouseMoveListener","unregister","_this$_clickEventList","_this$_mouseMoveEvent","remove","getMap","undefined","getLngLatFromEvent","bounds","getBounds","ne","getNorthEast","sw","getSouthWest","latLngBounds","LatLngBounds","mapCanvas","offsetX","clientX","getBoundingClientRect","left","offsetY","clientY","top","screenCoord","Point","projection","getProjection","latLng","fromContainerPixelToLatLng","contains","lng","lat","getMapEventElement","querySelector","project","point","fromLatLngToContainerPixel","LatLng","x","y","unproject","setCursor","cursor","div","styleDiv","document","classList","add","style","createElement","innerHTML","getElementsByTagName","appendChild","setDoubleClickToZoom","enabled","setOptions","disableDoubleClickZoom","setDraggability","draggable","render","changes","styling","deletedIds","forEach","deletedId","featureToDelete","getFeatureById","delete","updated","updatedFeature","featureToUpdate","forEachProperty","property","setProperty","Object","keys","properties","geometry","type","coordinates","setGeometry","Data","path","i","length","coordinate","push","LineString","paths","j","Polygon","created","createdFeature","addGeoJson","feature","featureCollection","features","setStyle","mode","getProperty","gmGeometry","getGeometry","getType","value","calculatedStyles","clickable","icon","pointWidth","fillColor","pointColor","fillOpacity","strokeColor","pointOutlineColor","strokeWeight","pointOutlineWidth","rotation","scale","zIndex","lineStringColor","lineStringWidth","polygonOutlineColor","polygonOutlineWidth","polygonFillOpacity","polygonFillColor","clearLayers","getId","has","clear","onClear","getCoordinatePrecision"],"mappings":"6CAWa,MAAAA,UAAmCC,EAAgBC,qBAC/DC,WAAAA,CACCC,GAWA,GANAC,MAAMD,GAAQE,KAgBPC,aACAC,EAAAA,KAAAA,8BACAC,UAAI,EAAAH,KACJI,UAAI,EAAAJ,KACJK,cAAQ,EAAAL,KACRM,yBAAmB,EAAAN,KACnBO,6BAAuB,EAAAP,KACvBQ,cAAe,EAAKR,KAiQpBS,mBAAqD,IAAIC,IAvRhEV,KAAKG,KAAOL,EAAOa,IACnBX,KAAKI,KAAON,EAAOc,KAIdZ,KAAKI,KAAKS,SAASC,GACvB,MAAM,IAAIC,MAAM,sDAGjBf,KAAKgB,qBACkC,iBAA/BlB,EAAOmB,oBACXnB,EAAOmB,oBACP,CACL,CAWA,WAAYC,GAAOC,IAAAA,EAClB,OAAOC,gBAAQD,EAAAnB,KAAKS,2BAALU,EAAyBE,MAAO,EAChD,CAUQC,UAAAA,CAAWC,EAAYC,EAAYC,GAC1C,MAAMC,EAAQ,EAAJD,EACV,MAAO,KAAKF,KAAMC,QAASC,UAAUA,KAAKA,WAAWC,SAASD,KAAKA,YAAYC,KAChF,CAEOC,QAAAA,CAASC,GACf7B,MAAM4B,SAASC,GAKf5B,KAAKK,SAAW,IAAQL,KAACG,KAAK0B,YAC9B7B,KAAKK,SAASyB,KAAO,WAEpB,EAKD9B,KAAKK,SAAS0B,MAAQ,KAAK,IAA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AExCkB,EAAQvB,gBAAgB,CAACgC,EAAO/B,KAC/BI,EAAWJ,GAAY+B,CAAAA,GAGxB,MAAMC,EAAmB3C,EAAQqC,GAAM,CACtCpB,KAAM,UACND,SAAU,CACTC,KAAMA,EACNC,YAAa,IAEdH,eAGD,OAAQE,GACP,IAAK,QAGJ,MAAO,CACN2B,WAAW,EACXC,KAAM,CACLxB,KALWhI,KAAKsB,WAAW,EAAG,EAAGgI,EAAiBG,YAMlDC,UAAWJ,EAAiBK,WAC5BC,YAAa,EACbC,YAAaP,EAAiBQ,kBAC9BC,aAAcT,EAAiBU,kBAC/BC,SAAU,EACVC,MAAO,GAERC,OAAQb,EAAiBa,QAG3B,IAAK,aACJ,MAAO,CACNN,YAAaP,EAAiBc,gBAC9BL,aAAcT,EAAiBe,gBAC/BF,OAAQb,EAAiBa,QAE3B,IAAK,UACJ,MAAO,CACNN,YAAaP,EAAiBgB,oBAC9BP,aAAcT,EAAiBiB,oBAC/BX,YAAaN,EAAiBkB,mBAC9Bd,UAAWJ,EAAiBmB,iBAC5BN,OAAQb,EAAiBa,QAI5B,MAAMpJ,MAAM,uBAAsB,EAEpC,CAEQ2J,WAAAA,GACH1K,KAAKkB,UACRlB,KAAKI,KAAKiC,KAAKwE,QAAS+B,IACvB,MAAM9H,EAAK8H,EAAQ+B,QACA3K,KAAKS,mBAAmBmK,IAAI9J,IAE9Cd,KAAKI,KAAKiC,KAAKY,OAAO2F,EACvB,GAED5I,KAAKS,mBAAqB,IAAIC,IAEhC,CAMOmK,KAAAA,GACF7K,KAAKiC,wBAERjC,KAAKiC,sBAAsB6I,UAG3B9K,KAAK0K,cAEP,CAEOK,sBAAAA,GAEN,OAAOhL,MAAMgL,wBACd"}
1
+ {"version":3,"file":"terra-draw-google-maps-adapter.modern.js","sources":["../src/terra-draw-google-maps-adapter.ts"],"sourcesContent":["/**\n * @module terra-draw-google-maps-adapter\n */\nimport {\n\tTerraDrawChanges,\n\tSetCursor,\n\tTerraDrawStylingFunction,\n\tTerraDrawExtend,\n} from \"terra-draw\";\nimport { GeoJsonObject } from \"geojson\";\n\nexport class TerraDrawGoogleMapsAdapter extends TerraDrawExtend.TerraDrawBaseAdapter {\n\tconstructor(\n\t\tconfig: {\n\t\t\tlib: typeof google.maps;\n\t\t\tmap: google.maps.Map;\n\t\t} & TerraDrawExtend.BaseAdapterConfig,\n\t) {\n\t\tsuper(config);\n\t\tthis._lib = config.lib;\n\t\tthis._map = config.map;\n\n\t\t// In order for the internals of the adapter to work we require an ID to\n\t\t// allow query selectors to work\n\t\tif (!this._map.getDiv().id) {\n\t\t\tthrow new Error(\"Google Map container div requires and id to be set\");\n\t\t}\n\n\t\tthis._coordinatePrecision =\n\t\t\ttypeof config.coordinatePrecision === \"number\"\n\t\t\t\t? config.coordinatePrecision\n\t\t\t\t: 9;\n\t}\n\n\tprivate _cursor: string | undefined;\n\tprivate _cursorStyleSheet: HTMLStyleElement | undefined;\n\tprivate _lib: typeof google.maps;\n\tprivate _map: google.maps.Map;\n\tprivate _overlay: google.maps.OverlayView | undefined;\n\tprivate _clickEventListener: google.maps.MapsEventListener | undefined;\n\tprivate _mouseMoveEventListener: google.maps.MapsEventListener | undefined;\n\tprivate _readyCalled = false;\n\n\tprivate get _layers(): boolean {\n\t\treturn Boolean(this.renderedFeatureIds?.size > 0);\n\t}\n\n\t/**\n\t * Generates an SVG path string for a circle with the given center coordinates and radius.\n\t * Based off this StackOverflow answer: https://stackoverflow.com/a/27905268/1363484\n\t * @param cx The x-coordinate of the circle's center.\n\t * @param cy The y-coordinate of the circle's center.\n\t * @param r The radius of the circle.\n\t * @returns The SVG path string representing the circle.\n\t */\n\tprivate circlePath(cx: number, cy: number, r: number) {\n\t\tconst d = r * 2;\n\t\treturn `M ${cx} ${cy} m -${r}, 0 a ${r},${r} 0 1,0 ${d},0 a ${r},${r} 0 1,0 -${d},0`;\n\t}\n\n\tpublic register(callbacks: TerraDrawExtend.TerraDrawCallbacks) {\n\t\tsuper.register(callbacks);\n\n\t\t// The overlay is responsible for allow us to\n\t\t// get the projection, which in turn allows us to\n\t\t// go through lng/lat to pixel space and vice versa\n\t\tthis._overlay = new this._lib.OverlayView();\n\t\tthis._overlay.draw = function () {\n\t\t\t// No-op\n\t\t};\n\n\t\t// Unfortunately it is only ready after the onAdd\n\t\t// method is called, which is why we need to use the 'ready'\n\t\t// listener with the Google Maps adapter\n\t\tthis._overlay.onAdd = () => {\n\t\t\tif (this._currentModeCallbacks?.onReady && !this._readyCalled) {\n\t\t\t\tthis._currentModeCallbacks.onReady();\n\t\t\t\tthis._readyCalled = true;\n\t\t\t}\n\t\t};\n\t\tthis._overlay.setMap(this._map);\n\n\t\t// Required to avoid runtime error in Google Maps API\n\t\tthis._overlay.onRemove = () => {\n\t\t\t// No-op\n\t\t};\n\n\t\t// Clicking on data geometries triggers\n\t\t// swallows the map onclick event,\n\t\t// so we need to forward it to the click callback handler\n\t\tthis._clickEventListener = this._map.data.addListener(\n\t\t\t\"click\",\n\t\t\t(\n\t\t\t\tevent: google.maps.MapMouseEvent & {\n\t\t\t\t\tdomEvent: MouseEvent;\n\t\t\t\t},\n\t\t\t) => {\n\t\t\t\tconst clickListener = this._listeners.find(\n\t\t\t\t\t({ name }) => name === \"click\",\n\t\t\t\t);\n\t\t\t\tif (clickListener) {\n\t\t\t\t\tclickListener.callback(event);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\n\t\tthis._mouseMoveEventListener = this._map.data.addListener(\n\t\t\t\"mousemove\",\n\t\t\t(\n\t\t\t\tevent: google.maps.MapMouseEvent & {\n\t\t\t\t\tdomEvent: MouseEvent;\n\t\t\t\t},\n\t\t\t) => {\n\t\t\t\tconst mouseMoveListener = this._listeners.find(\n\t\t\t\t\t({ name }) => name === \"mousemove\",\n\t\t\t\t);\n\t\t\t\tif (mouseMoveListener) {\n\t\t\t\t\tmouseMoveListener.callback(event);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t}\n\n\tpublic unregister(): void {\n\t\tsuper.unregister();\n\t\tthis._clickEventListener?.remove();\n\t\tthis._mouseMoveEventListener?.remove();\n\n\t\tif (this._overlay && this._overlay.getMap()) {\n\t\t\tthis._overlay.setMap(null);\n\t\t}\n\t\tthis._overlay = undefined;\n\t\tthis._readyCalled = false;\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\tgetLngLatFromEvent(event: PointerEvent | MouseEvent) {\n\t\tif (!this._overlay) {\n\t\t\tthrow new Error(\"cannot get overlay\");\n\t\t}\n\n\t\tconst bounds = this._map.getBounds();\n\n\t\tif (!bounds) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst ne = bounds.getNorthEast();\n\t\tconst sw = bounds.getSouthWest();\n\t\tconst latLngBounds = new this._lib.LatLngBounds(sw, ne);\n\n\t\tconst mapCanvas = this._map.getDiv();\n\t\tconst offsetX = event.clientX - mapCanvas.getBoundingClientRect().left;\n\t\tconst offsetY = event.clientY - mapCanvas.getBoundingClientRect().top;\n\t\tconst screenCoord = new this._lib.Point(offsetX, offsetY);\n\n\t\tconst projection = this._overlay.getProjection();\n\t\tif (!projection) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst latLng = projection.fromContainerPixelToLatLng(screenCoord);\n\n\t\tif (latLng && latLngBounds.contains(latLng)) {\n\t\t\treturn { lng: latLng.lng(), lat: latLng.lat() };\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * Retrieves the HTML element of the Google Map element that handles interaction events\n\t * @returns The HTMLElement representing the map container.\n\t */\n\tpublic getMapEventElement() {\n\t\t// TODO: This is a bit hacky, maybe there is a better solution here\n\t\tconst selector = 'div[style*=\"z-index: 3;\"]';\n\t\treturn this._map.getDiv().querySelector(selector) as HTMLDivElement;\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\tproject(lng: number, lat: number) {\n\t\tif (!this._overlay) {\n\t\t\tthrow new Error(\"cannot get overlay\");\n\t\t}\n\n\t\tconst bounds = this._map.getBounds();\n\n\t\tif (bounds === undefined) {\n\t\t\tthrow new Error(\"cannot get bounds\");\n\t\t}\n\n\t\tconst projection = this._overlay.getProjection();\n\t\tif (projection === undefined) {\n\t\t\tthrow new Error(\"cannot get projection\");\n\t\t}\n\n\t\tconst point = projection.fromLatLngToContainerPixel(\n\t\t\tnew this._lib.LatLng(lat, lng),\n\t\t);\n\n\t\tif (point === null) {\n\t\t\tthrow new Error(\"cannot project coordinates\");\n\t\t}\n\n\t\treturn { x: point.x, y: point.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\tunproject(x: number, y: number) {\n\t\tif (!this._overlay) {\n\t\t\tthrow new Error(\"cannot get overlay\");\n\t\t}\n\n\t\tconst projection = this._overlay.getProjection();\n\t\tif (projection === undefined) {\n\t\t\tthrow new Error(\"cannot get projection\");\n\t\t}\n\n\t\tconst latLng = projection.fromContainerPixelToLatLng(\n\t\t\tnew this._lib.Point(x, y),\n\t\t);\n\n\t\tif (latLng === null) {\n\t\t\tthrow new Error(\"cannot unproject coordinates\");\n\t\t}\n\n\t\treturn { lng: latLng.lng(), lat: latLng.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\tsetCursor(cursor: Parameters<SetCursor>[0]) {\n\t\tif (cursor === this._cursor) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this._cursorStyleSheet) {\n\t\t\tthis._cursorStyleSheet.remove();\n\t\t\tthis._cursorStyleSheet = undefined;\n\t\t}\n\n\t\tif (cursor !== \"unset\") {\n\t\t\t// TODO: We could cache these individually per cursor\n\n\t\t\tconst div = this._map.getDiv();\n\t\t\tconst styleDivSelector = `#${div.id} .gm-style > div`;\n\t\t\tconst styleDiv = document.querySelector(styleDivSelector);\n\n\t\t\tif (styleDiv) {\n\t\t\t\tstyleDiv.classList.add(\"terra-draw-google-maps\");\n\n\t\t\t\tconst style = document.createElement(\"style\");\n\t\t\t\tstyle.innerHTML = `.terra-draw-google-maps { cursor: ${cursor} !important; }`;\n\t\t\t\tdocument.getElementsByTagName(\"head\")[0].appendChild(style);\n\t\t\t\tthis._cursorStyleSheet = style;\n\t\t\t}\n\t\t}\n\n\t\tthis._cursor = cursor;\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\tsetDoubleClickToZoom(enabled: boolean) {\n\t\tif (enabled) {\n\t\t\tthis._map.setOptions({ disableDoubleClickZoom: false });\n\t\t} else {\n\t\t\tthis._map.setOptions({ disableDoubleClickZoom: true });\n\t\t}\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\tsetDraggability(enabled: boolean) {\n\t\tthis._map.setOptions({ draggable: enabled });\n\t}\n\n\tprivate renderedFeatureIds: Set<TerraDrawExtend.FeatureId> = new Set();\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\trender(changes: TerraDrawChanges, styling: TerraDrawStylingFunction) {\n\t\tif (this._layers) {\n\t\t\tchanges.deletedIds.forEach((deletedId) => {\n\t\t\t\tconst featureToDelete = this._map.data.getFeatureById(deletedId);\n\t\t\t\tif (featureToDelete) {\n\t\t\t\t\tthis._map.data.remove(featureToDelete);\n\t\t\t\t\tthis.renderedFeatureIds.delete(deletedId);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tchanges.updated.forEach((updatedFeature) => {\n\t\t\t\tif (!updatedFeature || !updatedFeature.id) {\n\t\t\t\t\tthrow new Error(\"Feature is not valid\");\n\t\t\t\t}\n\n\t\t\t\tconst featureToUpdate = this._map.data.getFeatureById(\n\t\t\t\t\tupdatedFeature.id,\n\t\t\t\t);\n\n\t\t\t\tif (!featureToUpdate) {\n\t\t\t\t\tthrow new Error(\"Feature could not be found by Google Maps API\");\n\t\t\t\t}\n\n\t\t\t\t// Remove all keys\n\t\t\t\tfeatureToUpdate.forEachProperty((property, name) => {\n\t\t\t\t\tfeatureToUpdate.setProperty(name, undefined);\n\t\t\t\t});\n\n\t\t\t\t// Update all keys\n\t\t\t\tObject.keys(updatedFeature.properties).forEach((property) => {\n\t\t\t\t\tfeatureToUpdate.setProperty(\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\tupdatedFeature.properties[property],\n\t\t\t\t\t);\n\t\t\t\t});\n\n\t\t\t\tswitch (updatedFeature.geometry.type) {\n\t\t\t\t\tcase \"Point\":\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconst coordinates = updatedFeature.geometry.coordinates;\n\n\t\t\t\t\t\t\tfeatureToUpdate.setGeometry(\n\t\t\t\t\t\t\t\tnew this._lib.Data.Point(\n\t\t\t\t\t\t\t\t\tnew this._lib.LatLng(coordinates[1], coordinates[0]),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"LineString\":\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconst coordinates = updatedFeature.geometry.coordinates;\n\n\t\t\t\t\t\t\tconst path: google.maps.LatLng[] = [];\n\t\t\t\t\t\t\tfor (let i = 0; i < coordinates.length; i++) {\n\t\t\t\t\t\t\t\tconst coordinate = coordinates[i];\n\t\t\t\t\t\t\t\tconst latLng = new this._lib.LatLng(\n\t\t\t\t\t\t\t\t\tcoordinate[1],\n\t\t\t\t\t\t\t\t\tcoordinate[0],\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tpath.push(latLng);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tfeatureToUpdate.setGeometry(new this._lib.Data.LineString(path));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Polygon\":\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconst coordinates = updatedFeature.geometry.coordinates;\n\n\t\t\t\t\t\t\tconst paths: google.maps.LatLng[][] = [];\n\t\t\t\t\t\t\tfor (let i = 0; i < coordinates.length; i++) {\n\t\t\t\t\t\t\t\tconst path: google.maps.LatLng[] = [];\n\t\t\t\t\t\t\t\tfor (let j = 0; j < coordinates[i].length; j++) {\n\t\t\t\t\t\t\t\t\tconst latLng = new this._lib.LatLng(\n\t\t\t\t\t\t\t\t\t\tcoordinates[i][j][1],\n\t\t\t\t\t\t\t\t\t\tcoordinates[i][j][0],\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tpath.push(latLng);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tpaths.push(path);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tfeatureToUpdate.setGeometry(new this._lib.Data.Polygon(paths));\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// Create new features\n\t\t\tchanges.created.forEach((createdFeature) => {\n\t\t\t\tthis.renderedFeatureIds.add(createdFeature.id as string);\n\t\t\t\tthis._map.data.addGeoJson(createdFeature);\n\t\t\t});\n\t\t}\n\n\t\tchanges.created.forEach((feature) => {\n\t\t\tthis.renderedFeatureIds.add(feature.id as string);\n\t\t});\n\n\t\tconst featureCollection = {\n\t\t\ttype: \"FeatureCollection\",\n\t\t\tfeatures: [...changes.created],\n\t\t} as GeoJsonObject;\n\n\t\tthis._map.data.addGeoJson(featureCollection);\n\n\t\tthis._map.data.setStyle((feature) => {\n\t\t\tconst mode = feature.getProperty(\"mode\");\n\t\t\tconst gmGeometry = feature.getGeometry();\n\t\t\tif (!gmGeometry) {\n\t\t\t\tthrow new Error(\"Google Maps geometry not found\");\n\t\t\t}\n\t\t\tconst type = gmGeometry.getType();\n\t\t\tconst properties: Record<string, any> = {};\n\t\t\tconst id = feature.getId();\n\n\t\t\tfeature.forEachProperty((value, property) => {\n\t\t\t\tproperties[property] = value;\n\t\t\t});\n\n\t\t\tconst calculatedStyles = styling[mode]({\n\t\t\t\ttype: \"Feature\",\n\t\t\t\tid,\n\t\t\t\tgeometry: {\n\t\t\t\t\ttype: type as \"Point\" | \"LineString\" | \"Polygon\",\n\t\t\t\t\tcoordinates: [],\n\t\t\t\t},\n\t\t\t\tproperties,\n\t\t\t});\n\n\t\t\tswitch (type) {\n\t\t\t\tcase \"Point\":\n\t\t\t\t\tconst path = this.circlePath(0, 0, calculatedStyles.pointWidth);\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tclickable: false,\n\t\t\t\t\t\ticon: {\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\tfillColor: calculatedStyles.pointColor,\n\t\t\t\t\t\t\tfillOpacity: 1,\n\t\t\t\t\t\t\tstrokeColor: calculatedStyles.pointOutlineColor,\n\t\t\t\t\t\t\tstrokeWeight: calculatedStyles.pointOutlineWidth,\n\t\t\t\t\t\t\trotation: 0,\n\t\t\t\t\t\t\tscale: 1,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tzIndex: calculatedStyles.zIndex,\n\t\t\t\t\t};\n\n\t\t\t\tcase \"LineString\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstrokeColor: calculatedStyles.lineStringColor,\n\t\t\t\t\t\tstrokeWeight: calculatedStyles.lineStringWidth,\n\t\t\t\t\t\tzIndex: calculatedStyles.zIndex,\n\t\t\t\t\t};\n\t\t\t\tcase \"Polygon\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstrokeColor: calculatedStyles.polygonOutlineColor,\n\t\t\t\t\t\tstrokeWeight: calculatedStyles.polygonOutlineWidth,\n\t\t\t\t\t\tfillOpacity: calculatedStyles.polygonFillOpacity,\n\t\t\t\t\t\tfillColor: calculatedStyles.polygonFillColor,\n\t\t\t\t\t\tzIndex: calculatedStyles.zIndex,\n\t\t\t\t\t};\n\t\t\t}\n\n\t\t\tthrow Error(\"Unknown feature type\");\n\t\t});\n\t}\n\n\tprivate clearLayers() {\n\t\tif (this._layers) {\n\t\t\tthis._map.data.forEach((feature) => {\n\t\t\t\tconst id = feature.getId() as string;\n\t\t\t\tconst hasFeature = this.renderedFeatureIds.has(id);\n\t\t\t\tif (hasFeature) {\n\t\t\t\t\tthis._map.data.remove(feature);\n\t\t\t\t}\n\t\t\t});\n\t\t\tthis.renderedFeatureIds = new Set();\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\tpublic getCoordinatePrecision(): number {\n\t\t// TODO: It seems this shouldn't be necessary as extends BaseAdapter which as this method\n\t\treturn super.getCoordinatePrecision();\n\t}\n}\n"],"names":["TerraDrawGoogleMapsAdapter","TerraDrawExtend","TerraDrawBaseAdapter","constructor","config","super","this","_cursor","_cursorStyleSheet","_lib","_map","_overlay","_clickEventListener","_mouseMoveEventListener","_readyCalled","renderedFeatureIds","Set","lib","map","getDiv","id","Error","_coordinatePrecision","coordinatePrecision","_layers","_this$renderedFeature","Boolean","size","circlePath","cx","cy","r","d","register","callbacks","OverlayView","draw","onAdd","_this$_currentModeCal","_currentModeCallbacks","onReady","setMap","onRemove","data","addListener","event","clickListener","_listeners","find","name","callback","mouseMoveListener","unregister","_this$_clickEventList","_this$_mouseMoveEvent","remove","getMap","undefined","getLngLatFromEvent","bounds","getBounds","ne","getNorthEast","sw","getSouthWest","latLngBounds","LatLngBounds","mapCanvas","offsetX","clientX","getBoundingClientRect","left","offsetY","clientY","top","screenCoord","Point","projection","getProjection","latLng","fromContainerPixelToLatLng","contains","lng","lat","getMapEventElement","querySelector","project","point","fromLatLngToContainerPixel","LatLng","x","y","unproject","setCursor","cursor","div","styleDiv","document","classList","add","style","createElement","innerHTML","getElementsByTagName","appendChild","setDoubleClickToZoom","enabled","setOptions","disableDoubleClickZoom","setDraggability","draggable","render","changes","styling","deletedIds","forEach","deletedId","featureToDelete","getFeatureById","delete","updated","updatedFeature","featureToUpdate","forEachProperty","property","setProperty","Object","keys","properties","geometry","type","coordinates","setGeometry","Data","path","i","length","coordinate","push","LineString","paths","j","Polygon","created","createdFeature","addGeoJson","feature","featureCollection","features","setStyle","mode","getProperty","gmGeometry","getGeometry","getType","getId","value","calculatedStyles","clickable","icon","pointWidth","fillColor","pointColor","fillOpacity","strokeColor","pointOutlineColor","strokeWeight","pointOutlineWidth","rotation","scale","zIndex","lineStringColor","lineStringWidth","polygonOutlineColor","polygonOutlineWidth","polygonFillOpacity","polygonFillColor","clearLayers","has","clear","onClear","getCoordinatePrecision"],"mappings":"6CAWa,MAAAA,UAAmCC,EAAgBC,qBAC/DC,WAAAA,CACCC,GAWA,GANAC,MAAMD,GAAQE,KAgBPC,aAAO,EAAAD,KACPE,uBAAiB,EAAAF,KACjBG,UACAC,EAAAA,KAAAA,UACAC,EAAAA,KAAAA,cACAC,EAAAA,KAAAA,yBACAC,EAAAA,KAAAA,6BACAC,EAAAA,KAAAA,cAAe,EAiQfC,KAAAA,mBAAqD,IAAIC,IAvRhEV,KAAKG,KAAOL,EAAOa,IACnBX,KAAKI,KAAON,EAAOc,KAIdZ,KAAKI,KAAKS,SAASC,GACvB,MAAU,IAAAC,MAAM,sDAGjBf,KAAKgB,qBACk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AA,GACH3K,KAAKkB,UACRlB,KAAKI,KAAKiC,KAAKwE,QAAS+B,IACvB,MAAM9H,EAAK8H,EAAQS,QACArJ,KAAKS,mBAAmBmK,IAAI9J,IAE9Cd,KAAKI,KAAKiC,KAAKY,OAAO2F,EACvB,GAED5I,KAAKS,mBAAqB,IAAIC,IAEhC,CAMOmK,KAAAA,GACF7K,KAAKiC,wBAERjC,KAAKiC,sBAAsB6I,UAG3B9K,KAAK2K,cAEP,CAEOI,sBAAAA,GAEN,OAAOhL,MAAMgL,wBACd"}
@@ -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)}function r(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}var o=/*#__PURE__*/function(e){function o(t){var r;if((r=e.call(this,t)||this)._cursor=void 0,r._cursorStyleSheet=void 0,r._lib=void 0,r._map=void 0,r._overlay=void 0,r._clickEventListener=void 0,r._mouseMoveEventListener=void 0,r._readyCalled=!1,r.renderedFeatureIds=new Set,r._lib=t.lib,r._map=t.map,!r._map.getDiv().id)throw new Error("Google Map container div requires and id to be set");return r._coordinatePrecision="number"==typeof t.coordinatePrecision?t.coordinatePrecision:9,r}var n,i;i=e,(n=o).prototype=Object.create(i.prototype),n.prototype.constructor=n,t(n,i);var a,l,s=o.prototype;return s.circlePath=function(e,t,r){var o=2*r;return"M "+e+" "+t+" m -"+r+", 0 a "+r+","+r+" 0 1,0 "+o+",0 a "+r+","+r+" 0 1,0 -"+o+",0"},s.register=function(t){var r=this;e.prototype.register.call(this,t),this._overlay=new this._lib.OverlayView,this._overlay.draw=function(){},this._overlay.onAdd=function(){var e;null!=(e=r._currentModeCallbacks)&&e.onReady&&!r._readyCalled&&(r._currentModeCallbacks.onReady(),r._readyCalled=!0)},this._overlay.setMap(this._map),this._overlay.onRemove=function(){},this._clickEventListener=this._map.data.addListener("click",function(e){var t=r._listeners.find(function(e){return"click"===e.name});t&&t.callback(e)}),this._mouseMoveEventListener=this._map.data.addListener("mousemove",function(e){var t=r._listeners.find(function(e){return"mousemove"===e.name});t&&t.callback(e)})},s.unregister=function(){var t,r;e.prototype.unregister.call(this),null==(t=this._clickEventListener)||t.remove(),null==(r=this._mouseMoveEventListener)||r.remove(),this._overlay&&this._overlay.getMap()&&this._overlay.setMap(null),this._overlay=void 0,this._readyCalled=!1},s.getLngLatFromEvent=function(e){if(!this._overlay)throw new Error("cannot get overlay");var t=this._map.getBounds();if(!t)return null;var r=t.getNorthEast(),o=t.getSouthWest(),n=new this._lib.LatLngBounds(o,r),i=this._map.getDiv(),a=e.clientX-i.getBoundingClientRect().left,l=e.clientY-i.getBoundingClientRect().top,s=new this._lib.Point(a,l),c=this._overlay.getProjection();if(!c)return null;var d=c.fromContainerPixelToLatLng(s);return d&&n.contains(d)?{lng:d.lng(),lat:d.lat()}:null},s.getMapEventElement=function(){return this._map.getDiv().querySelector('div[style*="z-index: 3;"]')},s.project=function(e,t){if(!this._overlay)throw new Error("cannot get overlay");if(void 0===this._map.getBounds())throw new Error("cannot get bounds");var r=this._overlay.getProjection();if(void 0===r)throw new Error("cannot get projection");var o=r.fromLatLngToContainerPixel(new this._lib.LatLng(t,e));if(null===o)throw new Error("cannot project coordinates");return{x:o.x,y:o.y}},s.unproject=function(e,t){if(!this._overlay)throw new Error("cannot get overlay");var r=this._overlay.getProjection();if(void 0===r)throw new Error("cannot get projection");var o=r.fromContainerPixelToLatLng(new this._lib.Point(e,t));if(null===o)throw new Error("cannot unproject coordinates");return{lng:o.lng(),lat:o.lat()}},s.setCursor=function(e){if(e!==this._cursor){if(this._cursorStyleSheet&&(this._cursorStyleSheet.remove(),this._cursorStyleSheet=void 0),"unset"!==e){var t=this._map.getDiv(),r=document.querySelector("#"+t.id+" .gm-style > div");if(r){r.classList.add("terra-draw-google-maps");var o=document.createElement("style");o.innerHTML=".terra-draw-google-maps { cursor: "+e+" !important; }",document.getElementsByTagName("head")[0].appendChild(o),this._cursorStyleSheet=o}}this._cursor=e}},s.setDoubleClickToZoom=function(e){this._map.setOptions(e?{disableDoubleClickZoom:!1}:{disableDoubleClickZoom:!0})},s.setDraggability=function(e){this._map.setOptions({draggable:e})},s.render=function(e,t){var r=this;this._layers&&(e.deletedIds.forEach(function(e){var t=r._map.data.getFeatureById(e);t&&(r._map.data.remove(t),r.renderedFeatureIds.delete(e))}),e.updated.forEach(function(e){if(!e||!e.id)throw new Error("Feature is not valid");var t=r._map.data.getFeatureById(e.id);if(!t)throw new Error("Feature could not be found by Google Maps API");switch(t.forEachProperty(function(e,r){t.setProperty(r,void 0)}),Object.keys(e.properties).forEach(function(r){t.setProperty(r,e.properties[r])}),e.geometry.type){case"Point":var o=e.geometry.coordinates;t.setGeometry(new r._lib.Data.Point(new r._lib.LatLng(o[1],o[0])));break;case"LineString":for(var n=e.geometry.coordinates,i=[],a=0;a<n.length;a++){var l=n[a],s=new r._lib.LatLng(l[1],l[0]);i.push(s)}t.setGeometry(new r._lib.Data.LineString(i));break;case"Polygon":for(var c=e.geometry.coordinates,d=[],u=0;u<c.length;u++){for(var h=[],p=0;p<c[u].length;p++){var v=new r._lib.LatLng(c[u][p][1],c[u][p][0]);h.push(v)}d.push(h)}t.setGeometry(new r._lib.Data.Polygon(d))}}),e.created.forEach(function(e){r.renderedFeatureIds.add(e.id),r._map.data.addGeoJson(e)})),e.created.forEach(function(e){r.renderedFeatureIds.add(e.id)});var o={type:"FeatureCollection",features:[].concat(e.created)};this._map.data.addGeoJson(o),this._map.data.setStyle(function(e){var o=e.getProperty("mode"),n=e.getGeometry();if(!n)throw new Error("Google Maps geometry not found");var i=n.getType(),a={};e.forEachProperty(function(e,t){a[t]=e});var l=t[o]({type:"Feature",geometry:{type:i,coordinates:[]},properties:a});switch(i){case"Point":return{clickable:!1,icon:{path:r.circlePath(0,0,l.pointWidth),fillColor:l.pointColor,fillOpacity:1,strokeColor:l.pointOutlineColor,strokeWeight:l.pointOutlineWidth,rotation:0,scale:1},zIndex:l.zIndex};case"LineString":return{strokeColor:l.lineStringColor,strokeWeight:l.lineStringWidth,zIndex:l.zIndex};case"Polygon":return{strokeColor:l.polygonOutlineColor,strokeWeight:l.polygonOutlineWidth,fillOpacity:l.polygonFillOpacity,fillColor:l.polygonFillColor,zIndex:l.zIndex}}throw Error("Unknown feature type")})},s.clearLayers=function(){var e=this;this._layers&&(this._map.data.forEach(function(t){var r=t.getId();e.renderedFeatureIds.has(r)&&e._map.data.remove(t)}),this.renderedFeatureIds=new Set)},s.clear=function(){this._currentModeCallbacks&&(this._currentModeCallbacks.onClear(),this.clearLayers())},s.getCoordinatePrecision=function(){return e.prototype.getCoordinatePrecision.call(this)},a=o,(l=[{key:"_layers",get:function(){var e;return Boolean((null==(e=this.renderedFeatureIds)?void 0:e.size)>0)}}])&&function(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,r(n.key),n)}}(a.prototype,l),Object.defineProperty(a,"prototype",{writable:!1}),a}(e.TerraDrawBaseAdapter);export{o as TerraDrawGoogleMapsAdapter};
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)}function r(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}var o=/*#__PURE__*/function(e){function o(t){var r;if((r=e.call(this,t)||this)._cursor=void 0,r._cursorStyleSheet=void 0,r._lib=void 0,r._map=void 0,r._overlay=void 0,r._clickEventListener=void 0,r._mouseMoveEventListener=void 0,r._readyCalled=!1,r.renderedFeatureIds=new Set,r._lib=t.lib,r._map=t.map,!r._map.getDiv().id)throw new Error("Google Map container div requires and id to be set");return r._coordinatePrecision="number"==typeof t.coordinatePrecision?t.coordinatePrecision:9,r}var n,i;i=e,(n=o).prototype=Object.create(i.prototype),n.prototype.constructor=n,t(n,i);var a,l,s=o.prototype;return s.circlePath=function(e,t,r){var o=2*r;return"M "+e+" "+t+" m -"+r+", 0 a "+r+","+r+" 0 1,0 "+o+",0 a "+r+","+r+" 0 1,0 -"+o+",0"},s.register=function(t){var r=this;e.prototype.register.call(this,t),this._overlay=new this._lib.OverlayView,this._overlay.draw=function(){},this._overlay.onAdd=function(){var e;null!=(e=r._currentModeCallbacks)&&e.onReady&&!r._readyCalled&&(r._currentModeCallbacks.onReady(),r._readyCalled=!0)},this._overlay.setMap(this._map),this._overlay.onRemove=function(){},this._clickEventListener=this._map.data.addListener("click",function(e){var t=r._listeners.find(function(e){return"click"===e.name});t&&t.callback(e)}),this._mouseMoveEventListener=this._map.data.addListener("mousemove",function(e){var t=r._listeners.find(function(e){return"mousemove"===e.name});t&&t.callback(e)})},s.unregister=function(){var t,r;e.prototype.unregister.call(this),null==(t=this._clickEventListener)||t.remove(),null==(r=this._mouseMoveEventListener)||r.remove(),this._overlay&&this._overlay.getMap()&&this._overlay.setMap(null),this._overlay=void 0,this._readyCalled=!1},s.getLngLatFromEvent=function(e){if(!this._overlay)throw new Error("cannot get overlay");var t=this._map.getBounds();if(!t)return null;var r=t.getNorthEast(),o=t.getSouthWest(),n=new this._lib.LatLngBounds(o,r),i=this._map.getDiv(),a=e.clientX-i.getBoundingClientRect().left,l=e.clientY-i.getBoundingClientRect().top,s=new this._lib.Point(a,l),c=this._overlay.getProjection();if(!c)return null;var d=c.fromContainerPixelToLatLng(s);return d&&n.contains(d)?{lng:d.lng(),lat:d.lat()}:null},s.getMapEventElement=function(){return this._map.getDiv().querySelector('div[style*="z-index: 3;"]')},s.project=function(e,t){if(!this._overlay)throw new Error("cannot get overlay");if(void 0===this._map.getBounds())throw new Error("cannot get bounds");var r=this._overlay.getProjection();if(void 0===r)throw new Error("cannot get projection");var o=r.fromLatLngToContainerPixel(new this._lib.LatLng(t,e));if(null===o)throw new Error("cannot project coordinates");return{x:o.x,y:o.y}},s.unproject=function(e,t){if(!this._overlay)throw new Error("cannot get overlay");var r=this._overlay.getProjection();if(void 0===r)throw new Error("cannot get projection");var o=r.fromContainerPixelToLatLng(new this._lib.Point(e,t));if(null===o)throw new Error("cannot unproject coordinates");return{lng:o.lng(),lat:o.lat()}},s.setCursor=function(e){if(e!==this._cursor){if(this._cursorStyleSheet&&(this._cursorStyleSheet.remove(),this._cursorStyleSheet=void 0),"unset"!==e){var t=this._map.getDiv(),r=document.querySelector("#"+t.id+" .gm-style > div");if(r){r.classList.add("terra-draw-google-maps");var o=document.createElement("style");o.innerHTML=".terra-draw-google-maps { cursor: "+e+" !important; }",document.getElementsByTagName("head")[0].appendChild(o),this._cursorStyleSheet=o}}this._cursor=e}},s.setDoubleClickToZoom=function(e){this._map.setOptions(e?{disableDoubleClickZoom:!1}:{disableDoubleClickZoom:!0})},s.setDraggability=function(e){this._map.setOptions({draggable:e})},s.render=function(e,t){var r=this;this._layers&&(e.deletedIds.forEach(function(e){var t=r._map.data.getFeatureById(e);t&&(r._map.data.remove(t),r.renderedFeatureIds.delete(e))}),e.updated.forEach(function(e){if(!e||!e.id)throw new Error("Feature is not valid");var t=r._map.data.getFeatureById(e.id);if(!t)throw new Error("Feature could not be found by Google Maps API");switch(t.forEachProperty(function(e,r){t.setProperty(r,void 0)}),Object.keys(e.properties).forEach(function(r){t.setProperty(r,e.properties[r])}),e.geometry.type){case"Point":var o=e.geometry.coordinates;t.setGeometry(new r._lib.Data.Point(new r._lib.LatLng(o[1],o[0])));break;case"LineString":for(var n=e.geometry.coordinates,i=[],a=0;a<n.length;a++){var l=n[a],s=new r._lib.LatLng(l[1],l[0]);i.push(s)}t.setGeometry(new r._lib.Data.LineString(i));break;case"Polygon":for(var c=e.geometry.coordinates,d=[],u=0;u<c.length;u++){for(var h=[],p=0;p<c[u].length;p++){var v=new r._lib.LatLng(c[u][p][1],c[u][p][0]);h.push(v)}d.push(h)}t.setGeometry(new r._lib.Data.Polygon(d))}}),e.created.forEach(function(e){r.renderedFeatureIds.add(e.id),r._map.data.addGeoJson(e)})),e.created.forEach(function(e){r.renderedFeatureIds.add(e.id)});var o={type:"FeatureCollection",features:[].concat(e.created)};this._map.data.addGeoJson(o),this._map.data.setStyle(function(e){var o=e.getProperty("mode"),n=e.getGeometry();if(!n)throw new Error("Google Maps geometry not found");var i=n.getType(),a={},l=e.getId();e.forEachProperty(function(e,t){a[t]=e});var s=t[o]({type:"Feature",id:l,geometry:{type:i,coordinates:[]},properties:a});switch(i){case"Point":return{clickable:!1,icon:{path:r.circlePath(0,0,s.pointWidth),fillColor:s.pointColor,fillOpacity:1,strokeColor:s.pointOutlineColor,strokeWeight:s.pointOutlineWidth,rotation:0,scale:1},zIndex:s.zIndex};case"LineString":return{strokeColor:s.lineStringColor,strokeWeight:s.lineStringWidth,zIndex:s.zIndex};case"Polygon":return{strokeColor:s.polygonOutlineColor,strokeWeight:s.polygonOutlineWidth,fillOpacity:s.polygonFillOpacity,fillColor:s.polygonFillColor,zIndex:s.zIndex}}throw Error("Unknown feature type")})},s.clearLayers=function(){var e=this;this._layers&&(this._map.data.forEach(function(t){var r=t.getId();e.renderedFeatureIds.has(r)&&e._map.data.remove(t)}),this.renderedFeatureIds=new Set)},s.clear=function(){this._currentModeCallbacks&&(this._currentModeCallbacks.onClear(),this.clearLayers())},s.getCoordinatePrecision=function(){return e.prototype.getCoordinatePrecision.call(this)},a=o,(l=[{key:"_layers",get:function(){var e;return Boolean((null==(e=this.renderedFeatureIds)?void 0:e.size)>0)}}])&&function(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,r(n.key),n)}}(a.prototype,l),Object.defineProperty(a,"prototype",{writable:!1}),a}(e.TerraDrawBaseAdapter);export{o as TerraDrawGoogleMapsAdapter};
2
2
  //# sourceMappingURL=terra-draw-google-maps-adapter.module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"terra-draw-google-maps-adapter.module.js","sources":["../src/terra-draw-google-maps-adapter.ts"],"sourcesContent":["/**\n * @module terra-draw-google-maps-adapter\n */\nimport {\n\tTerraDrawChanges,\n\tSetCursor,\n\tTerraDrawStylingFunction,\n\tTerraDrawExtend,\n} from \"terra-draw\";\nimport { GeoJsonObject } from \"geojson\";\n\nexport class TerraDrawGoogleMapsAdapter extends TerraDrawExtend.TerraDrawBaseAdapter {\n\tconstructor(\n\t\tconfig: {\n\t\t\tlib: typeof google.maps;\n\t\t\tmap: google.maps.Map;\n\t\t} & TerraDrawExtend.BaseAdapterConfig,\n\t) {\n\t\tsuper(config);\n\t\tthis._lib = config.lib;\n\t\tthis._map = config.map;\n\n\t\t// In order for the internals of the adapter to work we require an ID to\n\t\t// allow query selectors to work\n\t\tif (!this._map.getDiv().id) {\n\t\t\tthrow new Error(\"Google Map container div requires and id to be set\");\n\t\t}\n\n\t\tthis._coordinatePrecision =\n\t\t\ttypeof config.coordinatePrecision === \"number\"\n\t\t\t\t? config.coordinatePrecision\n\t\t\t\t: 9;\n\t}\n\n\tprivate _cursor: string | undefined;\n\tprivate _cursorStyleSheet: HTMLStyleElement | undefined;\n\tprivate _lib: typeof google.maps;\n\tprivate _map: google.maps.Map;\n\tprivate _overlay: google.maps.OverlayView | undefined;\n\tprivate _clickEventListener: google.maps.MapsEventListener | undefined;\n\tprivate _mouseMoveEventListener: google.maps.MapsEventListener | undefined;\n\tprivate _readyCalled = false;\n\n\tprivate get _layers(): boolean {\n\t\treturn Boolean(this.renderedFeatureIds?.size > 0);\n\t}\n\n\t/**\n\t * Generates an SVG path string for a circle with the given center coordinates and radius.\n\t * Based off this StackOverflow answer: https://stackoverflow.com/a/27905268/1363484\n\t * @param cx The x-coordinate of the circle's center.\n\t * @param cy The y-coordinate of the circle's center.\n\t * @param r The radius of the circle.\n\t * @returns The SVG path string representing the circle.\n\t */\n\tprivate circlePath(cx: number, cy: number, r: number) {\n\t\tconst d = r * 2;\n\t\treturn `M ${cx} ${cy} m -${r}, 0 a ${r},${r} 0 1,0 ${d},0 a ${r},${r} 0 1,0 -${d},0`;\n\t}\n\n\tpublic register(callbacks: TerraDrawExtend.TerraDrawCallbacks) {\n\t\tsuper.register(callbacks);\n\n\t\t// The overlay is responsible for allow us to\n\t\t// get the projection, which in turn allows us to\n\t\t// go through lng/lat to pixel space and vice versa\n\t\tthis._overlay = new this._lib.OverlayView();\n\t\tthis._overlay.draw = function () {\n\t\t\t// No-op\n\t\t};\n\n\t\t// Unfortunately it is only ready after the onAdd\n\t\t// method is called, which is why we need to use the 'ready'\n\t\t// listener with the Google Maps adapter\n\t\tthis._overlay.onAdd = () => {\n\t\t\tif (this._currentModeCallbacks?.onReady && !this._readyCalled) {\n\t\t\t\tthis._currentModeCallbacks.onReady();\n\t\t\t\tthis._readyCalled = true;\n\t\t\t}\n\t\t};\n\t\tthis._overlay.setMap(this._map);\n\n\t\t// Required to avoid runtime error in Google Maps API\n\t\tthis._overlay.onRemove = () => {\n\t\t\t// No-op\n\t\t};\n\n\t\t// Clicking on data geometries triggers\n\t\t// swallows the map onclick event,\n\t\t// so we need to forward it to the click callback handler\n\t\tthis._clickEventListener = this._map.data.addListener(\n\t\t\t\"click\",\n\t\t\t(\n\t\t\t\tevent: google.maps.MapMouseEvent & {\n\t\t\t\t\tdomEvent: MouseEvent;\n\t\t\t\t},\n\t\t\t) => {\n\t\t\t\tconst clickListener = this._listeners.find(\n\t\t\t\t\t({ name }) => name === \"click\",\n\t\t\t\t);\n\t\t\t\tif (clickListener) {\n\t\t\t\t\tclickListener.callback(event);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\n\t\tthis._mouseMoveEventListener = this._map.data.addListener(\n\t\t\t\"mousemove\",\n\t\t\t(\n\t\t\t\tevent: google.maps.MapMouseEvent & {\n\t\t\t\t\tdomEvent: MouseEvent;\n\t\t\t\t},\n\t\t\t) => {\n\t\t\t\tconst mouseMoveListener = this._listeners.find(\n\t\t\t\t\t({ name }) => name === \"mousemove\",\n\t\t\t\t);\n\t\t\t\tif (mouseMoveListener) {\n\t\t\t\t\tmouseMoveListener.callback(event);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t}\n\n\tpublic unregister(): void {\n\t\tsuper.unregister();\n\t\tthis._clickEventListener?.remove();\n\t\tthis._mouseMoveEventListener?.remove();\n\n\t\tif (this._overlay && this._overlay.getMap()) {\n\t\t\tthis._overlay.setMap(null);\n\t\t}\n\t\tthis._overlay = undefined;\n\t\tthis._readyCalled = false;\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\tgetLngLatFromEvent(event: PointerEvent | MouseEvent) {\n\t\tif (!this._overlay) {\n\t\t\tthrow new Error(\"cannot get overlay\");\n\t\t}\n\n\t\tconst bounds = this._map.getBounds();\n\n\t\tif (!bounds) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst ne = bounds.getNorthEast();\n\t\tconst sw = bounds.getSouthWest();\n\t\tconst latLngBounds = new this._lib.LatLngBounds(sw, ne);\n\n\t\tconst mapCanvas = this._map.getDiv();\n\t\tconst offsetX = event.clientX - mapCanvas.getBoundingClientRect().left;\n\t\tconst offsetY = event.clientY - mapCanvas.getBoundingClientRect().top;\n\t\tconst screenCoord = new this._lib.Point(offsetX, offsetY);\n\n\t\tconst projection = this._overlay.getProjection();\n\t\tif (!projection) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst latLng = projection.fromContainerPixelToLatLng(screenCoord);\n\n\t\tif (latLng && latLngBounds.contains(latLng)) {\n\t\t\treturn { lng: latLng.lng(), lat: latLng.lat() };\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * Retrieves the HTML element of the Google Map element that handles interaction events\n\t * @returns The HTMLElement representing the map container.\n\t */\n\tpublic getMapEventElement() {\n\t\t// TODO: This is a bit hacky, maybe there is a better solution here\n\t\tconst selector = 'div[style*=\"z-index: 3;\"]';\n\t\treturn this._map.getDiv().querySelector(selector) as HTMLDivElement;\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\tproject(lng: number, lat: number) {\n\t\tif (!this._overlay) {\n\t\t\tthrow new Error(\"cannot get overlay\");\n\t\t}\n\n\t\tconst bounds = this._map.getBounds();\n\n\t\tif (bounds === undefined) {\n\t\t\tthrow new Error(\"cannot get bounds\");\n\t\t}\n\n\t\tconst projection = this._overlay.getProjection();\n\t\tif (projection === undefined) {\n\t\t\tthrow new Error(\"cannot get projection\");\n\t\t}\n\n\t\tconst point = projection.fromLatLngToContainerPixel(\n\t\t\tnew this._lib.LatLng(lat, lng),\n\t\t);\n\n\t\tif (point === null) {\n\t\t\tthrow new Error(\"cannot project coordinates\");\n\t\t}\n\n\t\treturn { x: point.x, y: point.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\tunproject(x: number, y: number) {\n\t\tif (!this._overlay) {\n\t\t\tthrow new Error(\"cannot get overlay\");\n\t\t}\n\n\t\tconst projection = this._overlay.getProjection();\n\t\tif (projection === undefined) {\n\t\t\tthrow new Error(\"cannot get projection\");\n\t\t}\n\n\t\tconst latLng = projection.fromContainerPixelToLatLng(\n\t\t\tnew this._lib.Point(x, y),\n\t\t);\n\n\t\tif (latLng === null) {\n\t\t\tthrow new Error(\"cannot unproject coordinates\");\n\t\t}\n\n\t\treturn { lng: latLng.lng(), lat: latLng.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\tsetCursor(cursor: Parameters<SetCursor>[0]) {\n\t\tif (cursor === this._cursor) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this._cursorStyleSheet) {\n\t\t\tthis._cursorStyleSheet.remove();\n\t\t\tthis._cursorStyleSheet = undefined;\n\t\t}\n\n\t\tif (cursor !== \"unset\") {\n\t\t\t// TODO: We could cache these individually per cursor\n\n\t\t\tconst div = this._map.getDiv();\n\t\t\tconst styleDivSelector = `#${div.id} .gm-style > div`;\n\t\t\tconst styleDiv = document.querySelector(styleDivSelector);\n\n\t\t\tif (styleDiv) {\n\t\t\t\tstyleDiv.classList.add(\"terra-draw-google-maps\");\n\n\t\t\t\tconst style = document.createElement(\"style\");\n\t\t\t\tstyle.innerHTML = `.terra-draw-google-maps { cursor: ${cursor} !important; }`;\n\t\t\t\tdocument.getElementsByTagName(\"head\")[0].appendChild(style);\n\t\t\t\tthis._cursorStyleSheet = style;\n\t\t\t}\n\t\t}\n\n\t\tthis._cursor = cursor;\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\tsetDoubleClickToZoom(enabled: boolean) {\n\t\tif (enabled) {\n\t\t\tthis._map.setOptions({ disableDoubleClickZoom: false });\n\t\t} else {\n\t\t\tthis._map.setOptions({ disableDoubleClickZoom: true });\n\t\t}\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\tsetDraggability(enabled: boolean) {\n\t\tthis._map.setOptions({ draggable: enabled });\n\t}\n\n\tprivate renderedFeatureIds: Set<TerraDrawExtend.FeatureId> = new Set();\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\trender(changes: TerraDrawChanges, styling: TerraDrawStylingFunction) {\n\t\tif (this._layers) {\n\t\t\tchanges.deletedIds.forEach((deletedId) => {\n\t\t\t\tconst featureToDelete = this._map.data.getFeatureById(deletedId);\n\t\t\t\tif (featureToDelete) {\n\t\t\t\t\tthis._map.data.remove(featureToDelete);\n\t\t\t\t\tthis.renderedFeatureIds.delete(deletedId);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tchanges.updated.forEach((updatedFeature) => {\n\t\t\t\tif (!updatedFeature || !updatedFeature.id) {\n\t\t\t\t\tthrow new Error(\"Feature is not valid\");\n\t\t\t\t}\n\n\t\t\t\tconst featureToUpdate = this._map.data.getFeatureById(\n\t\t\t\t\tupdatedFeature.id,\n\t\t\t\t);\n\n\t\t\t\tif (!featureToUpdate) {\n\t\t\t\t\tthrow new Error(\"Feature could not be found by Google Maps API\");\n\t\t\t\t}\n\n\t\t\t\t// Remove all keys\n\t\t\t\tfeatureToUpdate.forEachProperty((property, name) => {\n\t\t\t\t\tfeatureToUpdate.setProperty(name, undefined);\n\t\t\t\t});\n\n\t\t\t\t// Update all keys\n\t\t\t\tObject.keys(updatedFeature.properties).forEach((property) => {\n\t\t\t\t\tfeatureToUpdate.setProperty(\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\tupdatedFeature.properties[property],\n\t\t\t\t\t);\n\t\t\t\t});\n\n\t\t\t\tswitch (updatedFeature.geometry.type) {\n\t\t\t\t\tcase \"Point\":\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconst coordinates = updatedFeature.geometry.coordinates;\n\n\t\t\t\t\t\t\tfeatureToUpdate.setGeometry(\n\t\t\t\t\t\t\t\tnew this._lib.Data.Point(\n\t\t\t\t\t\t\t\t\tnew this._lib.LatLng(coordinates[1], coordinates[0]),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"LineString\":\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconst coordinates = updatedFeature.geometry.coordinates;\n\n\t\t\t\t\t\t\tconst path: google.maps.LatLng[] = [];\n\t\t\t\t\t\t\tfor (let i = 0; i < coordinates.length; i++) {\n\t\t\t\t\t\t\t\tconst coordinate = coordinates[i];\n\t\t\t\t\t\t\t\tconst latLng = new this._lib.LatLng(\n\t\t\t\t\t\t\t\t\tcoordinate[1],\n\t\t\t\t\t\t\t\t\tcoordinate[0],\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tpath.push(latLng);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tfeatureToUpdate.setGeometry(new this._lib.Data.LineString(path));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Polygon\":\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconst coordinates = updatedFeature.geometry.coordinates;\n\n\t\t\t\t\t\t\tconst paths: google.maps.LatLng[][] = [];\n\t\t\t\t\t\t\tfor (let i = 0; i < coordinates.length; i++) {\n\t\t\t\t\t\t\t\tconst path: google.maps.LatLng[] = [];\n\t\t\t\t\t\t\t\tfor (let j = 0; j < coordinates[i].length; j++) {\n\t\t\t\t\t\t\t\t\tconst latLng = new this._lib.LatLng(\n\t\t\t\t\t\t\t\t\t\tcoordinates[i][j][1],\n\t\t\t\t\t\t\t\t\t\tcoordinates[i][j][0],\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tpath.push(latLng);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tpaths.push(path);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tfeatureToUpdate.setGeometry(new this._lib.Data.Polygon(paths));\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// Create new features\n\t\t\tchanges.created.forEach((createdFeature) => {\n\t\t\t\tthis.renderedFeatureIds.add(createdFeature.id as string);\n\t\t\t\tthis._map.data.addGeoJson(createdFeature);\n\t\t\t});\n\t\t}\n\n\t\tchanges.created.forEach((feature) => {\n\t\t\tthis.renderedFeatureIds.add(feature.id as string);\n\t\t});\n\n\t\tconst featureCollection = {\n\t\t\ttype: \"FeatureCollection\",\n\t\t\tfeatures: [...changes.created],\n\t\t} as GeoJsonObject;\n\n\t\tthis._map.data.addGeoJson(featureCollection);\n\n\t\tthis._map.data.setStyle((feature) => {\n\t\t\tconst mode = feature.getProperty(\"mode\");\n\t\t\tconst gmGeometry = feature.getGeometry();\n\t\t\tif (!gmGeometry) {\n\t\t\t\tthrow new Error(\"Google Maps geometry not found\");\n\t\t\t}\n\t\t\tconst type = gmGeometry.getType();\n\t\t\tconst properties: Record<string, any> = {};\n\n\t\t\tfeature.forEachProperty((value, property) => {\n\t\t\t\tproperties[property] = value;\n\t\t\t});\n\n\t\t\tconst calculatedStyles = styling[mode]({\n\t\t\t\ttype: \"Feature\",\n\t\t\t\tgeometry: {\n\t\t\t\t\ttype: type as \"Point\" | \"LineString\" | \"Polygon\",\n\t\t\t\t\tcoordinates: [],\n\t\t\t\t},\n\t\t\t\tproperties,\n\t\t\t});\n\n\t\t\tswitch (type) {\n\t\t\t\tcase \"Point\":\n\t\t\t\t\tconst path = this.circlePath(0, 0, calculatedStyles.pointWidth);\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tclickable: false,\n\t\t\t\t\t\ticon: {\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\tfillColor: calculatedStyles.pointColor,\n\t\t\t\t\t\t\tfillOpacity: 1,\n\t\t\t\t\t\t\tstrokeColor: calculatedStyles.pointOutlineColor,\n\t\t\t\t\t\t\tstrokeWeight: calculatedStyles.pointOutlineWidth,\n\t\t\t\t\t\t\trotation: 0,\n\t\t\t\t\t\t\tscale: 1,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tzIndex: calculatedStyles.zIndex,\n\t\t\t\t\t};\n\n\t\t\t\tcase \"LineString\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstrokeColor: calculatedStyles.lineStringColor,\n\t\t\t\t\t\tstrokeWeight: calculatedStyles.lineStringWidth,\n\t\t\t\t\t\tzIndex: calculatedStyles.zIndex,\n\t\t\t\t\t};\n\t\t\t\tcase \"Polygon\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstrokeColor: calculatedStyles.polygonOutlineColor,\n\t\t\t\t\t\tstrokeWeight: calculatedStyles.polygonOutlineWidth,\n\t\t\t\t\t\tfillOpacity: calculatedStyles.polygonFillOpacity,\n\t\t\t\t\t\tfillColor: calculatedStyles.polygonFillColor,\n\t\t\t\t\t\tzIndex: calculatedStyles.zIndex,\n\t\t\t\t\t};\n\t\t\t}\n\n\t\t\tthrow Error(\"Unknown feature type\");\n\t\t});\n\t}\n\n\tprivate clearLayers() {\n\t\tif (this._layers) {\n\t\t\tthis._map.data.forEach((feature) => {\n\t\t\t\tconst id = feature.getId() as string;\n\t\t\t\tconst hasFeature = this.renderedFeatureIds.has(id);\n\t\t\t\tif (hasFeature) {\n\t\t\t\t\tthis._map.data.remove(feature);\n\t\t\t\t}\n\t\t\t});\n\t\t\tthis.renderedFeatureIds = new Set();\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\tpublic getCoordinatePrecision(): number {\n\t\t// TODO: It seems this shouldn't be necessary as extends BaseAdapter which as this method\n\t\treturn super.getCoordinatePrecision();\n\t}\n}\n"],"names":["TerraDrawGoogleMapsAdapter","_TerraDrawExtend$Terr","config","_this","call","this","_cursor","_cursorStyleSheet","_lib","_map","_overlay","_clickEventListener","_mouseMoveEventListener","_readyCalled","renderedFeatureIds","Set","lib","map","getDiv","id","Error","_coordinatePrecision","coordinatePrecision","_proto","prototype","circlePath","cx","cy","r","d","register","callbacks","_this2","OverlayView","draw","onAdd","_this2$_currentModeCa","_currentModeCallbacks","onReady","setMap","onRemove","data","addListener","event","clickListener","_listeners","find","_ref","name","callback","mouseMoveListener","_ref2","unregister","_this$_clickEventList","_this$_mouseMoveEvent","remove","getMap","undefined","getLngLatFromEvent","bounds","getBounds","ne","getNorthEast","sw","getSouthWest","latLngBounds","LatLngBounds","mapCanvas","offsetX","clientX","getBoundingClientRect","left","offsetY","clientY","top","screenCoord","Point","projection","getProjection","latLng","fromContainerPixelToLatLng","contains","lng","lat","getMapEventElement","querySelector","project","point","fromLatLngToContainerPixel","LatLng","x","y","unproject","setCursor","cursor","div","styleDiv","document","classList","add","style","createElement","innerHTML","getElementsByTagName","appendChild","setDoubleClickToZoom","enabled","setOptions","disableDoubleClickZoom","setDraggability","draggable","render","changes","styling","_this3","_layers","deletedIds","forEach","deletedId","featureToDelete","getFeatureById","updated","updatedFeature","featureToUpdate","forEachProperty","property","setProperty","Object","keys","properties","geometry","type","coordinates","setGeometry","Data","path","i","length","coordinate","push","LineString","paths","j","Polygon","created","createdFeature","addGeoJson","feature","featureCollection","features","concat","setStyle","mode","getProperty","gmGeometry","getGeometry","getType","value","calculatedStyles","clickable","icon","pointWidth","fillColor","pointColor","fillOpacity","strokeColor","pointOutlineColor","strokeWeight","pointOutlineWidth","rotation","scale","zIndex","lineStringColor","lineStringWidth","polygonOutlineColor","polygonOutlineWidth","polygonFillOpacity","polygonFillColor","clearLayers","_this4","getId","has","clear","onClear","getCoordinatePrecision","key","get","_this$renderedFeature","Boolean","size","TerraDrawExtend","TerraDrawBaseAdapter"],"mappings":"qcAWa,IAAAA,eAA2B,SAAAC,GACvC,SAAAD,EACCE,GAGqCC,IAAA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-google-maps-adapter.module.js","sources":["../src/terra-draw-google-maps-adapter.ts"],"sourcesContent":["/**\n * @module terra-draw-google-maps-adapter\n */\nimport {\n\tTerraDrawChanges,\n\tSetCursor,\n\tTerraDrawStylingFunction,\n\tTerraDrawExtend,\n} from \"terra-draw\";\nimport { GeoJsonObject } from \"geojson\";\n\nexport class TerraDrawGoogleMapsAdapter extends TerraDrawExtend.TerraDrawBaseAdapter {\n\tconstructor(\n\t\tconfig: {\n\t\t\tlib: typeof google.maps;\n\t\t\tmap: google.maps.Map;\n\t\t} & TerraDrawExtend.BaseAdapterConfig,\n\t) {\n\t\tsuper(config);\n\t\tthis._lib = config.lib;\n\t\tthis._map = config.map;\n\n\t\t// In order for the internals of the adapter to work we require an ID to\n\t\t// allow query selectors to work\n\t\tif (!this._map.getDiv().id) {\n\t\t\tthrow new Error(\"Google Map container div requires and id to be set\");\n\t\t}\n\n\t\tthis._coordinatePrecision =\n\t\t\ttypeof config.coordinatePrecision === \"number\"\n\t\t\t\t? config.coordinatePrecision\n\t\t\t\t: 9;\n\t}\n\n\tprivate _cursor: string | undefined;\n\tprivate _cursorStyleSheet: HTMLStyleElement | undefined;\n\tprivate _lib: typeof google.maps;\n\tprivate _map: google.maps.Map;\n\tprivate _overlay: google.maps.OverlayView | undefined;\n\tprivate _clickEventListener: google.maps.MapsEventListener | undefined;\n\tprivate _mouseMoveEventListener: google.maps.MapsEventListener | undefined;\n\tprivate _readyCalled = false;\n\n\tprivate get _layers(): boolean {\n\t\treturn Boolean(this.renderedFeatureIds?.size > 0);\n\t}\n\n\t/**\n\t * Generates an SVG path string for a circle with the given center coordinates and radius.\n\t * Based off this StackOverflow answer: https://stackoverflow.com/a/27905268/1363484\n\t * @param cx The x-coordinate of the circle's center.\n\t * @param cy The y-coordinate of the circle's center.\n\t * @param r The radius of the circle.\n\t * @returns The SVG path string representing the circle.\n\t */\n\tprivate circlePath(cx: number, cy: number, r: number) {\n\t\tconst d = r * 2;\n\t\treturn `M ${cx} ${cy} m -${r}, 0 a ${r},${r} 0 1,0 ${d},0 a ${r},${r} 0 1,0 -${d},0`;\n\t}\n\n\tpublic register(callbacks: TerraDrawExtend.TerraDrawCallbacks) {\n\t\tsuper.register(callbacks);\n\n\t\t// The overlay is responsible for allow us to\n\t\t// get the projection, which in turn allows us to\n\t\t// go through lng/lat to pixel space and vice versa\n\t\tthis._overlay = new this._lib.OverlayView();\n\t\tthis._overlay.draw = function () {\n\t\t\t// No-op\n\t\t};\n\n\t\t// Unfortunately it is only ready after the onAdd\n\t\t// method is called, which is why we need to use the 'ready'\n\t\t// listener with the Google Maps adapter\n\t\tthis._overlay.onAdd = () => {\n\t\t\tif (this._currentModeCallbacks?.onReady && !this._readyCalled) {\n\t\t\t\tthis._currentModeCallbacks.onReady();\n\t\t\t\tthis._readyCalled = true;\n\t\t\t}\n\t\t};\n\t\tthis._overlay.setMap(this._map);\n\n\t\t// Required to avoid runtime error in Google Maps API\n\t\tthis._overlay.onRemove = () => {\n\t\t\t// No-op\n\t\t};\n\n\t\t// Clicking on data geometries triggers\n\t\t// swallows the map onclick event,\n\t\t// so we need to forward it to the click callback handler\n\t\tthis._clickEventListener = this._map.data.addListener(\n\t\t\t\"click\",\n\t\t\t(\n\t\t\t\tevent: google.maps.MapMouseEvent & {\n\t\t\t\t\tdomEvent: MouseEvent;\n\t\t\t\t},\n\t\t\t) => {\n\t\t\t\tconst clickListener = this._listeners.find(\n\t\t\t\t\t({ name }) => name === \"click\",\n\t\t\t\t);\n\t\t\t\tif (clickListener) {\n\t\t\t\t\tclickListener.callback(event);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\n\t\tthis._mouseMoveEventListener = this._map.data.addListener(\n\t\t\t\"mousemove\",\n\t\t\t(\n\t\t\t\tevent: google.maps.MapMouseEvent & {\n\t\t\t\t\tdomEvent: MouseEvent;\n\t\t\t\t},\n\t\t\t) => {\n\t\t\t\tconst mouseMoveListener = this._listeners.find(\n\t\t\t\t\t({ name }) => name === \"mousemove\",\n\t\t\t\t);\n\t\t\t\tif (mouseMoveListener) {\n\t\t\t\t\tmouseMoveListener.callback(event);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t}\n\n\tpublic unregister(): void {\n\t\tsuper.unregister();\n\t\tthis._clickEventListener?.remove();\n\t\tthis._mouseMoveEventListener?.remove();\n\n\t\tif (this._overlay && this._overlay.getMap()) {\n\t\t\tthis._overlay.setMap(null);\n\t\t}\n\t\tthis._overlay = undefined;\n\t\tthis._readyCalled = false;\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\tgetLngLatFromEvent(event: PointerEvent | MouseEvent) {\n\t\tif (!this._overlay) {\n\t\t\tthrow new Error(\"cannot get overlay\");\n\t\t}\n\n\t\tconst bounds = this._map.getBounds();\n\n\t\tif (!bounds) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst ne = bounds.getNorthEast();\n\t\tconst sw = bounds.getSouthWest();\n\t\tconst latLngBounds = new this._lib.LatLngBounds(sw, ne);\n\n\t\tconst mapCanvas = this._map.getDiv();\n\t\tconst offsetX = event.clientX - mapCanvas.getBoundingClientRect().left;\n\t\tconst offsetY = event.clientY - mapCanvas.getBoundingClientRect().top;\n\t\tconst screenCoord = new this._lib.Point(offsetX, offsetY);\n\n\t\tconst projection = this._overlay.getProjection();\n\t\tif (!projection) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst latLng = projection.fromContainerPixelToLatLng(screenCoord);\n\n\t\tif (latLng && latLngBounds.contains(latLng)) {\n\t\t\treturn { lng: latLng.lng(), lat: latLng.lat() };\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * Retrieves the HTML element of the Google Map element that handles interaction events\n\t * @returns The HTMLElement representing the map container.\n\t */\n\tpublic getMapEventElement() {\n\t\t// TODO: This is a bit hacky, maybe there is a better solution here\n\t\tconst selector = 'div[style*=\"z-index: 3;\"]';\n\t\treturn this._map.getDiv().querySelector(selector) as HTMLDivElement;\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\tproject(lng: number, lat: number) {\n\t\tif (!this._overlay) {\n\t\t\tthrow new Error(\"cannot get overlay\");\n\t\t}\n\n\t\tconst bounds = this._map.getBounds();\n\n\t\tif (bounds === undefined) {\n\t\t\tthrow new Error(\"cannot get bounds\");\n\t\t}\n\n\t\tconst projection = this._overlay.getProjection();\n\t\tif (projection === undefined) {\n\t\t\tthrow new Error(\"cannot get projection\");\n\t\t}\n\n\t\tconst point = projection.fromLatLngToContainerPixel(\n\t\t\tnew this._lib.LatLng(lat, lng),\n\t\t);\n\n\t\tif (point === null) {\n\t\t\tthrow new Error(\"cannot project coordinates\");\n\t\t}\n\n\t\treturn { x: point.x, y: point.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\tunproject(x: number, y: number) {\n\t\tif (!this._overlay) {\n\t\t\tthrow new Error(\"cannot get overlay\");\n\t\t}\n\n\t\tconst projection = this._overlay.getProjection();\n\t\tif (projection === undefined) {\n\t\t\tthrow new Error(\"cannot get projection\");\n\t\t}\n\n\t\tconst latLng = projection.fromContainerPixelToLatLng(\n\t\t\tnew this._lib.Point(x, y),\n\t\t);\n\n\t\tif (latLng === null) {\n\t\t\tthrow new Error(\"cannot unproject coordinates\");\n\t\t}\n\n\t\treturn { lng: latLng.lng(), lat: latLng.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\tsetCursor(cursor: Parameters<SetCursor>[0]) {\n\t\tif (cursor === this._cursor) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this._cursorStyleSheet) {\n\t\t\tthis._cursorStyleSheet.remove();\n\t\t\tthis._cursorStyleSheet = undefined;\n\t\t}\n\n\t\tif (cursor !== \"unset\") {\n\t\t\t// TODO: We could cache these individually per cursor\n\n\t\t\tconst div = this._map.getDiv();\n\t\t\tconst styleDivSelector = `#${div.id} .gm-style > div`;\n\t\t\tconst styleDiv = document.querySelector(styleDivSelector);\n\n\t\t\tif (styleDiv) {\n\t\t\t\tstyleDiv.classList.add(\"terra-draw-google-maps\");\n\n\t\t\t\tconst style = document.createElement(\"style\");\n\t\t\t\tstyle.innerHTML = `.terra-draw-google-maps { cursor: ${cursor} !important; }`;\n\t\t\t\tdocument.getElementsByTagName(\"head\")[0].appendChild(style);\n\t\t\t\tthis._cursorStyleSheet = style;\n\t\t\t}\n\t\t}\n\n\t\tthis._cursor = cursor;\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\tsetDoubleClickToZoom(enabled: boolean) {\n\t\tif (enabled) {\n\t\t\tthis._map.setOptions({ disableDoubleClickZoom: false });\n\t\t} else {\n\t\t\tthis._map.setOptions({ disableDoubleClickZoom: true });\n\t\t}\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\tsetDraggability(enabled: boolean) {\n\t\tthis._map.setOptions({ draggable: enabled });\n\t}\n\n\tprivate renderedFeatureIds: Set<TerraDrawExtend.FeatureId> = new Set();\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\trender(changes: TerraDrawChanges, styling: TerraDrawStylingFunction) {\n\t\tif (this._layers) {\n\t\t\tchanges.deletedIds.forEach((deletedId) => {\n\t\t\t\tconst featureToDelete = this._map.data.getFeatureById(deletedId);\n\t\t\t\tif (featureToDelete) {\n\t\t\t\t\tthis._map.data.remove(featureToDelete);\n\t\t\t\t\tthis.renderedFeatureIds.delete(deletedId);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tchanges.updated.forEach((updatedFeature) => {\n\t\t\t\tif (!updatedFeature || !updatedFeature.id) {\n\t\t\t\t\tthrow new Error(\"Feature is not valid\");\n\t\t\t\t}\n\n\t\t\t\tconst featureToUpdate = this._map.data.getFeatureById(\n\t\t\t\t\tupdatedFeature.id,\n\t\t\t\t);\n\n\t\t\t\tif (!featureToUpdate) {\n\t\t\t\t\tthrow new Error(\"Feature could not be found by Google Maps API\");\n\t\t\t\t}\n\n\t\t\t\t// Remove all keys\n\t\t\t\tfeatureToUpdate.forEachProperty((property, name) => {\n\t\t\t\t\tfeatureToUpdate.setProperty(name, undefined);\n\t\t\t\t});\n\n\t\t\t\t// Update all keys\n\t\t\t\tObject.keys(updatedFeature.properties).forEach((property) => {\n\t\t\t\t\tfeatureToUpdate.setProperty(\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\tupdatedFeature.properties[property],\n\t\t\t\t\t);\n\t\t\t\t});\n\n\t\t\t\tswitch (updatedFeature.geometry.type) {\n\t\t\t\t\tcase \"Point\":\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconst coordinates = updatedFeature.geometry.coordinates;\n\n\t\t\t\t\t\t\tfeatureToUpdate.setGeometry(\n\t\t\t\t\t\t\t\tnew this._lib.Data.Point(\n\t\t\t\t\t\t\t\t\tnew this._lib.LatLng(coordinates[1], coordinates[0]),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"LineString\":\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconst coordinates = updatedFeature.geometry.coordinates;\n\n\t\t\t\t\t\t\tconst path: google.maps.LatLng[] = [];\n\t\t\t\t\t\t\tfor (let i = 0; i < coordinates.length; i++) {\n\t\t\t\t\t\t\t\tconst coordinate = coordinates[i];\n\t\t\t\t\t\t\t\tconst latLng = new this._lib.LatLng(\n\t\t\t\t\t\t\t\t\tcoordinate[1],\n\t\t\t\t\t\t\t\t\tcoordinate[0],\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tpath.push(latLng);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tfeatureToUpdate.setGeometry(new this._lib.Data.LineString(path));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Polygon\":\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconst coordinates = updatedFeature.geometry.coordinates;\n\n\t\t\t\t\t\t\tconst paths: google.maps.LatLng[][] = [];\n\t\t\t\t\t\t\tfor (let i = 0; i < coordinates.length; i++) {\n\t\t\t\t\t\t\t\tconst path: google.maps.LatLng[] = [];\n\t\t\t\t\t\t\t\tfor (let j = 0; j < coordinates[i].length; j++) {\n\t\t\t\t\t\t\t\t\tconst latLng = new this._lib.LatLng(\n\t\t\t\t\t\t\t\t\t\tcoordinates[i][j][1],\n\t\t\t\t\t\t\t\t\t\tcoordinates[i][j][0],\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tpath.push(latLng);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tpaths.push(path);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tfeatureToUpdate.setGeometry(new this._lib.Data.Polygon(paths));\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// Create new features\n\t\t\tchanges.created.forEach((createdFeature) => {\n\t\t\t\tthis.renderedFeatureIds.add(createdFeature.id as string);\n\t\t\t\tthis._map.data.addGeoJson(createdFeature);\n\t\t\t});\n\t\t}\n\n\t\tchanges.created.forEach((feature) => {\n\t\t\tthis.renderedFeatureIds.add(feature.id as string);\n\t\t});\n\n\t\tconst featureCollection = {\n\t\t\ttype: \"FeatureCollection\",\n\t\t\tfeatures: [...changes.created],\n\t\t} as GeoJsonObject;\n\n\t\tthis._map.data.addGeoJson(featureCollection);\n\n\t\tthis._map.data.setStyle((feature) => {\n\t\t\tconst mode = feature.getProperty(\"mode\");\n\t\t\tconst gmGeometry = feature.getGeometry();\n\t\t\tif (!gmGeometry) {\n\t\t\t\tthrow new Error(\"Google Maps geometry not found\");\n\t\t\t}\n\t\t\tconst type = gmGeometry.getType();\n\t\t\tconst properties: Record<string, any> = {};\n\t\t\tconst id = feature.getId();\n\n\t\t\tfeature.forEachProperty((value, property) => {\n\t\t\t\tproperties[property] = value;\n\t\t\t});\n\n\t\t\tconst calculatedStyles = styling[mode]({\n\t\t\t\ttype: \"Feature\",\n\t\t\t\tid,\n\t\t\t\tgeometry: {\n\t\t\t\t\ttype: type as \"Point\" | \"LineString\" | \"Polygon\",\n\t\t\t\t\tcoordinates: [],\n\t\t\t\t},\n\t\t\t\tproperties,\n\t\t\t});\n\n\t\t\tswitch (type) {\n\t\t\t\tcase \"Point\":\n\t\t\t\t\tconst path = this.circlePath(0, 0, calculatedStyles.pointWidth);\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tclickable: false,\n\t\t\t\t\t\ticon: {\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\tfillColor: calculatedStyles.pointColor,\n\t\t\t\t\t\t\tfillOpacity: 1,\n\t\t\t\t\t\t\tstrokeColor: calculatedStyles.pointOutlineColor,\n\t\t\t\t\t\t\tstrokeWeight: calculatedStyles.pointOutlineWidth,\n\t\t\t\t\t\t\trotation: 0,\n\t\t\t\t\t\t\tscale: 1,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tzIndex: calculatedStyles.zIndex,\n\t\t\t\t\t};\n\n\t\t\t\tcase \"LineString\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstrokeColor: calculatedStyles.lineStringColor,\n\t\t\t\t\t\tstrokeWeight: calculatedStyles.lineStringWidth,\n\t\t\t\t\t\tzIndex: calculatedStyles.zIndex,\n\t\t\t\t\t};\n\t\t\t\tcase \"Polygon\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstrokeColor: calculatedStyles.polygonOutlineColor,\n\t\t\t\t\t\tstrokeWeight: calculatedStyles.polygonOutlineWidth,\n\t\t\t\t\t\tfillOpacity: calculatedStyles.polygonFillOpacity,\n\t\t\t\t\t\tfillColor: calculatedStyles.polygonFillColor,\n\t\t\t\t\t\tzIndex: calculatedStyles.zIndex,\n\t\t\t\t\t};\n\t\t\t}\n\n\t\t\tthrow Error(\"Unknown feature type\");\n\t\t});\n\t}\n\n\tprivate clearLayers() {\n\t\tif (this._layers) {\n\t\t\tthis._map.data.forEach((feature) => {\n\t\t\t\tconst id = feature.getId() as string;\n\t\t\t\tconst hasFeature = this.renderedFeatureIds.has(id);\n\t\t\t\tif (hasFeature) {\n\t\t\t\t\tthis._map.data.remove(feature);\n\t\t\t\t}\n\t\t\t});\n\t\t\tthis.renderedFeatureIds = new Set();\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\tpublic getCoordinatePrecision(): number {\n\t\t// TODO: It seems this shouldn't be necessary as extends BaseAdapter which as this method\n\t\treturn super.getCoordinatePrecision();\n\t}\n}\n"],"names":["TerraDrawGoogleMapsAdapter","_TerraDrawExtend$Terr","config","_this","call","this","_cursor","_cursorStyleSheet","_lib","_map","_overlay","_clickEventListener","_mouseMoveEventListener","_readyCalled","renderedFeatureIds","Set","lib","map","getDiv","id","Error","_coordinatePrecision","coordinatePrecision","_proto","prototype","circlePath","cx","cy","r","d","register","callbacks","_this2","OverlayView","draw","onAdd","_this2$_currentModeCa","_currentModeCallbacks","onReady","setMap","onRemove","data","addListener","event","clickListener","_listeners","find","_ref","name","callback","mouseMoveListener","_ref2","unregister","_this$_clickEventList","_this$_mouseMoveEvent","remove","getMap","undefined","getLngLatFromEvent","bounds","getBounds","ne","getNorthEast","sw","getSouthWest","latLngBounds","LatLngBounds","mapCanvas","offsetX","clientX","getBoundingClientRect","left","offsetY","clientY","top","screenCoord","Point","projection","getProjection","latLng","fromContainerPixelToLatLng","contains","lng","lat","getMapEventElement","querySelector","project","point","fromLatLngToContainerPixel","LatLng","x","y","unproject","setCursor","cursor","div","styleDiv","document","classList","add","style","createElement","innerHTML","getElementsByTagName","appendChild","setDoubleClickToZoom","enabled","setOptions","disableDoubleClickZoom","setDraggability","draggable","render","changes","styling","_this3","_layers","deletedIds","forEach","deletedId","featureToDelete","getFeatureById","updated","updatedFeature","featureToUpdate","forEachProperty","property","setProperty","Object","keys","properties","geometry","type","coordinates","setGeometry","Data","path","i","length","coordinate","push","LineString","paths","j","Polygon","created","createdFeature","addGeoJson","feature","featureCollection","features","concat","setStyle","mode","getProperty","gmGeometry","getGeometry","getType","getId","value","calculatedStyles","clickable","icon","pointWidth","fillColor","pointColor","fillOpacity","strokeColor","pointOutlineColor","strokeWeight","pointOutlineWidth","rotation","scale","zIndex","lineStringColor","lineStringWidth","polygonOutlineColor","polygonOutlineWidth","polygonFillOpacity","polygonFillColor","clearLayers","_this4","has","clear","onClear","getCoordinatePrecision","key","get","_this$renderedFeature","Boolean","size","TerraDrawExtend","TerraDrawBaseAdapter"],"mappings":"qcAWa,IAAAA,eAA2B,SAAAC,GACvC,SAAAD,EACCE,GAGqCC,IAAAA,EAQrC,IANAA,EAAAF,EAAAG,KAAMF,KAAAA,IAAOG,MAgBNC,aAAOH,EAAAA,EACPI,uBAAiBJ,EAAAA,EACjBK,UAAIL,EAAAA,EACJM,UAAIN,EAAAA,EACJO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,CACN6B,WAAW,EACXC,KAAM,CACL1B,KALWrB,EAAKzF,WAAW,EAAG,EAAGsI,EAAiBG,YAMlDC,UAAWJ,EAAiBK,WAC5BC,YAAa,EACbC,YAAaP,EAAiBQ,kBAC9BC,aAAcT,EAAiBU,kBAC/BC,SAAU,EACVC,MAAO,GAERC,OAAQb,EAAiBa,QAG3B,IAAK,aACJ,MAAO,CACNN,YAAaP,EAAiBc,gBAC9BL,aAAcT,EAAiBe,gBAC/BF,OAAQb,EAAiBa,QAE3B,IAAK,UACJ,MAAO,CACNN,YAAaP,EAAiBgB,oBAC9BP,aAAcT,EAAiBiB,oBAC/BX,YAAaN,EAAiBkB,mBAC9Bd,UAAWJ,EAAiBmB,iBAC5BN,OAAQb,EAAiBa,QAI5B,MAAMxJ,MAAM,uBACb,EACD,EAACG,EAEO4J,YAAA,WAAW,IAAAC,EAAA/K,KACdA,KAAK8G,UACR9G,KAAKI,KAAKgC,KAAK4E,QAAQ,SAAC8B,GACvB,IAAMhI,EAAKgI,EAAQU,QACAuB,EAAKtK,mBAAmBuK,IAAIlK,IAE9CiK,EAAK3K,KAAKgC,KAAKc,OAAO4F,EAExB,GACA9I,KAAKS,mBAAqB,IAAIC,IAEhC,EAACQ,EAMM+J,MAAA,WACFjL,KAAKgC,wBAERhC,KAAKgC,sBAAsBkJ,UAG3BlL,KAAK8K,cAEP,EAAC5J,EAEMiK,uBAAA,WAEN,OAAAvL,EAAAuB,UAAagK,uBAAsBpL,KACpCC,KAAA,IAACL,KAAA,CAAA,CAAAyL,IAAA,UAAAC,IA7cD,WAAmB,IAAAC,EAClB,OAAOC,SAAQD,OAAAA,EAAAtL,KAAKS,yBAAL6K,EAAAA,EAAyBE,MAAO,EAChD,iPAlC+CC,CAAR,CAAQA,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).terraDrawGoogleMapsAdapter={},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)}function o(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}e.TerraDrawGoogleMapsAdapter=/*#__PURE__*/function(e){function t(t){var r;if((r=e.call(this,t)||this)._cursor=void 0,r._cursorStyleSheet=void 0,r._lib=void 0,r._map=void 0,r._overlay=void 0,r._clickEventListener=void 0,r._mouseMoveEventListener=void 0,r._readyCalled=!1,r.renderedFeatureIds=new Set,r._lib=t.lib,r._map=t.map,!r._map.getDiv().id)throw new Error("Google Map container div requires and id to be set");return r._coordinatePrecision="number"==typeof t.coordinatePrecision?t.coordinatePrecision:9,r}var n,i;i=e,(n=t).prototype=Object.create(i.prototype),n.prototype.constructor=n,r(n,i);var a,l,s=t.prototype;return s.circlePath=function(e,t,r){var o=2*r;return"M "+e+" "+t+" m -"+r+", 0 a "+r+","+r+" 0 1,0 "+o+",0 a "+r+","+r+" 0 1,0 -"+o+",0"},s.register=function(t){var r=this;e.prototype.register.call(this,t),this._overlay=new this._lib.OverlayView,this._overlay.draw=function(){},this._overlay.onAdd=function(){var e;null!=(e=r._currentModeCallbacks)&&e.onReady&&!r._readyCalled&&(r._currentModeCallbacks.onReady(),r._readyCalled=!0)},this._overlay.setMap(this._map),this._overlay.onRemove=function(){},this._clickEventListener=this._map.data.addListener("click",function(e){var t=r._listeners.find(function(e){return"click"===e.name});t&&t.callback(e)}),this._mouseMoveEventListener=this._map.data.addListener("mousemove",function(e){var t=r._listeners.find(function(e){return"mousemove"===e.name});t&&t.callback(e)})},s.unregister=function(){var t,r;e.prototype.unregister.call(this),null==(t=this._clickEventListener)||t.remove(),null==(r=this._mouseMoveEventListener)||r.remove(),this._overlay&&this._overlay.getMap()&&this._overlay.setMap(null),this._overlay=void 0,this._readyCalled=!1},s.getLngLatFromEvent=function(e){if(!this._overlay)throw new Error("cannot get overlay");var t=this._map.getBounds();if(!t)return null;var r=t.getNorthEast(),o=t.getSouthWest(),n=new this._lib.LatLngBounds(o,r),i=this._map.getDiv(),a=e.clientX-i.getBoundingClientRect().left,l=e.clientY-i.getBoundingClientRect().top,s=new this._lib.Point(a,l),c=this._overlay.getProjection();if(!c)return null;var d=c.fromContainerPixelToLatLng(s);return d&&n.contains(d)?{lng:d.lng(),lat:d.lat()}:null},s.getMapEventElement=function(){return this._map.getDiv().querySelector('div[style*="z-index: 3;"]')},s.project=function(e,t){if(!this._overlay)throw new Error("cannot get overlay");if(void 0===this._map.getBounds())throw new Error("cannot get bounds");var r=this._overlay.getProjection();if(void 0===r)throw new Error("cannot get projection");var o=r.fromLatLngToContainerPixel(new this._lib.LatLng(t,e));if(null===o)throw new Error("cannot project coordinates");return{x:o.x,y:o.y}},s.unproject=function(e,t){if(!this._overlay)throw new Error("cannot get overlay");var r=this._overlay.getProjection();if(void 0===r)throw new Error("cannot get projection");var o=r.fromContainerPixelToLatLng(new this._lib.Point(e,t));if(null===o)throw new Error("cannot unproject coordinates");return{lng:o.lng(),lat:o.lat()}},s.setCursor=function(e){if(e!==this._cursor){if(this._cursorStyleSheet&&(this._cursorStyleSheet.remove(),this._cursorStyleSheet=void 0),"unset"!==e){var t=this._map.getDiv(),r=document.querySelector("#"+t.id+" .gm-style > div");if(r){r.classList.add("terra-draw-google-maps");var o=document.createElement("style");o.innerHTML=".terra-draw-google-maps { cursor: "+e+" !important; }",document.getElementsByTagName("head")[0].appendChild(o),this._cursorStyleSheet=o}}this._cursor=e}},s.setDoubleClickToZoom=function(e){this._map.setOptions(e?{disableDoubleClickZoom:!1}:{disableDoubleClickZoom:!0})},s.setDraggability=function(e){this._map.setOptions({draggable:e})},s.render=function(e,t){var r=this;this._layers&&(e.deletedIds.forEach(function(e){var t=r._map.data.getFeatureById(e);t&&(r._map.data.remove(t),r.renderedFeatureIds.delete(e))}),e.updated.forEach(function(e){if(!e||!e.id)throw new Error("Feature is not valid");var t=r._map.data.getFeatureById(e.id);if(!t)throw new Error("Feature could not be found by Google Maps API");switch(t.forEachProperty(function(e,r){t.setProperty(r,void 0)}),Object.keys(e.properties).forEach(function(r){t.setProperty(r,e.properties[r])}),e.geometry.type){case"Point":var o=e.geometry.coordinates;t.setGeometry(new r._lib.Data.Point(new r._lib.LatLng(o[1],o[0])));break;case"LineString":for(var n=e.geometry.coordinates,i=[],a=0;a<n.length;a++){var l=n[a],s=new r._lib.LatLng(l[1],l[0]);i.push(s)}t.setGeometry(new r._lib.Data.LineString(i));break;case"Polygon":for(var c=e.geometry.coordinates,d=[],u=0;u<c.length;u++){for(var p=[],h=0;h<c[u].length;h++){var y=new r._lib.LatLng(c[u][h][1],c[u][h][0]);p.push(y)}d.push(p)}t.setGeometry(new r._lib.Data.Polygon(d))}}),e.created.forEach(function(e){r.renderedFeatureIds.add(e.id),r._map.data.addGeoJson(e)})),e.created.forEach(function(e){r.renderedFeatureIds.add(e.id)});var o={type:"FeatureCollection",features:[].concat(e.created)};this._map.data.addGeoJson(o),this._map.data.setStyle(function(e){var o=e.getProperty("mode"),n=e.getGeometry();if(!n)throw new Error("Google Maps geometry not found");var i=n.getType(),a={};e.forEachProperty(function(e,t){a[t]=e});var l=t[o]({type:"Feature",geometry:{type:i,coordinates:[]},properties:a});switch(i){case"Point":return{clickable:!1,icon:{path:r.circlePath(0,0,l.pointWidth),fillColor:l.pointColor,fillOpacity:1,strokeColor:l.pointOutlineColor,strokeWeight:l.pointOutlineWidth,rotation:0,scale:1},zIndex:l.zIndex};case"LineString":return{strokeColor:l.lineStringColor,strokeWeight:l.lineStringWidth,zIndex:l.zIndex};case"Polygon":return{strokeColor:l.polygonOutlineColor,strokeWeight:l.polygonOutlineWidth,fillOpacity:l.polygonFillOpacity,fillColor:l.polygonFillColor,zIndex:l.zIndex}}throw Error("Unknown feature type")})},s.clearLayers=function(){var e=this;this._layers&&(this._map.data.forEach(function(t){var r=t.getId();e.renderedFeatureIds.has(r)&&e._map.data.remove(t)}),this.renderedFeatureIds=new Set)},s.clear=function(){this._currentModeCallbacks&&(this._currentModeCallbacks.onClear(),this.clearLayers())},s.getCoordinatePrecision=function(){return e.prototype.getCoordinatePrecision.call(this)},a=t,(l=[{key:"_layers",get:function(){var e;return Boolean((null==(e=this.renderedFeatureIds)?void 0:e.size)>0)}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,o(n.key),n)}}(a.prototype,l),Object.defineProperty(a,"prototype",{writable:!1}),a}(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).terraDrawGoogleMapsAdapter={},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)}function o(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}e.TerraDrawGoogleMapsAdapter=/*#__PURE__*/function(e){function t(t){var r;if((r=e.call(this,t)||this)._cursor=void 0,r._cursorStyleSheet=void 0,r._lib=void 0,r._map=void 0,r._overlay=void 0,r._clickEventListener=void 0,r._mouseMoveEventListener=void 0,r._readyCalled=!1,r.renderedFeatureIds=new Set,r._lib=t.lib,r._map=t.map,!r._map.getDiv().id)throw new Error("Google Map container div requires and id to be set");return r._coordinatePrecision="number"==typeof t.coordinatePrecision?t.coordinatePrecision:9,r}var n,i;i=e,(n=t).prototype=Object.create(i.prototype),n.prototype.constructor=n,r(n,i);var a,l,s=t.prototype;return s.circlePath=function(e,t,r){var o=2*r;return"M "+e+" "+t+" m -"+r+", 0 a "+r+","+r+" 0 1,0 "+o+",0 a "+r+","+r+" 0 1,0 -"+o+",0"},s.register=function(t){var r=this;e.prototype.register.call(this,t),this._overlay=new this._lib.OverlayView,this._overlay.draw=function(){},this._overlay.onAdd=function(){var e;null!=(e=r._currentModeCallbacks)&&e.onReady&&!r._readyCalled&&(r._currentModeCallbacks.onReady(),r._readyCalled=!0)},this._overlay.setMap(this._map),this._overlay.onRemove=function(){},this._clickEventListener=this._map.data.addListener("click",function(e){var t=r._listeners.find(function(e){return"click"===e.name});t&&t.callback(e)}),this._mouseMoveEventListener=this._map.data.addListener("mousemove",function(e){var t=r._listeners.find(function(e){return"mousemove"===e.name});t&&t.callback(e)})},s.unregister=function(){var t,r;e.prototype.unregister.call(this),null==(t=this._clickEventListener)||t.remove(),null==(r=this._mouseMoveEventListener)||r.remove(),this._overlay&&this._overlay.getMap()&&this._overlay.setMap(null),this._overlay=void 0,this._readyCalled=!1},s.getLngLatFromEvent=function(e){if(!this._overlay)throw new Error("cannot get overlay");var t=this._map.getBounds();if(!t)return null;var r=t.getNorthEast(),o=t.getSouthWest(),n=new this._lib.LatLngBounds(o,r),i=this._map.getDiv(),a=e.clientX-i.getBoundingClientRect().left,l=e.clientY-i.getBoundingClientRect().top,s=new this._lib.Point(a,l),c=this._overlay.getProjection();if(!c)return null;var d=c.fromContainerPixelToLatLng(s);return d&&n.contains(d)?{lng:d.lng(),lat:d.lat()}:null},s.getMapEventElement=function(){return this._map.getDiv().querySelector('div[style*="z-index: 3;"]')},s.project=function(e,t){if(!this._overlay)throw new Error("cannot get overlay");if(void 0===this._map.getBounds())throw new Error("cannot get bounds");var r=this._overlay.getProjection();if(void 0===r)throw new Error("cannot get projection");var o=r.fromLatLngToContainerPixel(new this._lib.LatLng(t,e));if(null===o)throw new Error("cannot project coordinates");return{x:o.x,y:o.y}},s.unproject=function(e,t){if(!this._overlay)throw new Error("cannot get overlay");var r=this._overlay.getProjection();if(void 0===r)throw new Error("cannot get projection");var o=r.fromContainerPixelToLatLng(new this._lib.Point(e,t));if(null===o)throw new Error("cannot unproject coordinates");return{lng:o.lng(),lat:o.lat()}},s.setCursor=function(e){if(e!==this._cursor){if(this._cursorStyleSheet&&(this._cursorStyleSheet.remove(),this._cursorStyleSheet=void 0),"unset"!==e){var t=this._map.getDiv(),r=document.querySelector("#"+t.id+" .gm-style > div");if(r){r.classList.add("terra-draw-google-maps");var o=document.createElement("style");o.innerHTML=".terra-draw-google-maps { cursor: "+e+" !important; }",document.getElementsByTagName("head")[0].appendChild(o),this._cursorStyleSheet=o}}this._cursor=e}},s.setDoubleClickToZoom=function(e){this._map.setOptions(e?{disableDoubleClickZoom:!1}:{disableDoubleClickZoom:!0})},s.setDraggability=function(e){this._map.setOptions({draggable:e})},s.render=function(e,t){var r=this;this._layers&&(e.deletedIds.forEach(function(e){var t=r._map.data.getFeatureById(e);t&&(r._map.data.remove(t),r.renderedFeatureIds.delete(e))}),e.updated.forEach(function(e){if(!e||!e.id)throw new Error("Feature is not valid");var t=r._map.data.getFeatureById(e.id);if(!t)throw new Error("Feature could not be found by Google Maps API");switch(t.forEachProperty(function(e,r){t.setProperty(r,void 0)}),Object.keys(e.properties).forEach(function(r){t.setProperty(r,e.properties[r])}),e.geometry.type){case"Point":var o=e.geometry.coordinates;t.setGeometry(new r._lib.Data.Point(new r._lib.LatLng(o[1],o[0])));break;case"LineString":for(var n=e.geometry.coordinates,i=[],a=0;a<n.length;a++){var l=n[a],s=new r._lib.LatLng(l[1],l[0]);i.push(s)}t.setGeometry(new r._lib.Data.LineString(i));break;case"Polygon":for(var c=e.geometry.coordinates,d=[],u=0;u<c.length;u++){for(var p=[],h=0;h<c[u].length;h++){var y=new r._lib.LatLng(c[u][h][1],c[u][h][0]);p.push(y)}d.push(p)}t.setGeometry(new r._lib.Data.Polygon(d))}}),e.created.forEach(function(e){r.renderedFeatureIds.add(e.id),r._map.data.addGeoJson(e)})),e.created.forEach(function(e){r.renderedFeatureIds.add(e.id)});var o={type:"FeatureCollection",features:[].concat(e.created)};this._map.data.addGeoJson(o),this._map.data.setStyle(function(e){var o=e.getProperty("mode"),n=e.getGeometry();if(!n)throw new Error("Google Maps geometry not found");var i=n.getType(),a={},l=e.getId();e.forEachProperty(function(e,t){a[t]=e});var s=t[o]({type:"Feature",id:l,geometry:{type:i,coordinates:[]},properties:a});switch(i){case"Point":return{clickable:!1,icon:{path:r.circlePath(0,0,s.pointWidth),fillColor:s.pointColor,fillOpacity:1,strokeColor:s.pointOutlineColor,strokeWeight:s.pointOutlineWidth,rotation:0,scale:1},zIndex:s.zIndex};case"LineString":return{strokeColor:s.lineStringColor,strokeWeight:s.lineStringWidth,zIndex:s.zIndex};case"Polygon":return{strokeColor:s.polygonOutlineColor,strokeWeight:s.polygonOutlineWidth,fillOpacity:s.polygonFillOpacity,fillColor:s.polygonFillColor,zIndex:s.zIndex}}throw Error("Unknown feature type")})},s.clearLayers=function(){var e=this;this._layers&&(this._map.data.forEach(function(t){var r=t.getId();e.renderedFeatureIds.has(r)&&e._map.data.remove(t)}),this.renderedFeatureIds=new Set)},s.clear=function(){this._currentModeCallbacks&&(this._currentModeCallbacks.onClear(),this.clearLayers())},s.getCoordinatePrecision=function(){return e.prototype.getCoordinatePrecision.call(this)},a=t,(l=[{key:"_layers",get:function(){var e;return Boolean((null==(e=this.renderedFeatureIds)?void 0:e.size)>0)}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,o(n.key),n)}}(a.prototype,l),Object.defineProperty(a,"prototype",{writable:!1}),a}(t.TerraDrawExtend.TerraDrawBaseAdapter)});
2
2
  //# sourceMappingURL=terra-draw-google-maps-adapter.umd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"terra-draw-google-maps-adapter.umd.js","sources":["../src/terra-draw-google-maps-adapter.ts"],"sourcesContent":["/**\n * @module terra-draw-google-maps-adapter\n */\nimport {\n\tTerraDrawChanges,\n\tSetCursor,\n\tTerraDrawStylingFunction,\n\tTerraDrawExtend,\n} from \"terra-draw\";\nimport { GeoJsonObject } from \"geojson\";\n\nexport class TerraDrawGoogleMapsAdapter extends TerraDrawExtend.TerraDrawBaseAdapter {\n\tconstructor(\n\t\tconfig: {\n\t\t\tlib: typeof google.maps;\n\t\t\tmap: google.maps.Map;\n\t\t} & TerraDrawExtend.BaseAdapterConfig,\n\t) {\n\t\tsuper(config);\n\t\tthis._lib = config.lib;\n\t\tthis._map = config.map;\n\n\t\t// In order for the internals of the adapter to work we require an ID to\n\t\t// allow query selectors to work\n\t\tif (!this._map.getDiv().id) {\n\t\t\tthrow new Error(\"Google Map container div requires and id to be set\");\n\t\t}\n\n\t\tthis._coordinatePrecision =\n\t\t\ttypeof config.coordinatePrecision === \"number\"\n\t\t\t\t? config.coordinatePrecision\n\t\t\t\t: 9;\n\t}\n\n\tprivate _cursor: string | undefined;\n\tprivate _cursorStyleSheet: HTMLStyleElement | undefined;\n\tprivate _lib: typeof google.maps;\n\tprivate _map: google.maps.Map;\n\tprivate _overlay: google.maps.OverlayView | undefined;\n\tprivate _clickEventListener: google.maps.MapsEventListener | undefined;\n\tprivate _mouseMoveEventListener: google.maps.MapsEventListener | undefined;\n\tprivate _readyCalled = false;\n\n\tprivate get _layers(): boolean {\n\t\treturn Boolean(this.renderedFeatureIds?.size > 0);\n\t}\n\n\t/**\n\t * Generates an SVG path string for a circle with the given center coordinates and radius.\n\t * Based off this StackOverflow answer: https://stackoverflow.com/a/27905268/1363484\n\t * @param cx The x-coordinate of the circle's center.\n\t * @param cy The y-coordinate of the circle's center.\n\t * @param r The radius of the circle.\n\t * @returns The SVG path string representing the circle.\n\t */\n\tprivate circlePath(cx: number, cy: number, r: number) {\n\t\tconst d = r * 2;\n\t\treturn `M ${cx} ${cy} m -${r}, 0 a ${r},${r} 0 1,0 ${d},0 a ${r},${r} 0 1,0 -${d},0`;\n\t}\n\n\tpublic register(callbacks: TerraDrawExtend.TerraDrawCallbacks) {\n\t\tsuper.register(callbacks);\n\n\t\t// The overlay is responsible for allow us to\n\t\t// get the projection, which in turn allows us to\n\t\t// go through lng/lat to pixel space and vice versa\n\t\tthis._overlay = new this._lib.OverlayView();\n\t\tthis._overlay.draw = function () {\n\t\t\t// No-op\n\t\t};\n\n\t\t// Unfortunately it is only ready after the onAdd\n\t\t// method is called, which is why we need to use the 'ready'\n\t\t// listener with the Google Maps adapter\n\t\tthis._overlay.onAdd = () => {\n\t\t\tif (this._currentModeCallbacks?.onReady && !this._readyCalled) {\n\t\t\t\tthis._currentModeCallbacks.onReady();\n\t\t\t\tthis._readyCalled = true;\n\t\t\t}\n\t\t};\n\t\tthis._overlay.setMap(this._map);\n\n\t\t// Required to avoid runtime error in Google Maps API\n\t\tthis._overlay.onRemove = () => {\n\t\t\t// No-op\n\t\t};\n\n\t\t// Clicking on data geometries triggers\n\t\t// swallows the map onclick event,\n\t\t// so we need to forward it to the click callback handler\n\t\tthis._clickEventListener = this._map.data.addListener(\n\t\t\t\"click\",\n\t\t\t(\n\t\t\t\tevent: google.maps.MapMouseEvent & {\n\t\t\t\t\tdomEvent: MouseEvent;\n\t\t\t\t},\n\t\t\t) => {\n\t\t\t\tconst clickListener = this._listeners.find(\n\t\t\t\t\t({ name }) => name === \"click\",\n\t\t\t\t);\n\t\t\t\tif (clickListener) {\n\t\t\t\t\tclickListener.callback(event);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\n\t\tthis._mouseMoveEventListener = this._map.data.addListener(\n\t\t\t\"mousemove\",\n\t\t\t(\n\t\t\t\tevent: google.maps.MapMouseEvent & {\n\t\t\t\t\tdomEvent: MouseEvent;\n\t\t\t\t},\n\t\t\t) => {\n\t\t\t\tconst mouseMoveListener = this._listeners.find(\n\t\t\t\t\t({ name }) => name === \"mousemove\",\n\t\t\t\t);\n\t\t\t\tif (mouseMoveListener) {\n\t\t\t\t\tmouseMoveListener.callback(event);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t}\n\n\tpublic unregister(): void {\n\t\tsuper.unregister();\n\t\tthis._clickEventListener?.remove();\n\t\tthis._mouseMoveEventListener?.remove();\n\n\t\tif (this._overlay && this._overlay.getMap()) {\n\t\t\tthis._overlay.setMap(null);\n\t\t}\n\t\tthis._overlay = undefined;\n\t\tthis._readyCalled = false;\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\tgetLngLatFromEvent(event: PointerEvent | MouseEvent) {\n\t\tif (!this._overlay) {\n\t\t\tthrow new Error(\"cannot get overlay\");\n\t\t}\n\n\t\tconst bounds = this._map.getBounds();\n\n\t\tif (!bounds) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst ne = bounds.getNorthEast();\n\t\tconst sw = bounds.getSouthWest();\n\t\tconst latLngBounds = new this._lib.LatLngBounds(sw, ne);\n\n\t\tconst mapCanvas = this._map.getDiv();\n\t\tconst offsetX = event.clientX - mapCanvas.getBoundingClientRect().left;\n\t\tconst offsetY = event.clientY - mapCanvas.getBoundingClientRect().top;\n\t\tconst screenCoord = new this._lib.Point(offsetX, offsetY);\n\n\t\tconst projection = this._overlay.getProjection();\n\t\tif (!projection) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst latLng = projection.fromContainerPixelToLatLng(screenCoord);\n\n\t\tif (latLng && latLngBounds.contains(latLng)) {\n\t\t\treturn { lng: latLng.lng(), lat: latLng.lat() };\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * Retrieves the HTML element of the Google Map element that handles interaction events\n\t * @returns The HTMLElement representing the map container.\n\t */\n\tpublic getMapEventElement() {\n\t\t// TODO: This is a bit hacky, maybe there is a better solution here\n\t\tconst selector = 'div[style*=\"z-index: 3;\"]';\n\t\treturn this._map.getDiv().querySelector(selector) as HTMLDivElement;\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\tproject(lng: number, lat: number) {\n\t\tif (!this._overlay) {\n\t\t\tthrow new Error(\"cannot get overlay\");\n\t\t}\n\n\t\tconst bounds = this._map.getBounds();\n\n\t\tif (bounds === undefined) {\n\t\t\tthrow new Error(\"cannot get bounds\");\n\t\t}\n\n\t\tconst projection = this._overlay.getProjection();\n\t\tif (projection === undefined) {\n\t\t\tthrow new Error(\"cannot get projection\");\n\t\t}\n\n\t\tconst point = projection.fromLatLngToContainerPixel(\n\t\t\tnew this._lib.LatLng(lat, lng),\n\t\t);\n\n\t\tif (point === null) {\n\t\t\tthrow new Error(\"cannot project coordinates\");\n\t\t}\n\n\t\treturn { x: point.x, y: point.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\tunproject(x: number, y: number) {\n\t\tif (!this._overlay) {\n\t\t\tthrow new Error(\"cannot get overlay\");\n\t\t}\n\n\t\tconst projection = this._overlay.getProjection();\n\t\tif (projection === undefined) {\n\t\t\tthrow new Error(\"cannot get projection\");\n\t\t}\n\n\t\tconst latLng = projection.fromContainerPixelToLatLng(\n\t\t\tnew this._lib.Point(x, y),\n\t\t);\n\n\t\tif (latLng === null) {\n\t\t\tthrow new Error(\"cannot unproject coordinates\");\n\t\t}\n\n\t\treturn { lng: latLng.lng(), lat: latLng.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\tsetCursor(cursor: Parameters<SetCursor>[0]) {\n\t\tif (cursor === this._cursor) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this._cursorStyleSheet) {\n\t\t\tthis._cursorStyleSheet.remove();\n\t\t\tthis._cursorStyleSheet = undefined;\n\t\t}\n\n\t\tif (cursor !== \"unset\") {\n\t\t\t// TODO: We could cache these individually per cursor\n\n\t\t\tconst div = this._map.getDiv();\n\t\t\tconst styleDivSelector = `#${div.id} .gm-style > div`;\n\t\t\tconst styleDiv = document.querySelector(styleDivSelector);\n\n\t\t\tif (styleDiv) {\n\t\t\t\tstyleDiv.classList.add(\"terra-draw-google-maps\");\n\n\t\t\t\tconst style = document.createElement(\"style\");\n\t\t\t\tstyle.innerHTML = `.terra-draw-google-maps { cursor: ${cursor} !important; }`;\n\t\t\t\tdocument.getElementsByTagName(\"head\")[0].appendChild(style);\n\t\t\t\tthis._cursorStyleSheet = style;\n\t\t\t}\n\t\t}\n\n\t\tthis._cursor = cursor;\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\tsetDoubleClickToZoom(enabled: boolean) {\n\t\tif (enabled) {\n\t\t\tthis._map.setOptions({ disableDoubleClickZoom: false });\n\t\t} else {\n\t\t\tthis._map.setOptions({ disableDoubleClickZoom: true });\n\t\t}\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\tsetDraggability(enabled: boolean) {\n\t\tthis._map.setOptions({ draggable: enabled });\n\t}\n\n\tprivate renderedFeatureIds: Set<TerraDrawExtend.FeatureId> = new Set();\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\trender(changes: TerraDrawChanges, styling: TerraDrawStylingFunction) {\n\t\tif (this._layers) {\n\t\t\tchanges.deletedIds.forEach((deletedId) => {\n\t\t\t\tconst featureToDelete = this._map.data.getFeatureById(deletedId);\n\t\t\t\tif (featureToDelete) {\n\t\t\t\t\tthis._map.data.remove(featureToDelete);\n\t\t\t\t\tthis.renderedFeatureIds.delete(deletedId);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tchanges.updated.forEach((updatedFeature) => {\n\t\t\t\tif (!updatedFeature || !updatedFeature.id) {\n\t\t\t\t\tthrow new Error(\"Feature is not valid\");\n\t\t\t\t}\n\n\t\t\t\tconst featureToUpdate = this._map.data.getFeatureById(\n\t\t\t\t\tupdatedFeature.id,\n\t\t\t\t);\n\n\t\t\t\tif (!featureToUpdate) {\n\t\t\t\t\tthrow new Error(\"Feature could not be found by Google Maps API\");\n\t\t\t\t}\n\n\t\t\t\t// Remove all keys\n\t\t\t\tfeatureToUpdate.forEachProperty((property, name) => {\n\t\t\t\t\tfeatureToUpdate.setProperty(name, undefined);\n\t\t\t\t});\n\n\t\t\t\t// Update all keys\n\t\t\t\tObject.keys(updatedFeature.properties).forEach((property) => {\n\t\t\t\t\tfeatureToUpdate.setProperty(\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\tupdatedFeature.properties[property],\n\t\t\t\t\t);\n\t\t\t\t});\n\n\t\t\t\tswitch (updatedFeature.geometry.type) {\n\t\t\t\t\tcase \"Point\":\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconst coordinates = updatedFeature.geometry.coordinates;\n\n\t\t\t\t\t\t\tfeatureToUpdate.setGeometry(\n\t\t\t\t\t\t\t\tnew this._lib.Data.Point(\n\t\t\t\t\t\t\t\t\tnew this._lib.LatLng(coordinates[1], coordinates[0]),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"LineString\":\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconst coordinates = updatedFeature.geometry.coordinates;\n\n\t\t\t\t\t\t\tconst path: google.maps.LatLng[] = [];\n\t\t\t\t\t\t\tfor (let i = 0; i < coordinates.length; i++) {\n\t\t\t\t\t\t\t\tconst coordinate = coordinates[i];\n\t\t\t\t\t\t\t\tconst latLng = new this._lib.LatLng(\n\t\t\t\t\t\t\t\t\tcoordinate[1],\n\t\t\t\t\t\t\t\t\tcoordinate[0],\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tpath.push(latLng);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tfeatureToUpdate.setGeometry(new this._lib.Data.LineString(path));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Polygon\":\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconst coordinates = updatedFeature.geometry.coordinates;\n\n\t\t\t\t\t\t\tconst paths: google.maps.LatLng[][] = [];\n\t\t\t\t\t\t\tfor (let i = 0; i < coordinates.length; i++) {\n\t\t\t\t\t\t\t\tconst path: google.maps.LatLng[] = [];\n\t\t\t\t\t\t\t\tfor (let j = 0; j < coordinates[i].length; j++) {\n\t\t\t\t\t\t\t\t\tconst latLng = new this._lib.LatLng(\n\t\t\t\t\t\t\t\t\t\tcoordinates[i][j][1],\n\t\t\t\t\t\t\t\t\t\tcoordinates[i][j][0],\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tpath.push(latLng);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tpaths.push(path);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tfeatureToUpdate.setGeometry(new this._lib.Data.Polygon(paths));\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// Create new features\n\t\t\tchanges.created.forEach((createdFeature) => {\n\t\t\t\tthis.renderedFeatureIds.add(createdFeature.id as string);\n\t\t\t\tthis._map.data.addGeoJson(createdFeature);\n\t\t\t});\n\t\t}\n\n\t\tchanges.created.forEach((feature) => {\n\t\t\tthis.renderedFeatureIds.add(feature.id as string);\n\t\t});\n\n\t\tconst featureCollection = {\n\t\t\ttype: \"FeatureCollection\",\n\t\t\tfeatures: [...changes.created],\n\t\t} as GeoJsonObject;\n\n\t\tthis._map.data.addGeoJson(featureCollection);\n\n\t\tthis._map.data.setStyle((feature) => {\n\t\t\tconst mode = feature.getProperty(\"mode\");\n\t\t\tconst gmGeometry = feature.getGeometry();\n\t\t\tif (!gmGeometry) {\n\t\t\t\tthrow new Error(\"Google Maps geometry not found\");\n\t\t\t}\n\t\t\tconst type = gmGeometry.getType();\n\t\t\tconst properties: Record<string, any> = {};\n\n\t\t\tfeature.forEachProperty((value, property) => {\n\t\t\t\tproperties[property] = value;\n\t\t\t});\n\n\t\t\tconst calculatedStyles = styling[mode]({\n\t\t\t\ttype: \"Feature\",\n\t\t\t\tgeometry: {\n\t\t\t\t\ttype: type as \"Point\" | \"LineString\" | \"Polygon\",\n\t\t\t\t\tcoordinates: [],\n\t\t\t\t},\n\t\t\t\tproperties,\n\t\t\t});\n\n\t\t\tswitch (type) {\n\t\t\t\tcase \"Point\":\n\t\t\t\t\tconst path = this.circlePath(0, 0, calculatedStyles.pointWidth);\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tclickable: false,\n\t\t\t\t\t\ticon: {\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\tfillColor: calculatedStyles.pointColor,\n\t\t\t\t\t\t\tfillOpacity: 1,\n\t\t\t\t\t\t\tstrokeColor: calculatedStyles.pointOutlineColor,\n\t\t\t\t\t\t\tstrokeWeight: calculatedStyles.pointOutlineWidth,\n\t\t\t\t\t\t\trotation: 0,\n\t\t\t\t\t\t\tscale: 1,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tzIndex: calculatedStyles.zIndex,\n\t\t\t\t\t};\n\n\t\t\t\tcase \"LineString\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstrokeColor: calculatedStyles.lineStringColor,\n\t\t\t\t\t\tstrokeWeight: calculatedStyles.lineStringWidth,\n\t\t\t\t\t\tzIndex: calculatedStyles.zIndex,\n\t\t\t\t\t};\n\t\t\t\tcase \"Polygon\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstrokeColor: calculatedStyles.polygonOutlineColor,\n\t\t\t\t\t\tstrokeWeight: calculatedStyles.polygonOutlineWidth,\n\t\t\t\t\t\tfillOpacity: calculatedStyles.polygonFillOpacity,\n\t\t\t\t\t\tfillColor: calculatedStyles.polygonFillColor,\n\t\t\t\t\t\tzIndex: calculatedStyles.zIndex,\n\t\t\t\t\t};\n\t\t\t}\n\n\t\t\tthrow Error(\"Unknown feature type\");\n\t\t});\n\t}\n\n\tprivate clearLayers() {\n\t\tif (this._layers) {\n\t\t\tthis._map.data.forEach((feature) => {\n\t\t\t\tconst id = feature.getId() as string;\n\t\t\t\tconst hasFeature = this.renderedFeatureIds.has(id);\n\t\t\t\tif (hasFeature) {\n\t\t\t\t\tthis._map.data.remove(feature);\n\t\t\t\t}\n\t\t\t});\n\t\t\tthis.renderedFeatureIds = new Set();\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\tpublic getCoordinatePrecision(): number {\n\t\t// TODO: It seems this shouldn't be necessary as extends BaseAdapter which as this method\n\t\treturn super.getCoordinatePrecision();\n\t}\n}\n"],"names":["_TerraDrawExtend$Terr","TerraDrawGoogleMapsAdapter","config","_this","call","this","_cursor","_cursorStyleSheet","_lib","_map","_overlay","_clickEventListener","_mouseMoveEventListener","_readyCalled","renderedFeatureIds","Set","lib","map","getDiv","id","Error","_coordinatePrecision","coordinatePrecision","_proto","prototype","circlePath","cx","cy","r","d","register","callbacks","_this2","OverlayView","draw","onAdd","_this2$_currentModeCa","_currentModeCallbacks","onReady","setMap","onRemove","data","addListener","event","clickListener","_listeners","find","_ref","name","callback","mouseMoveListener","_ref2","unregister","_this$_clickEventList","_this$_mouseMoveEvent","remove","getMap","undefined","getLngLatFromEvent","bounds","getBounds","ne","getNorthEast","sw","getSouthWest","latLngBounds","LatLngBounds","mapCanvas","offsetX","clientX","getBoundingClientRect","left","offsetY","clientY","top","screenCoord","Point","projection","getProjection","latLng","fromContainerPixelToLatLng","contains","lng","lat","getMapEventElement","querySelector","project","point","fromLatLngToContainerPixel","LatLng","x","y","unproject","setCursor","cursor","div","styleDiv","document","classList","add","style","createElement","innerHTML","getElementsByTagName","appendChild","setDoubleClickToZoom","enabled","setOptions","disableDoubleClickZoom","setDraggability","draggable","render","changes","styling","_this3","_layers","deletedIds","forEach","deletedId","featureToDelete","getFeatureById","updated","updatedFeature","featureToUpdate","forEachProperty","property","setProperty","Object","keys","properties","geometry","type","coordinates","setGeometry","Data","path","i","length","coordinate","push","LineString","paths","j","Polygon","created","createdFeature","addGeoJson","feature","featureCollection","features","concat","setStyle","mode","getProperty","gmGeometry","getGeometry","getType","value","calculatedStyles","clickable","icon","pointWidth","fillColor","pointColor","fillOpacity","strokeColor","pointOutlineColor","strokeWeight","pointOutlineWidth","rotation","scale","zIndex","lineStringColor","lineStringWidth","polygonOutlineColor","polygonOutlineWidth","polygonFillOpacity","polygonFillColor","clearLayers","_this4","getId","has","clear","onClear","getCoordinatePrecision","key","get","_this$renderedFeature","Boolean","size","TerraDrawExtend","TerraDrawBaseAdapter"],"mappings":"uuBAWwC,SAAAA,GACvC,SAAAC,EACCC,GAGqCC,IAAAA,EAQrC,IANAA,EAAAH,EAAAI,KAAMF,KAAAA,IAAOG,MAgBNC,aAAOH,EAAAA,EACPI,uBAAiBJ,EAAAA,EACjBK,UAAIL,EAAAA,EACJM,UAAIN,EAAAA,EACJO,gBAAQP,EACRQ,yBAAmB,EAAAR,EACnBS,6BAAuB,EAAAT,EACvBU,cAAe,EAAKV,EAiQpBW,mBAAq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EAAiBQ,kBAC9BC,aAAcT,EAAiBU,kBAC/BC,SAAU,EACVC,MAAO,GAERC,OAAQb,EAAiBa,QAG3B,IAAK,aACJ,MAAO,CACNN,YAAaP,EAAiBc,gBAC9BL,aAAcT,EAAiBe,gBAC/BF,OAAQb,EAAiBa,QAE3B,IAAK,UACJ,MAAO,CACNN,YAAaP,EAAiBgB,oBAC9BP,aAAcT,EAAiBiB,oBAC/BX,YAAaN,EAAiBkB,mBAC9Bd,UAAWJ,EAAiBmB,iBAC5BN,OAAQb,EAAiBa,QAI5B,MAAMvJ,MAAM,uBACb,EACD,EAACG,EAEO2J,YAAA,WAAWC,IAAAA,EAClB9K,KAAIA,KAAK8G,UACR9G,KAAKI,KAAKgC,KAAK4E,QAAQ,SAAC8B,GACvB,IAAMhI,EAAKgI,EAAQiC,QACAD,EAAKrK,mBAAmBuK,IAAIlK,IAE9CgK,EAAK1K,KAAKgC,KAAKc,OAAO4F,EAExB,GACA9I,KAAKS,mBAAqB,IAAIC,IAEhC,EAACQ,EAMM+J,MAAA,WACFjL,KAAKgC,wBAERhC,KAAKgC,sBAAsBkJ,UAG3BlL,KAAK6K,cAEP,EAAC3J,EAEMiK,uBAAA,WAEN,OAAAxL,EAAAwB,UAAagK,uBAAsBpL,KACpCC,KAAA,IAACJ,KAAA,CAAA,CAAAwL,IAAA,UAAAC,IA3cD,WAAmB,IAAAC,EAClB,OAAOC,SAAQD,OAAAA,EAAAtL,KAAKS,yBAAL6K,EAAAA,EAAyBE,MAAO,EAChD,iPAlC+CC,CAAR,CAAQA,EAAAA,gBAAgBC"}
1
+ {"version":3,"file":"terra-draw-google-maps-adapter.umd.js","sources":["../src/terra-draw-google-maps-adapter.ts"],"sourcesContent":["/**\n * @module terra-draw-google-maps-adapter\n */\nimport {\n\tTerraDrawChanges,\n\tSetCursor,\n\tTerraDrawStylingFunction,\n\tTerraDrawExtend,\n} from \"terra-draw\";\nimport { GeoJsonObject } from \"geojson\";\n\nexport class TerraDrawGoogleMapsAdapter extends TerraDrawExtend.TerraDrawBaseAdapter {\n\tconstructor(\n\t\tconfig: {\n\t\t\tlib: typeof google.maps;\n\t\t\tmap: google.maps.Map;\n\t\t} & TerraDrawExtend.BaseAdapterConfig,\n\t) {\n\t\tsuper(config);\n\t\tthis._lib = config.lib;\n\t\tthis._map = config.map;\n\n\t\t// In order for the internals of the adapter to work we require an ID to\n\t\t// allow query selectors to work\n\t\tif (!this._map.getDiv().id) {\n\t\t\tthrow new Error(\"Google Map container div requires and id to be set\");\n\t\t}\n\n\t\tthis._coordinatePrecision =\n\t\t\ttypeof config.coordinatePrecision === \"number\"\n\t\t\t\t? config.coordinatePrecision\n\t\t\t\t: 9;\n\t}\n\n\tprivate _cursor: string | undefined;\n\tprivate _cursorStyleSheet: HTMLStyleElement | undefined;\n\tprivate _lib: typeof google.maps;\n\tprivate _map: google.maps.Map;\n\tprivate _overlay: google.maps.OverlayView | undefined;\n\tprivate _clickEventListener: google.maps.MapsEventListener | undefined;\n\tprivate _mouseMoveEventListener: google.maps.MapsEventListener | undefined;\n\tprivate _readyCalled = false;\n\n\tprivate get _layers(): boolean {\n\t\treturn Boolean(this.renderedFeatureIds?.size > 0);\n\t}\n\n\t/**\n\t * Generates an SVG path string for a circle with the given center coordinates and radius.\n\t * Based off this StackOverflow answer: https://stackoverflow.com/a/27905268/1363484\n\t * @param cx The x-coordinate of the circle's center.\n\t * @param cy The y-coordinate of the circle's center.\n\t * @param r The radius of the circle.\n\t * @returns The SVG path string representing the circle.\n\t */\n\tprivate circlePath(cx: number, cy: number, r: number) {\n\t\tconst d = r * 2;\n\t\treturn `M ${cx} ${cy} m -${r}, 0 a ${r},${r} 0 1,0 ${d},0 a ${r},${r} 0 1,0 -${d},0`;\n\t}\n\n\tpublic register(callbacks: TerraDrawExtend.TerraDrawCallbacks) {\n\t\tsuper.register(callbacks);\n\n\t\t// The overlay is responsible for allow us to\n\t\t// get the projection, which in turn allows us to\n\t\t// go through lng/lat to pixel space and vice versa\n\t\tthis._overlay = new this._lib.OverlayView();\n\t\tthis._overlay.draw = function () {\n\t\t\t// No-op\n\t\t};\n\n\t\t// Unfortunately it is only ready after the onAdd\n\t\t// method is called, which is why we need to use the 'ready'\n\t\t// listener with the Google Maps adapter\n\t\tthis._overlay.onAdd = () => {\n\t\t\tif (this._currentModeCallbacks?.onReady && !this._readyCalled) {\n\t\t\t\tthis._currentModeCallbacks.onReady();\n\t\t\t\tthis._readyCalled = true;\n\t\t\t}\n\t\t};\n\t\tthis._overlay.setMap(this._map);\n\n\t\t// Required to avoid runtime error in Google Maps API\n\t\tthis._overlay.onRemove = () => {\n\t\t\t// No-op\n\t\t};\n\n\t\t// Clicking on data geometries triggers\n\t\t// swallows the map onclick event,\n\t\t// so we need to forward it to the click callback handler\n\t\tthis._clickEventListener = this._map.data.addListener(\n\t\t\t\"click\",\n\t\t\t(\n\t\t\t\tevent: google.maps.MapMouseEvent & {\n\t\t\t\t\tdomEvent: MouseEvent;\n\t\t\t\t},\n\t\t\t) => {\n\t\t\t\tconst clickListener = this._listeners.find(\n\t\t\t\t\t({ name }) => name === \"click\",\n\t\t\t\t);\n\t\t\t\tif (clickListener) {\n\t\t\t\t\tclickListener.callback(event);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\n\t\tthis._mouseMoveEventListener = this._map.data.addListener(\n\t\t\t\"mousemove\",\n\t\t\t(\n\t\t\t\tevent: google.maps.MapMouseEvent & {\n\t\t\t\t\tdomEvent: MouseEvent;\n\t\t\t\t},\n\t\t\t) => {\n\t\t\t\tconst mouseMoveListener = this._listeners.find(\n\t\t\t\t\t({ name }) => name === \"mousemove\",\n\t\t\t\t);\n\t\t\t\tif (mouseMoveListener) {\n\t\t\t\t\tmouseMoveListener.callback(event);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t}\n\n\tpublic unregister(): void {\n\t\tsuper.unregister();\n\t\tthis._clickEventListener?.remove();\n\t\tthis._mouseMoveEventListener?.remove();\n\n\t\tif (this._overlay && this._overlay.getMap()) {\n\t\t\tthis._overlay.setMap(null);\n\t\t}\n\t\tthis._overlay = undefined;\n\t\tthis._readyCalled = false;\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\tgetLngLatFromEvent(event: PointerEvent | MouseEvent) {\n\t\tif (!this._overlay) {\n\t\t\tthrow new Error(\"cannot get overlay\");\n\t\t}\n\n\t\tconst bounds = this._map.getBounds();\n\n\t\tif (!bounds) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst ne = bounds.getNorthEast();\n\t\tconst sw = bounds.getSouthWest();\n\t\tconst latLngBounds = new this._lib.LatLngBounds(sw, ne);\n\n\t\tconst mapCanvas = this._map.getDiv();\n\t\tconst offsetX = event.clientX - mapCanvas.getBoundingClientRect().left;\n\t\tconst offsetY = event.clientY - mapCanvas.getBoundingClientRect().top;\n\t\tconst screenCoord = new this._lib.Point(offsetX, offsetY);\n\n\t\tconst projection = this._overlay.getProjection();\n\t\tif (!projection) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst latLng = projection.fromContainerPixelToLatLng(screenCoord);\n\n\t\tif (latLng && latLngBounds.contains(latLng)) {\n\t\t\treturn { lng: latLng.lng(), lat: latLng.lat() };\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * Retrieves the HTML element of the Google Map element that handles interaction events\n\t * @returns The HTMLElement representing the map container.\n\t */\n\tpublic getMapEventElement() {\n\t\t// TODO: This is a bit hacky, maybe there is a better solution here\n\t\tconst selector = 'div[style*=\"z-index: 3;\"]';\n\t\treturn this._map.getDiv().querySelector(selector) as HTMLDivElement;\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\tproject(lng: number, lat: number) {\n\t\tif (!this._overlay) {\n\t\t\tthrow new Error(\"cannot get overlay\");\n\t\t}\n\n\t\tconst bounds = this._map.getBounds();\n\n\t\tif (bounds === undefined) {\n\t\t\tthrow new Error(\"cannot get bounds\");\n\t\t}\n\n\t\tconst projection = this._overlay.getProjection();\n\t\tif (projection === undefined) {\n\t\t\tthrow new Error(\"cannot get projection\");\n\t\t}\n\n\t\tconst point = projection.fromLatLngToContainerPixel(\n\t\t\tnew this._lib.LatLng(lat, lng),\n\t\t);\n\n\t\tif (point === null) {\n\t\t\tthrow new Error(\"cannot project coordinates\");\n\t\t}\n\n\t\treturn { x: point.x, y: point.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\tunproject(x: number, y: number) {\n\t\tif (!this._overlay) {\n\t\t\tthrow new Error(\"cannot get overlay\");\n\t\t}\n\n\t\tconst projection = this._overlay.getProjection();\n\t\tif (projection === undefined) {\n\t\t\tthrow new Error(\"cannot get projection\");\n\t\t}\n\n\t\tconst latLng = projection.fromContainerPixelToLatLng(\n\t\t\tnew this._lib.Point(x, y),\n\t\t);\n\n\t\tif (latLng === null) {\n\t\t\tthrow new Error(\"cannot unproject coordinates\");\n\t\t}\n\n\t\treturn { lng: latLng.lng(), lat: latLng.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\tsetCursor(cursor: Parameters<SetCursor>[0]) {\n\t\tif (cursor === this._cursor) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this._cursorStyleSheet) {\n\t\t\tthis._cursorStyleSheet.remove();\n\t\t\tthis._cursorStyleSheet = undefined;\n\t\t}\n\n\t\tif (cursor !== \"unset\") {\n\t\t\t// TODO: We could cache these individually per cursor\n\n\t\t\tconst div = this._map.getDiv();\n\t\t\tconst styleDivSelector = `#${div.id} .gm-style > div`;\n\t\t\tconst styleDiv = document.querySelector(styleDivSelector);\n\n\t\t\tif (styleDiv) {\n\t\t\t\tstyleDiv.classList.add(\"terra-draw-google-maps\");\n\n\t\t\t\tconst style = document.createElement(\"style\");\n\t\t\t\tstyle.innerHTML = `.terra-draw-google-maps { cursor: ${cursor} !important; }`;\n\t\t\t\tdocument.getElementsByTagName(\"head\")[0].appendChild(style);\n\t\t\t\tthis._cursorStyleSheet = style;\n\t\t\t}\n\t\t}\n\n\t\tthis._cursor = cursor;\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\tsetDoubleClickToZoom(enabled: boolean) {\n\t\tif (enabled) {\n\t\t\tthis._map.setOptions({ disableDoubleClickZoom: false });\n\t\t} else {\n\t\t\tthis._map.setOptions({ disableDoubleClickZoom: true });\n\t\t}\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\tsetDraggability(enabled: boolean) {\n\t\tthis._map.setOptions({ draggable: enabled });\n\t}\n\n\tprivate renderedFeatureIds: Set<TerraDrawExtend.FeatureId> = new Set();\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\trender(changes: TerraDrawChanges, styling: TerraDrawStylingFunction) {\n\t\tif (this._layers) {\n\t\t\tchanges.deletedIds.forEach((deletedId) => {\n\t\t\t\tconst featureToDelete = this._map.data.getFeatureById(deletedId);\n\t\t\t\tif (featureToDelete) {\n\t\t\t\t\tthis._map.data.remove(featureToDelete);\n\t\t\t\t\tthis.renderedFeatureIds.delete(deletedId);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tchanges.updated.forEach((updatedFeature) => {\n\t\t\t\tif (!updatedFeature || !updatedFeature.id) {\n\t\t\t\t\tthrow new Error(\"Feature is not valid\");\n\t\t\t\t}\n\n\t\t\t\tconst featureToUpdate = this._map.data.getFeatureById(\n\t\t\t\t\tupdatedFeature.id,\n\t\t\t\t);\n\n\t\t\t\tif (!featureToUpdate) {\n\t\t\t\t\tthrow new Error(\"Feature could not be found by Google Maps API\");\n\t\t\t\t}\n\n\t\t\t\t// Remove all keys\n\t\t\t\tfeatureToUpdate.forEachProperty((property, name) => {\n\t\t\t\t\tfeatureToUpdate.setProperty(name, undefined);\n\t\t\t\t});\n\n\t\t\t\t// Update all keys\n\t\t\t\tObject.keys(updatedFeature.properties).forEach((property) => {\n\t\t\t\t\tfeatureToUpdate.setProperty(\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\tupdatedFeature.properties[property],\n\t\t\t\t\t);\n\t\t\t\t});\n\n\t\t\t\tswitch (updatedFeature.geometry.type) {\n\t\t\t\t\tcase \"Point\":\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconst coordinates = updatedFeature.geometry.coordinates;\n\n\t\t\t\t\t\t\tfeatureToUpdate.setGeometry(\n\t\t\t\t\t\t\t\tnew this._lib.Data.Point(\n\t\t\t\t\t\t\t\t\tnew this._lib.LatLng(coordinates[1], coordinates[0]),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"LineString\":\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconst coordinates = updatedFeature.geometry.coordinates;\n\n\t\t\t\t\t\t\tconst path: google.maps.LatLng[] = [];\n\t\t\t\t\t\t\tfor (let i = 0; i < coordinates.length; i++) {\n\t\t\t\t\t\t\t\tconst coordinate = coordinates[i];\n\t\t\t\t\t\t\t\tconst latLng = new this._lib.LatLng(\n\t\t\t\t\t\t\t\t\tcoordinate[1],\n\t\t\t\t\t\t\t\t\tcoordinate[0],\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tpath.push(latLng);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tfeatureToUpdate.setGeometry(new this._lib.Data.LineString(path));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Polygon\":\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconst coordinates = updatedFeature.geometry.coordinates;\n\n\t\t\t\t\t\t\tconst paths: google.maps.LatLng[][] = [];\n\t\t\t\t\t\t\tfor (let i = 0; i < coordinates.length; i++) {\n\t\t\t\t\t\t\t\tconst path: google.maps.LatLng[] = [];\n\t\t\t\t\t\t\t\tfor (let j = 0; j < coordinates[i].length; j++) {\n\t\t\t\t\t\t\t\t\tconst latLng = new this._lib.LatLng(\n\t\t\t\t\t\t\t\t\t\tcoordinates[i][j][1],\n\t\t\t\t\t\t\t\t\t\tcoordinates[i][j][0],\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tpath.push(latLng);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tpaths.push(path);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tfeatureToUpdate.setGeometry(new this._lib.Data.Polygon(paths));\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// Create new features\n\t\t\tchanges.created.forEach((createdFeature) => {\n\t\t\t\tthis.renderedFeatureIds.add(createdFeature.id as string);\n\t\t\t\tthis._map.data.addGeoJson(createdFeature);\n\t\t\t});\n\t\t}\n\n\t\tchanges.created.forEach((feature) => {\n\t\t\tthis.renderedFeatureIds.add(feature.id as string);\n\t\t});\n\n\t\tconst featureCollection = {\n\t\t\ttype: \"FeatureCollection\",\n\t\t\tfeatures: [...changes.created],\n\t\t} as GeoJsonObject;\n\n\t\tthis._map.data.addGeoJson(featureCollection);\n\n\t\tthis._map.data.setStyle((feature) => {\n\t\t\tconst mode = feature.getProperty(\"mode\");\n\t\t\tconst gmGeometry = feature.getGeometry();\n\t\t\tif (!gmGeometry) {\n\t\t\t\tthrow new Error(\"Google Maps geometry not found\");\n\t\t\t}\n\t\t\tconst type = gmGeometry.getType();\n\t\t\tconst properties: Record<string, any> = {};\n\t\t\tconst id = feature.getId();\n\n\t\t\tfeature.forEachProperty((value, property) => {\n\t\t\t\tproperties[property] = value;\n\t\t\t});\n\n\t\t\tconst calculatedStyles = styling[mode]({\n\t\t\t\ttype: \"Feature\",\n\t\t\t\tid,\n\t\t\t\tgeometry: {\n\t\t\t\t\ttype: type as \"Point\" | \"LineString\" | \"Polygon\",\n\t\t\t\t\tcoordinates: [],\n\t\t\t\t},\n\t\t\t\tproperties,\n\t\t\t});\n\n\t\t\tswitch (type) {\n\t\t\t\tcase \"Point\":\n\t\t\t\t\tconst path = this.circlePath(0, 0, calculatedStyles.pointWidth);\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tclickable: false,\n\t\t\t\t\t\ticon: {\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\tfillColor: calculatedStyles.pointColor,\n\t\t\t\t\t\t\tfillOpacity: 1,\n\t\t\t\t\t\t\tstrokeColor: calculatedStyles.pointOutlineColor,\n\t\t\t\t\t\t\tstrokeWeight: calculatedStyles.pointOutlineWidth,\n\t\t\t\t\t\t\trotation: 0,\n\t\t\t\t\t\t\tscale: 1,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tzIndex: calculatedStyles.zIndex,\n\t\t\t\t\t};\n\n\t\t\t\tcase \"LineString\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstrokeColor: calculatedStyles.lineStringColor,\n\t\t\t\t\t\tstrokeWeight: calculatedStyles.lineStringWidth,\n\t\t\t\t\t\tzIndex: calculatedStyles.zIndex,\n\t\t\t\t\t};\n\t\t\t\tcase \"Polygon\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstrokeColor: calculatedStyles.polygonOutlineColor,\n\t\t\t\t\t\tstrokeWeight: calculatedStyles.polygonOutlineWidth,\n\t\t\t\t\t\tfillOpacity: calculatedStyles.polygonFillOpacity,\n\t\t\t\t\t\tfillColor: calculatedStyles.polygonFillColor,\n\t\t\t\t\t\tzIndex: calculatedStyles.zIndex,\n\t\t\t\t\t};\n\t\t\t}\n\n\t\t\tthrow Error(\"Unknown feature type\");\n\t\t});\n\t}\n\n\tprivate clearLayers() {\n\t\tif (this._layers) {\n\t\t\tthis._map.data.forEach((feature) => {\n\t\t\t\tconst id = feature.getId() as string;\n\t\t\t\tconst hasFeature = this.renderedFeatureIds.has(id);\n\t\t\t\tif (hasFeature) {\n\t\t\t\t\tthis._map.data.remove(feature);\n\t\t\t\t}\n\t\t\t});\n\t\t\tthis.renderedFeatureIds = new Set();\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\tpublic getCoordinatePrecision(): number {\n\t\t// TODO: It seems this shouldn't be necessary as extends BaseAdapter which as this method\n\t\treturn super.getCoordinatePrecision();\n\t}\n}\n"],"names":["_TerraDrawExtend$Terr","TerraDrawGoogleMapsAdapter","config","_this","call","this","_cursor","_cursorStyleSheet","_lib","_map","_overlay","_clickEventListener","_mouseMoveEventListener","_readyCalled","renderedFeatureIds","Set","lib","map","getDiv","id","Error","_coordinatePrecision","coordinatePrecision","_proto","prototype","circlePath","cx","cy","r","d","register","callbacks","_this2","OverlayView","draw","onAdd","_this2$_currentModeCa","_currentModeCallbacks","onReady","setMap","onRemove","data","addListener","event","clickListener","_listeners","find","_ref","name","callback","mouseMoveListener","_ref2","unregister","_this$_clickEventList","_this$_mouseMoveEvent","remove","getMap","undefined","getLngLatFromEvent","bounds","getBounds","ne","getNorthEast","sw","getSouthWest","latLngBounds","LatLngBounds","mapCanvas","offsetX","clientX","getBoundingClientRect","left","offsetY","clientY","top","screenCoord","Point","projection","getProjection","latLng","fromContainerPixelToLatLng","contains","lng","lat","getMapEventElement","querySelector","project","point","fromLatLngToContainerPixel","LatLng","x","y","unproject","setCursor","cursor","div","styleDiv","document","classList","add","style","createElement","innerHTML","getElementsByTagName","appendChild","setDoubleClickToZoom","enabled","setOptions","disableDoubleClickZoom","setDraggability","draggable","render","changes","styling","_this3","_layers","deletedIds","forEach","deletedId","featureToDelete","getFeatureById","updated","updatedFeature","featureToUpdate","forEachProperty","property","setProperty","Object","keys","properties","geometry","type","coordinates","setGeometry","Data","path","i","length","coordinate","push","LineString","paths","j","Polygon","created","createdFeature","addGeoJson","feature","featureCollection","features","concat","setStyle","mode","getProperty","gmGeometry","getGeometry","getType","getId","value","calculatedStyles","clickable","icon","pointWidth","fillColor","pointColor","fillOpacity","strokeColor","pointOutlineColor","strokeWeight","pointOutlineWidth","rotation","scale","zIndex","lineStringColor","lineStringWidth","polygonOutlineColor","polygonOutlineWidth","polygonFillOpacity","polygonFillColor","clearLayers","_this4","has","clear","onClear","getCoordinatePrecision","key","get","_this$renderedFeature","Boolean","size","TerraDrawExtend","TerraDrawBaseAdapter"],"mappings":"uuBAWwC,SAAAA,GACvC,SAAAC,EACCC,GAGqCC,IAAAA,EAQrC,IANAA,EAAAH,EAAAI,KAAMF,KAAAA,IAAOG,MAgBNC,aAAOH,EAAAA,EACPI,uBAAiBJ,EAAAA,EACjBK,UAAIL,EAAAA,EACJM,UAAIN,EAAAA,EACJO,gBAAQP,EACRQ,yBAAmB,EAAAR,EACnBS,6BAAuB,EAAAT,EACvBU,cAAe,EAAKV,EAiQpBW,mBAAqD,IAAIC,IAvRhEZ,EAAKK,KAAON,EAAOc,IACnBb,EAAKM,KAAOP,EAAOe,KAIdd,EAAKM,KAAKS,SAASC,GACvB,MAAM,IAAIC,MAAM,sDAMX,OAHNjB,EAAKkB,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,CACNN,YAAaP,EAAiBc,gBAC9BL,aAAcT,EAAiBe,gBAC/BF,OAAQb,EAAiBa,QAE3B,IAAK,UACJ,MAAO,CACNN,YAAaP,EAAiBgB,oBAC9BP,aAAcT,EAAiBiB,oBAC/BX,YAAaN,EAAiBkB,mBAC9Bd,UAAWJ,EAAiBmB,iBAC5BN,OAAQb,EAAiBa,QAI5B,MAAMxJ,MAAM,uBACb,EACD,EAACG,EAEO4J,YAAA,WAAW,IAAAC,EAAA/K,KACdA,KAAK8G,UACR9G,KAAKI,KAAKgC,KAAK4E,QAAQ,SAAC8B,GACvB,IAAMhI,EAAKgI,EAAQU,QACAuB,EAAKtK,mBAAmBuK,IAAIlK,IAE9CiK,EAAK3K,KAAKgC,KAAKc,OAAO4F,EAExB,GACA9I,KAAKS,mBAAqB,IAAIC,IAEhC,EAACQ,EAMM+J,MAAA,WACFjL,KAAKgC,wBAERhC,KAAKgC,sBAAsBkJ,UAG3BlL,KAAK8K,cAEP,EAAC5J,EAEMiK,uBAAA,WAEN,OAAAxL,EAAAwB,UAAagK,uBAAsBpL,KACpCC,KAAA,IAACJ,KAAA,CAAA,CAAAwL,IAAA,UAAAC,IA7cD,WAAmB,IAAAC,EAClB,OAAOC,SAAQD,OAAAA,EAAAtL,KAAKS,yBAAL6K,EAAAA,EAAyBE,MAAO,EAChD,iPAlC+CC,CAAR,CAAQA,EAAAA,gBAAgBC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "terra-draw-google-maps-adapter",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Terra Draw Adapter for Google Maps JavaScript API",
5
5
  "peerDependencies": {
6
6
  "terra-draw": "^1.0.0",