{"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\tGeoJSONStoreFeatures,\n} from \"terra-draw\";\n\nimport { GeoJsonObject } from \"geojson\";\n\nexport class TerraDrawGoogleMapsAdapter\n\textends TerraDrawExtend.TerraDrawBaseAdapter\n{\n\tconstructor(\n\t\tconfig: {\n\t\t\tlib: typeof google.maps;\n\t\t\tmap: google.maps.Map;\n\t\t\tforwardMapElementEvents?: boolean;\n\t\t\tisolatedData?: boolean;\n\t\t} & TerraDrawExtend.BaseAdapterConfig,\n\t) {\n\t\tsuper(config);\n\t\tthis._lib = config.lib;\n\t\tthis._map = config.map;\n\t\tthis._forwardMapElementEvents =\n\t\t\ttypeof config.forwardMapElementEvents === \"boolean\"\n\t\t\t\t? config.forwardMapElementEvents\n\t\t\t\t: false;\n\t\tthis._isolatedData = config.isolatedData || false;\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 _forwardMapElementEvents: boolean = false;\n\tprivate _isolatedData: boolean = false;\n\tprivate _data: google.maps.Data | undefined;\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\t// Cached so listeners are always removed from the element they were added to\n\tprivate _mapEventElement: HTMLElement | undefined;\n\tprivate _markerClickListener: any | undefined;\n\tprivate _markerMouseMoveListener: ((event: MouseEvent) => void) | undefined;\n\tprivate _pointerCaptureDownListener:\n\t\t| ((event: PointerEvent) => void)\n\t\t| undefined;\n\tprivate _pointerCaptureUpListener:\n\t\t| ((event: PointerEvent) => void)\n\t\t| undefined;\n\tprivate _clickEventListener: google.maps.MapsEventListener | undefined;\n\tprivate _mouseMoveEventListener: google.maps.MapsEventListener | undefined;\n\tprivate _readyCalled = false;\n\n\tprivate _interactiveTargetSelector = [\n\t\t'[role=\"dialog\"]',\n\t\t\"a\",\n\t\t\"button\",\n\t\t\"input\",\n\t\t\"select\",\n\t\t\"textarea\",\n\t\t\"summary\",\n\t\t'[role=\"button\"]',\n\t\t'[role=\"link\"]',\n\t\t'[contenteditable=\"\"]',\n\t\t'[contenteditable=\"true\"]',\n\t].join(\", \");\n\n\tprivate _advancedMarkerElementTag = \"gmp-advanced-marker\";\n\n\tprivate get _hasRenderedFeatures(): boolean {\n\t\treturn Boolean(this.renderedFeatureIds?.size > 0);\n\t}\n\n\tprivate getPointerTargetElement(target: EventTarget | null) {\n\t\tif (!target) {\n\t\t\treturn null;\n\t\t}\n\n\t\tif (target instanceof Element) {\n\t\t\treturn target;\n\t\t}\n\n\t\tif (target instanceof Node) {\n\t\t\treturn target.parentElement;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tprivate shouldCapturePointer(event: PointerEvent) {\n\t\tconst targetElement = this.getPointerTargetElement(event.target);\n\t\tif (!targetElement) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif (targetElement.closest(this._advancedMarkerElementTag)) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Avoid pointer capture on interactive controls so native map UI keeps working.\n\t\treturn !targetElement.closest(this._interactiveTargetSelector);\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\tif (this._forwardMapElementEvents) {\n\t\t\tconst mapEventElement = this.getMapEventElement();\n\t\t\tthis._pointerCaptureDownListener = (event: PointerEvent) => {\n\t\t\t\tif (!event.isPrimary) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (!this.shouldCapturePointer(event)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (typeof mapEventElement.setPointerCapture === \"function\") {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tmapEventElement.setPointerCapture(event.pointerId);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// Pointer capture can throw if the pointer is not active.\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tthis._pointerCaptureUpListener = (event: PointerEvent) => {\n\t\t\t\tif (\n\t\t\t\t\ttypeof mapEventElement.releasePointerCapture === \"function\" &&\n\t\t\t\t\ttypeof mapEventElement.hasPointerCapture === \"function\" &&\n\t\t\t\t\tmapEventElement.hasPointerCapture(event.pointerId)\n\t\t\t\t) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tmapEventElement.releasePointerCapture(event.pointerId);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// Pointer may already be released by browser.\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tmapEventElement.addEventListener(\n\t\t\t\t\"pointerdown\",\n\t\t\t\tthis._pointerCaptureDownListener,\n\t\t\t);\n\t\t\tmapEventElement.addEventListener(\n\t\t\t\t\"pointerup\",\n\t\t\t\tthis._pointerCaptureUpListener,\n\t\t\t);\n\t\t\tmapEventElement.addEventListener(\n\t\t\t\t\"pointercancel\",\n\t\t\t\tthis._pointerCaptureUpListener,\n\t\t\t);\n\n\t\t\tthis._markerClickListener = (event: MouseEvent) => {\n\t\t\t\tconst target = event.target as HTMLElement;\n\n\t\t\t\tif (!target?.closest(this._advancedMarkerElementTag)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst drawEvent = this.getDrawEventFromEvent(event);\n\t\t\t\tif (drawEvent) {\n\t\t\t\t\tcallbacks.onClick(drawEvent);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tmapEventElement.addEventListener(\n\t\t\t\t\"pointerdown\",\n\t\t\t\tthis._markerClickListener,\n\t\t\t);\n\n\t\t\tthis._markerMouseMoveListener = (event: MouseEvent) => {\n\t\t\t\tconst target = event.target as HTMLElement;\n\n\t\t\t\tif (!target?.closest(this._advancedMarkerElementTag)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst drawEvent = this.getDrawEventFromEvent(event);\n\t\t\t\tif (drawEvent) {\n\t\t\t\t\tcallbacks.onMouseMove(drawEvent);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tmapEventElement.addEventListener(\n\t\t\t\t\"pointermove\",\n\t\t\t\tthis._markerMouseMoveListener,\n\t\t\t);\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.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.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\n\t\tif (this._isolatedData) {\n\t\t\tthis._data = new this._lib.Data();\n\t\t\tthis._data.setMap(this._map);\n\t\t}\n\t}\n\n\tprotected data() {\n\t\tif (this._isolatedData && this._data) {\n\t\t\treturn this._data;\n\t\t}\n\t\treturn this._map.data;\n\t}\n\n\tprivate styling: TerraDrawStylingFunction | undefined;\n\n\tprivate style(feature: google.maps.Data.Feature) {\n\t\tif (!this.styling) {\n\t\t\tthrow new Error(\"Styling function not defined\");\n\t\t}\n\n\t\tconst id = String(feature.getId());\n\n\t\t// Style callback has been called for a feature that is not rendered\n\t\tif (!this.renderedFeatureIds.has(id as string)) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst mode = feature.getProperty(\"mode\") as string;\n\t\tconst gmGeometry = feature.getGeometry();\n\t\tif (!gmGeometry) {\n\t\t\tthrow new Error(\"Google Maps geometry not found\");\n\t\t}\n\t\tconst type = gmGeometry.getType();\n\t\tconst properties: Record<string, any> = {};\n\n\t\tfeature.forEachProperty((value, property) => {\n\t\t\tproperties[property] = value;\n\t\t});\n\n\t\tconst calculatedStyles = this.styling[mode]({\n\t\t\ttype: \"Feature\",\n\t\t\tid,\n\t\t\tgeometry: {\n\t\t\t\ttype: type as \"Point\" | \"LineString\" | \"Polygon\",\n\t\t\t\tcoordinates: [],\n\t\t\t},\n\t\t\tproperties,\n\t\t});\n\n\t\tswitch (type) {\n\t\t\tcase \"Point\":\n\t\t\t\tif (calculatedStyles.markerUrl) {\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\turl: calculatedStyles.markerUrl as string,\n\t\t\t\t\t\t\tscaledSize:\n\t\t\t\t\t\t\t\tcalculatedStyles.markerWidth && calculatedStyles.markerHeight\n\t\t\t\t\t\t\t\t\t? new this._lib.Size(\n\t\t\t\t\t\t\t\t\t\t\tcalculatedStyles.markerWidth,\n\t\t\t\t\t\t\t\t\t\t\tcalculatedStyles.markerHeight,\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tzIndex: calculatedStyles.zIndex,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst path = this.circlePath(0, 0, calculatedStyles.pointWidth);\n\n\t\t\t\t// Backwards compatible read: pre Terra Draw v1.24.0 will not have this field in the interface\n\t\t\t\tconst strokeOpacity = (\n\t\t\t\t\tcalculatedStyles as { pointOutlineOpacity?: number }\n\t\t\t\t).pointOutlineOpacity;\n\t\t\t\tconst fillOpacity = (calculatedStyles as { pointOpacity?: number })\n\t\t\t\t\t.pointOpacity;\n\n\t\t\t\treturn {\n\t\t\t\t\tclickable: false,\n\t\t\t\t\ticon: {\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\tfillColor: calculatedStyles.pointColor,\n\t\t\t\t\t\tfillOpacity: fillOpacity === undefined ? 1 : fillOpacity,\n\t\t\t\t\t\tstrokeColor: calculatedStyles.pointOutlineColor,\n\t\t\t\t\t\tstrokeWeight: calculatedStyles.pointOutlineWidth,\n\t\t\t\t\t\tstrokeOpacity: strokeOpacity === undefined ? 1 : strokeOpacity,\n\t\t\t\t\t\trotation: 0,\n\t\t\t\t\t\tscale: 1,\n\t\t\t\t\t},\n\t\t\t\t\tzIndex: calculatedStyles.zIndex,\n\t\t\t\t};\n\n\t\t\tcase \"LineString\":\n\t\t\t\t// Backwards compatible read: pre Terra Draw v1.24.0 will not have this field in the interface\n\t\t\t\tconst lineStringOpacity = (\n\t\t\t\t\tcalculatedStyles as { lineStringOpacity?: number }\n\t\t\t\t).lineStringOpacity;\n\t\t\t\t// Backwards compatible read: pre Terra Draw v1.24.0 will not have this field in the interface\n\t\t\t\tconst lineStringDash = (\n\t\t\t\t\tcalculatedStyles as {\n\t\t\t\t\t\tlineStringDash?: [number, number];\n\t\t\t\t\t}\n\t\t\t\t).lineStringDash;\n\n\t\t\t\tconst dashedLineStyles = lineStringDash\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tstrokeOpacity: 0,\n\t\t\t\t\t\t\ticons: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ticon: {\n\t\t\t\t\t\t\t\t\t\tpath: \"M 0,0 0,\" + lineStringDash[0],\n\t\t\t\t\t\t\t\t\t\tstrokeOpacity: 1,\n\t\t\t\t\t\t\t\t\t\tstrokeWeight: calculatedStyles.lineStringWidth,\n\t\t\t\t\t\t\t\t\t\tcolor: calculatedStyles.lineStringColor,\n\t\t\t\t\t\t\t\t\t\tscale: 1,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\toffset: \"0\",\n\t\t\t\t\t\t\t\t\trepeat: `${lineStringDash[0] + lineStringDash[1]}px`,\n\t\t\t\t\t\t\t\t\tfixedRotation: false,\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: {};\n\n\t\t\t\treturn {\n\t\t\t\t\tstrokeColor: calculatedStyles.lineStringColor,\n\t\t\t\t\tstrokeWeight: calculatedStyles.lineStringWidth,\n\t\t\t\t\tstrokeOpacity:\n\t\t\t\t\t\tlineStringOpacity === undefined ? 1 : lineStringOpacity,\n\t\t\t\t\tzIndex: calculatedStyles.zIndex,\n\t\t\t\t\t...dashedLineStyles,\n\t\t\t\t};\n\t\t\tcase \"Polygon\":\n\t\t\t\tconst polygonOutlineOpacity = (\n\t\t\t\t\tcalculatedStyles as { polygonOutlineOpacity?: number }\n\t\t\t\t).polygonOutlineOpacity;\n\n\t\t\t\treturn {\n\t\t\t\t\tstrokeColor: calculatedStyles.polygonOutlineColor,\n\t\t\t\t\tstrokeWeight: calculatedStyles.polygonOutlineWidth,\n\t\t\t\t\tstrokeOpacity:\n\t\t\t\t\t\tpolygonOutlineOpacity === undefined ? 1 : polygonOutlineOpacity,\n\t\t\t\t\tfillOpacity: calculatedStyles.polygonFillOpacity,\n\t\t\t\t\tfillColor: calculatedStyles.polygonFillColor,\n\t\t\t\t\tzIndex: calculatedStyles.zIndex,\n\t\t\t\t};\n\t\t}\n\n\t\tthrow Error(\"Unknown feature type\");\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._markerClickListener) {\n\t\t\tthis.getMapEventElement().removeEventListener(\n\t\t\t\t\"pointerdown\",\n\t\t\t\tthis._markerClickListener,\n\t\t\t);\n\t\t}\n\n\t\tif (this._markerMouseMoveListener) {\n\t\t\tthis.getMapEventElement().removeEventListener(\n\t\t\t\t\"pointermove\",\n\t\t\t\tthis._markerMouseMoveListener,\n\t\t\t);\n\t\t}\n\n\t\tif (this._pointerCaptureDownListener) {\n\t\t\tthis.getMapEventElement().removeEventListener(\n\t\t\t\t\"pointerdown\",\n\t\t\t\tthis._pointerCaptureDownListener,\n\t\t\t);\n\t\t}\n\n\t\tif (this._pointerCaptureUpListener) {\n\t\t\tthis.getMapEventElement().removeEventListener(\n\t\t\t\t\"pointerup\",\n\t\t\t\tthis._pointerCaptureUpListener,\n\t\t\t);\n\t\t\tthis.getMapEventElement().removeEventListener(\n\t\t\t\t\"pointercancel\",\n\t\t\t\tthis._pointerCaptureUpListener,\n\t\t\t);\n\t\t}\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\tthis._mapEventElement = undefined;\n\n\t\tif (this._isolatedData && this._data) {\n\t\t\tthis._data.setMap(null);\n\t\t\tthis._data = undefined;\n\t\t}\n\t}\n\n\t/**\n\t * Returns the longitude and latitude coordinates from a given PointerEvent on the map.\n\t * @param event The PointerEvent or MouseEvent containing the screen coordinates of the pointer.\n\t * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude, or null if the conversion is not possible.\n\t */\n\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\t// In fullscreen mode, use coordinates relative to the fullscreen element\n\t\tconst mapElement = document.fullscreenElement ?? this._map.getDiv();\n\t\tconst mapCanvasRect = mapElement.getBoundingClientRect();\n\t\tconst offsetX = event.clientX - mapCanvasRect.left;\n\t\tconst offsetY = event.clientY - mapCanvasRect.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\teventType?: // TODO: Import TerraDrawHandledEvents - however is a breaking change currently\n\t\t\t| \"pointerdown\"\n\t\t\t| \"pointerup\"\n\t\t\t| \"pointermove\"\n\t\t\t| \"contextmenu\"\n\t\t\t| \"keyup\"\n\t\t\t| \"keydown\",\n\t): HTMLElement {\n\t\tif (eventType && (eventType === \"keyup\" || eventType === \"keydown\")) {\n\t\t\treturn this._map.getDiv();\n\t\t}\n\n\t\tif (!this._mapEventElement) {\n\t\t\t// TODO: This is a bit hacky, maybe there is a better solution here\n\t\t\tconst selector = 'div[style*=\"z-index: 3;\"]';\n\t\t\tthis._mapEventElement = this._map\n\t\t\t\t.getDiv()\n\t\t\t\t.querySelector(selector) as HTMLElement;\n\t\t}\n\n\t\treturn this._mapEventElement;\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 styleDiv = div.querySelector(\".gm-style > div\");\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 * Schedules actual mutations into requestAnimationFrame, applying:\n\t * deletes -> updates -> creates\n\t */\n\trender(changes: TerraDrawChanges, styling: TerraDrawStylingFunction) {\n\t\tthis.styling = styling;\n\n\t\tif (!this.data().getStyle()) {\n\t\t\tthis.data().setStyle((feature) => this.style(feature));\n\t\t}\n\n\t\t// Ensure scheduler state exists\n\t\tif (!this._rafState) {\n\t\t\tthis._rafState = {\n\t\t\t\trafId: null as number | null,\n\t\t\t\tpending: {\n\t\t\t\t\tdeletedIds: [] as string[],\n\t\t\t\t\tupdated: [] as GeoJSONStoreFeatures[],\n\t\t\t\t\tcreated: [] as GeoJSONStoreFeatures[],\n\t\t\t\t},\n\t\t\t\t// Used to coalesce changes within a frame\n\t\t\t\tdeletedSet: new Set<string>(),\n\t\t\t\tupdatedById: new Map<string, GeoJSONStoreFeatures>(),\n\t\t\t\tcreatedById: new Map<string, GeoJSONStoreFeatures>(),\n\t\t\t};\n\t\t}\n\n\t\t// ---- Queue up changes for the next animation frame ----\n\t\t// Deleted\n\t\tfor (const id of changes.deletedIds) {\n\t\t\t// If something is deleted, it shouldn't also be created/updated in same frame.\n\t\t\tthis._rafState.deletedSet.add(id as string);\n\t\t\tthis._rafState.updatedById.delete(id as string);\n\t\t\tthis._rafState.createdById.delete(id as string);\n\t\t}\n\n\t\t// Updated\n\t\tfor (const feature of changes.updated) {\n\t\t\tif (!feature?.id) throw new Error(\"Feature is not valid\");\n\n\t\t\tconst id = String(feature.id);\n\t\t\tif (this._rafState.deletedSet.has(id)) continue; // delete wins\n\n\t\t\t// If it was created this frame, treat as \"create with latest data\"\n\t\t\tif (this._rafState.createdById.has(id)) {\n\t\t\t\tthis._rafState.createdById.set(id, feature);\n\t\t\t} else {\n\t\t\t\tthis._rafState.updatedById.set(id, feature); // latest update wins\n\t\t\t}\n\t\t}\n\n\t\t// Created\n\t\tfor (const feature of changes.created) {\n\t\t\tif (!feature?.id) throw new Error(\"Feature is not valid\");\n\n\t\t\tconst id = String(feature.id);\n\n\t\t\t// Preserve delete+create cycles for the same id in one frame (e.g. undo/redo).\n\t\t\t// Flush order is delete -> update -> create, so recreation still occurs.\n\n\t\t\tthis._rafState.createdById.set(id, feature); // latest create wins\n\t\t\tthis._rafState.updatedById.delete(id); // creation supersedes update in same frame\n\t\t}\n\n\t\t// Schedule a flush if not already scheduled\n\t\tif (this._rafState.rafId == null) {\n\t\t\tthis._rafState.rafId = requestAnimationFrame(() => {\n\t\t\t\tif (!this._rafState) return;\n\n\t\t\t\tthis._rafState.rafId = null;\n\n\t\t\t\t// Snapshot + clear (so new renders can queue while we flush)\n\t\t\t\tconst deletedIds = Array.from(this._rafState.deletedSet);\n\t\t\t\tconst updated = Array.from(this._rafState.updatedById.values());\n\t\t\t\tconst created = Array.from(this._rafState.createdById.values());\n\n\t\t\t\tthis._rafState!.deletedSet.clear();\n\t\t\t\tthis._rafState!.updatedById.clear();\n\t\t\t\tthis._rafState!.createdById.clear();\n\n\t\t\t\t// ---- Apply chronologically: deletes -> updates -> creates ----\n\t\t\t\tif (this._hasRenderedFeatures) {\n\t\t\t\t\t// Deletes\n\t\t\t\t\tfor (const deletedId of deletedIds) {\n\t\t\t\t\t\tconst featureToDelete = this.data().getFeatureById(deletedId);\n\t\t\t\t\t\tif (featureToDelete) {\n\t\t\t\t\t\t\tthis.data().remove(featureToDelete);\n\t\t\t\t\t\t\tthis.renderedFeatureIds.delete(deletedId);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Updates\n\t\t\t\t\tfor (const updatedFeature of updated) {\n\t\t\t\t\t\tif (!updatedFeature?.id) throw new Error(\"Feature is not valid\");\n\n\t\t\t\t\t\tconst featureToUpdate = this.data().getFeatureById(\n\t\t\t\t\t\t\tString(updatedFeature.id),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif (!featureToUpdate) {\n\t\t\t\t\t\t\tthrow new Error(\"Feature could not be found by Google Maps API\");\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Remove all keys\n\t\t\t\t\t\tfeatureToUpdate.forEachProperty((_property, name) => {\n\t\t\t\t\t\t\tfeatureToUpdate.setProperty(name, undefined);\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\t// Update all keys\n\t\t\t\t\t\tObject.keys(updatedFeature.properties).forEach((property) => {\n\t\t\t\t\t\t\tfeatureToUpdate.setProperty(\n\t\t\t\t\t\t\t\tproperty,\n\t\t\t\t\t\t\t\tupdatedFeature.properties[property],\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tswitch (updatedFeature.geometry.type) {\n\t\t\t\t\t\t\tcase \"Point\": {\n\t\t\t\t\t\t\t\tconst coordinates = updatedFeature.geometry.coordinates;\n\t\t\t\t\t\t\t\tfeatureToUpdate.setGeometry(\n\t\t\t\t\t\t\t\t\tnew this._lib.Data.Point(\n\t\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\t),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcase \"LineString\": {\n\t\t\t\t\t\t\t\tconst coordinates = updatedFeature.geometry.coordinates;\n\t\t\t\t\t\t\t\tconst path: google.maps.LatLng[] = [];\n\t\t\t\t\t\t\t\tfor (let i = 0; i < coordinates.length; i++) {\n\t\t\t\t\t\t\t\t\tconst [lng, lat] = coordinates[i];\n\t\t\t\t\t\t\t\t\tpath.push(new this._lib.LatLng(lat, lng));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tfeatureToUpdate.setGeometry(\n\t\t\t\t\t\t\t\t\tnew this._lib.Data.LineString(path),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcase \"Polygon\": {\n\t\t\t\t\t\t\t\tconst coordinates = updatedFeature.geometry.coordinates;\n\t\t\t\t\t\t\t\tconst paths: google.maps.LatLng[][] = [];\n\t\t\t\t\t\t\t\tfor (let i = 0; i < coordinates.length; i++) {\n\t\t\t\t\t\t\t\t\tconst ring: google.maps.LatLng[] = [];\n\t\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\t\tconst [lng, lat] = coordinates[i][j];\n\t\t\t\t\t\t\t\t\t\tring.push(new this._lib.LatLng(lat, lng));\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tpaths.push(ring);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tfeatureToUpdate.setGeometry(new this._lib.Data.Polygon(paths));\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Creates\n\t\t\t\t\tfor (const createdFeature of created) {\n\t\t\t\t\t\tthis.renderedFeatureIds.add(String(createdFeature.id));\n\t\t\t\t\t\tthis.data().addGeoJson(createdFeature);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// First render: treat everything as a feature collection create\n\t\t\t\t\tconst features: GeoJSONStoreFeatures[] = [];\n\n\t\t\t\t\t// (If you want deletes/updates to matter before first render, you can filter here,\n\t\t\t\t\t// but usually first render is only creates.)\n\t\t\t\t\tfor (const feature of created) {\n\t\t\t\t\t\tthis.renderedFeatureIds.add(String(feature.id));\n\t\t\t\t\t\tfeatures.push(feature);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (features.length) {\n\t\t\t\t\t\tthis.data().addGeoJson({\n\t\t\t\t\t\t\ttype: \"FeatureCollection\",\n\t\t\t\t\t\t\tfeatures,\n\t\t\t\t\t\t} as GeoJsonObject);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\t// Put this on the class:\n\tprivate _rafState?: {\n\t\trafId: number | null;\n\t\tpending: {\n\t\t\tdeletedIds: string[];\n\t\t\tupdated: GeoJSONStoreFeatures[];\n\t\t\tcreated: GeoJSONStoreFeatures[];\n\t\t};\n\t\tdeletedSet: Set<string>;\n\t\tupdatedById: Map<string, GeoJSONStoreFeatures>;\n\t\tcreatedById: Map<string, GeoJSONStoreFeatures>;\n\t};\n\n\tprivate clearLayers() {\n\t\tif (this._hasRenderedFeatures) {\n\t\t\tthis.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.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\n\t\t// clean up any styles set on the default data layer\n\t\tif (this.data()) {\n\t\t\tthis.data().setStyle(null);\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","_forwardMapElementEvents","_isolatedData","_data","_cursor","_cursorStyleSheet","_lib","_map","_overlay","_mapEventElement","_markerClickListener","_markerMouseMoveListener","_pointerCaptureDownListener","_pointerCaptureUpListener","_clickEventListener","_mouseMoveEventListener","_readyCalled","_interactiveTargetSelector","join","_advancedMarkerElementTag","styling","renderedFeatureIds","Set","_rafState","lib","map","forwardMapElementEvents","isolatedData","_coordinatePrecision","coordinatePrecision","_proto","prototype","_createClass","getPointerTargetElement","target","Element","Node","parentElement","shouldCapturePointer","event","targetElement","closest","circlePath","cx","cy","r","d","register","callbacks","_this2","OverlayView","draw","onAdd","_this2$_currentModeCa","_currentModeCallbacks","onReady","setMap","onRemove","mapEventElement","getMapEventElement","isPrimary","setPointerCapture","pointerId","_unused","releasePointerCapture","hasPointerCapture","_unused2","addEventListener","drawEvent","getDrawEventFromEvent","onClick","onMouseMove","data","addListener","clickListener","_listeners","find","_ref","name","callback","mouseMoveListener","_ref2","Data","style","feature","Error","id","String","getId","has","mode","getProperty","gmGeometry","getGeometry","type","getType","properties","forEachProperty","value","property","calculatedStyles","geometry","coordinates","markerUrl","clickable","icon","url","scaledSize","markerWidth","markerHeight","Size","undefined","zIndex","path","pointWidth","strokeOpacity","pointOutlineOpacity","fillOpacity","pointOpacity","fillColor","pointColor","strokeColor","pointOutlineColor","strokeWeight","pointOutlineWidth","rotation","scale","lineStringOpacity","lineStringDash","_extends","lineStringColor","lineStringWidth","icons","color","offset","repeat","fixedRotation","polygonOutlineOpacity","polygonOutlineColor","polygonOutlineWidth","polygonFillOpacity","polygonFillColor","unregister","_this$_clickEventList","_this$_mouseMoveEvent","remove","removeEventListener","getMap","getLngLatFromEvent","_document$fullscreenE","bounds","getBounds","ne","getNorthEast","sw","getSouthWest","latLngBounds","LatLngBounds","mapCanvasRect","document","fullscreenElement","getDiv","getBoundingClientRect","screenCoord","Point","clientX","left","clientY","top","projection","getProjection","latLng","fromContainerPixelToLatLng","contains","lng","lat","eventType","querySelector","project","point","fromLatLngToContainerPixel","LatLng","x","y","unproject","setCursor","cursor","styleDiv","classList","add","createElement","innerHTML","getElementsByTagName","appendChild","setDoubleClickToZoom","enabled","setOptions","disableDoubleClickZoom","setDraggability","draggable","render","changes","_this3","getStyle","setStyle","rafId","pending","deletedIds","updated","created","deletedSet","updatedById","Map","createdById","_step","_iterator","_createForOfIteratorHelperLoose","done","_iterator2","_step2","set","_step3","_iterator3","requestAnimationFrame","Array","from","values","clear","_hasRenderedFeatures","_iterator4","_step4","deletedId","featureToDelete","getFeatureById","_step5","_loop","updatedFeature","featureToUpdate","_property","setProperty","Object","keys","forEach","setGeometry","i","length","_coordinates$i","push","LineString","paths","ring","j","_coordinates2$_i$j","Polygon","_iterator5","_iterator6","_step6","createdFeature","addGeoJson","_step7","features","_iterator7","clearLayers","_this4","onClear","getCoordinatePrecision","key","get","_this$renderedFeature","Boolean","size","TerraDrawExtend","TerraDrawBaseAdapter"],"mappings":"g+CAcC,SAAAA,GAEA,SAAAC,EACCC,GAKqC,IAAAC,EAc/B,OAZNA,EAAAH,EAAAI,KAAAC,KAAMH,IAAQC,MAePG,0BAAoC,EAAKH,EACzCI,eAAyB,EAAKJ,EAC9BK,WAAKL,EAAAA,EACLM,aAAO,EAAAN,EACPO,uBAAiB,EAAAP,EACjBQ,UAAI,EAAAR,EACJS,UAAI,EAAAT,EACJU,cAAQV,EAAAA,EAERW,wBAAgBX,EAChBY,0BAAoB,EAAAZ,EACpBa,8BAAwBb,EAAAA,EACxBc,iCAA2Bd,EAAAA,EAG3Be,+BAAyBf,EAAAA,EAGzBgB,yBAAmBhB,EAAAA,EACnBiB,6BAAuB,EAAAjB,EACvBkB,cAAe,EAAKlB,EAEpBmB,2BAA6B,CACpC,kBACA,IACA,SACA,QACA,SACA,WACA,UACA,kBACA,gBACA,uBACA,4BACCC,KAAK,MAAKpB,EAEJqB,0BAA4B,sBAAqBrB,EAgNjDsB,aAAOtB,EAAAA,EAkXPuB,mBAAqD,IAAIC,IAAKxB,EA0L9DyB,eA9yBPzB,EAA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