From 9cec19bf1139751cd8233378ef071c913b6c172f Mon Sep 17 00:00:00 2001 From: rug Date: Thu, 15 Feb 2024 16:44:32 +0100 Subject: [PATCH 01/12] Moving Global to root --- src/{Providers/Maps/Google => }/Global.d.ts | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{Providers/Maps/Google => }/Global.d.ts (100%) diff --git a/src/Providers/Maps/Google/Global.d.ts b/src/Global.d.ts similarity index 100% rename from src/Providers/Maps/Google/Global.d.ts rename to src/Global.d.ts From c9e56781cdc61979d90bdf751a9d618e4f36e97c Mon Sep 17 00:00:00 2001 From: rug Date: Thu, 15 Feb 2024 18:34:02 +0100 Subject: [PATCH 02/12] Adding a new type for Google Advanced format --- src/Global.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Global.d.ts b/src/Global.d.ts index 37b02ee0..38f41db0 100644 --- a/src/Global.d.ts +++ b/src/Global.d.ts @@ -24,5 +24,6 @@ declare global { type GoogleMapsMarkerClustererOptions = OriginalMarkerClustererOptions; type GoogleMapsClusterRenderer = OriginalRenderer; type GoogleMapsSuperClusterAlgorithm = OriginalSuperClusterAlgorithm; + type GoogleAdvancedFormatObj = {JSON, mapEvents: string[]}; } window.GMCB = window.GMCB || {}; From 3a0c14d2b23ab8d355696413b9bb701b76829249 Mon Sep 17 00:00:00 2001 From: rug Date: Thu, 15 Feb 2024 18:35:15 +0100 Subject: [PATCH 03/12] Using new advanced format type --- src/Providers/Maps/Google/OSMap/OSMap.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/Providers/Maps/Google/OSMap/OSMap.ts b/src/Providers/Maps/Google/OSMap/OSMap.ts index 12471995..23b392f4 100644 --- a/src/Providers/Maps/Google/OSMap/OSMap.ts +++ b/src/Providers/Maps/Google/OSMap/OSMap.ts @@ -7,8 +7,7 @@ namespace Provider.Maps.Google.OSMap { implements IMapGoogle { private _addedEvents: Array; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - private _advancedFormatObj: any; + private _advancedFormatObj: GoogleAdvancedFormatObj; private _fBuilder: Feature.FeatureBuilder; private _gZoomChangeListener: google.maps.MapsEventListener; private _scriptCallback: OSFramework.Maps.Callbacks.Generic; @@ -134,7 +133,9 @@ namespace Provider.Maps.Google.OSMap { // Make sure the center has a default value before the conversion of the location to coordinates this.config.center = OSFramework.Maps.Helper.Constants.defaultMapCenter; // Take care of the advancedFormat options which can override the previous configuration - this._advancedFormatObj = OSFramework.Maps.Helper.JsonFormatter(this.config.advancedFormat); + this._advancedFormatObj = OSFramework.Maps.Helper.JsonFormatter( + this.config.advancedFormat + ) as unknown as GoogleAdvancedFormatObj; return this.config.getProviderConfig(); } @@ -350,13 +351,9 @@ namespace Provider.Maps.Google.OSMap { styles: GetStyleByStyleId(propertyValue as number), }); case OSFramework.Maps.Enum.OS_Config_Map.advancedFormat: - // eslint-disable-next-line @typescript-eslint/no-explicit-any - propertyValue = OSFramework.Maps.Helper.JsonFormatter(propertyValue as string); + propertyValue = OSFramework.Maps.Helper.JsonFormatter(propertyValue as string) as unknown; // Make sure the MapEvents that are associated in the advancedFormat get updated - this._setMapEvents( - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (propertyValue as any).mapEvents as string[] - ); + this._setMapEvents((propertyValue as GoogleAdvancedFormatObj).mapEvents); return this._provider.setOptions(propertyValue); case OSFramework.Maps.Enum.OS_Config_Map.showTraffic: return this.features.trafficLayer.setState(propertyValue as boolean); From 6981cfd20b651f811367efa57844058205c95327 Mon Sep 17 00:00:00 2001 From: rug Date: Thu, 15 Feb 2024 18:39:18 +0100 Subject: [PATCH 04/12] Using unknown instead of any --- .../DrawingTools/DrawBasicShapeConfig.ts | 3 +-- .../DrawingTools/DrawFilledShapeConfig.ts | 3 +-- .../DrawingTools/DrawMarkerConfig.ts | 3 +-- .../DrawingTools/DrawingToolsConfig.ts | 3 +-- .../Configuration/FileLayer/FileLayerConfigs.ts | 3 +-- .../HeatmapLayer/HeatmapLayerConfigs.ts | 3 +-- .../Configuration/Marker/GoogleMarkerConfig.ts | 3 +-- .../Google/Configuration/OSMap/GoogleMapConfig.ts | 3 +-- .../Configuration/OSMap/GoogleStaticMapConfig.ts | 3 +-- .../Maps/Google/DrawingTools/AbstractDrawShape.ts | 3 +-- .../Google/DrawingTools/AbstractProviderTool.ts | 11 ++--------- .../Maps/Google/DrawingTools/DrawCircle.ts | 3 +-- .../Maps/Google/DrawingTools/DrawMarker.ts | 12 ++++-------- .../Maps/Google/DrawingTools/DrawingTools.ts | 12 +++++------- src/Providers/Maps/Google/FileLayer/FileLayer.ts | 9 ++++----- .../Maps/Google/HeatmapLayer/HeatmapLayer.ts | 15 +++++++-------- .../Configuration/DrawingTools/DrawConfig.ts | 5 ++--- .../DrawingTools/DrawingToolsConfig.ts | 3 +-- .../OSMap/LeafletMapConfiguration.ts | 3 +-- .../Configuration/Shape/RectangleShapeConfig.ts | 3 +-- .../Leaflet/DrawingTools/AbstractProviderTool.ts | 3 +-- .../Maps/Leaflet/DrawingTools/DrawingTools.ts | 3 +-- 22 files changed, 40 insertions(+), 72 deletions(-) diff --git a/src/Providers/Maps/Google/Configuration/DrawingTools/DrawBasicShapeConfig.ts b/src/Providers/Maps/Google/Configuration/DrawingTools/DrawBasicShapeConfig.ts index 32fb2ba4..f71cb083 100644 --- a/src/Providers/Maps/Google/Configuration/DrawingTools/DrawBasicShapeConfig.ts +++ b/src/Providers/Maps/Google/Configuration/DrawingTools/DrawBasicShapeConfig.ts @@ -13,8 +13,7 @@ namespace Provider.Maps.Google.Configuration.DrawingTools { // super(config); // } - // eslint-disable-next-line @typescript-eslint/no-explicit-any - public getProviderConfig(): any { + public getProviderConfig(): unknown[] { const configs = super.getProviderConfig(); // eslint-disable-next-line prefer-const let provider = { diff --git a/src/Providers/Maps/Google/Configuration/DrawingTools/DrawFilledShapeConfig.ts b/src/Providers/Maps/Google/Configuration/DrawingTools/DrawFilledShapeConfig.ts index 3fc14278..1db2417a 100644 --- a/src/Providers/Maps/Google/Configuration/DrawingTools/DrawFilledShapeConfig.ts +++ b/src/Providers/Maps/Google/Configuration/DrawingTools/DrawFilledShapeConfig.ts @@ -11,8 +11,7 @@ namespace Provider.Maps.Google.Configuration.DrawingTools { // super(config); // } - // eslint-disable-next-line @typescript-eslint/no-explicit-any - public getProviderConfig(): any { + public getProviderConfig(): unknown[] { const configs = super.getProviderConfig(); // eslint-disable-next-line prefer-const let provider = { diff --git a/src/Providers/Maps/Google/Configuration/DrawingTools/DrawMarkerConfig.ts b/src/Providers/Maps/Google/Configuration/DrawingTools/DrawMarkerConfig.ts index 35cd88d7..6c7f1fc1 100644 --- a/src/Providers/Maps/Google/Configuration/DrawingTools/DrawMarkerConfig.ts +++ b/src/Providers/Maps/Google/Configuration/DrawingTools/DrawMarkerConfig.ts @@ -10,8 +10,7 @@ namespace Provider.Maps.Google.Configuration.DrawingTools { // super(config); // } - // eslint-disable-next-line @typescript-eslint/no-explicit-any - public getProviderConfig(): any { + public getProviderConfig(): unknown[] { const provider = super.getProviderConfig(); provider.icon = this.iconUrl; diff --git a/src/Providers/Maps/Google/Configuration/DrawingTools/DrawingToolsConfig.ts b/src/Providers/Maps/Google/Configuration/DrawingTools/DrawingToolsConfig.ts index a87a5489..6f2b205a 100644 --- a/src/Providers/Maps/Google/Configuration/DrawingTools/DrawingToolsConfig.ts +++ b/src/Providers/Maps/Google/Configuration/DrawingTools/DrawingToolsConfig.ts @@ -14,8 +14,7 @@ namespace Provider.Maps.Google.Configuration.DrawingTools { // super(config); // } - // eslint-disable-next-line @typescript-eslint/no-explicit-any - public getProviderConfig(): any { + public getProviderConfig(): unknown { return { position: this.position, }; diff --git a/src/Providers/Maps/Google/Configuration/FileLayer/FileLayerConfigs.ts b/src/Providers/Maps/Google/Configuration/FileLayer/FileLayerConfigs.ts index 2d51c7bd..d5bfcbe6 100644 --- a/src/Providers/Maps/Google/Configuration/FileLayer/FileLayerConfigs.ts +++ b/src/Providers/Maps/Google/Configuration/FileLayer/FileLayerConfigs.ts @@ -15,8 +15,7 @@ namespace Provider.Maps.Google.Configuration.FileLayer { // super(config); // } - // eslint-disable-next-line @typescript-eslint/no-explicit-any - public getProviderConfig(): any { + public getProviderConfig(): unknown { // eslint-disable-next-line prefer-const let provider = { clickable: true, diff --git a/src/Providers/Maps/Google/Configuration/HeatmapLayer/HeatmapLayerConfigs.ts b/src/Providers/Maps/Google/Configuration/HeatmapLayer/HeatmapLayerConfigs.ts index 9a942709..157a8e59 100644 --- a/src/Providers/Maps/Google/Configuration/HeatmapLayer/HeatmapLayerConfigs.ts +++ b/src/Providers/Maps/Google/Configuration/HeatmapLayer/HeatmapLayerConfigs.ts @@ -18,8 +18,7 @@ namespace Provider.Maps.Google.Configuration.HeatmapLayer { // super(config); // } - // eslint-disable-next-line @typescript-eslint/no-explicit-any - public getProviderConfig(): any { + public getProviderConfig(): unknown { // eslint-disable-next-line prefer-const let provider = { points: this.points, diff --git a/src/Providers/Maps/Google/Configuration/Marker/GoogleMarkerConfig.ts b/src/Providers/Maps/Google/Configuration/Marker/GoogleMarkerConfig.ts index 42fcdb2e..45d4954e 100644 --- a/src/Providers/Maps/Google/Configuration/Marker/GoogleMarkerConfig.ts +++ b/src/Providers/Maps/Google/Configuration/Marker/GoogleMarkerConfig.ts @@ -19,8 +19,7 @@ namespace Provider.Maps.Google.Configuration.Marker { // super(config); // } - // eslint-disable-next-line @typescript-eslint/no-explicit-any - public getProviderConfig(): any { + public getProviderConfig(): unknown { const provider = { draggable: this.allowDrag, icon: this.iconUrl, diff --git a/src/Providers/Maps/Google/Configuration/OSMap/GoogleMapConfig.ts b/src/Providers/Maps/Google/Configuration/OSMap/GoogleMapConfig.ts index 7463d024..88b44705 100644 --- a/src/Providers/Maps/Google/Configuration/OSMap/GoogleMapConfig.ts +++ b/src/Providers/Maps/Google/Configuration/OSMap/GoogleMapConfig.ts @@ -23,8 +23,7 @@ namespace Provider.Maps.Google.Configuration.OSMap { // super(config); // } - // eslint-disable-next-line @typescript-eslint/no-explicit-any - public getProviderConfig(): any { + public getProviderConfig(): unknown { const provider = { center: this.center, zoom: this.zoom, diff --git a/src/Providers/Maps/Google/Configuration/OSMap/GoogleStaticMapConfig.ts b/src/Providers/Maps/Google/Configuration/OSMap/GoogleStaticMapConfig.ts index 75c62451..0bc11a7d 100644 --- a/src/Providers/Maps/Google/Configuration/OSMap/GoogleStaticMapConfig.ts +++ b/src/Providers/Maps/Google/Configuration/OSMap/GoogleStaticMapConfig.ts @@ -16,8 +16,7 @@ namespace Provider.Maps.Google.Configuration.OSMap { // super(config); // } - // eslint-disable-next-line @typescript-eslint/no-explicit-any - public getProviderConfig(): any { + public getProviderConfig(): unknown { const provider = { center: this.center, zoom: this.zoom, diff --git a/src/Providers/Maps/Google/DrawingTools/AbstractDrawShape.ts b/src/Providers/Maps/Google/DrawingTools/AbstractDrawShape.ts index d1b783f2..f75db4f6 100644 --- a/src/Providers/Maps/Google/DrawingTools/AbstractDrawShape.ts +++ b/src/Providers/Maps/Google/DrawingTools/AbstractDrawShape.ts @@ -65,8 +65,7 @@ namespace Provider.Maps.Google.DrawingTools { super.build(); } - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars - public changeProperty(propertyName: string, value: any): void { + public changeProperty(propertyName: string, value: unknown): void { const propValue = OSFramework.Maps.Enum.OS_Config_Shape[propertyName]; super.changeProperty(propertyName, value); if (this.drawingTools.isReady) { diff --git a/src/Providers/Maps/Google/DrawingTools/AbstractProviderTool.ts b/src/Providers/Maps/Google/DrawingTools/AbstractProviderTool.ts index 23a22ee1..d8561b31 100644 --- a/src/Providers/Maps/Google/DrawingTools/AbstractProviderTool.ts +++ b/src/Providers/Maps/Google/DrawingTools/AbstractProviderTool.ts @@ -78,8 +78,7 @@ namespace Provider.Maps.Google.DrawingTools { this.finishBuild(); } - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars - public changeProperty(propertyName: string, value: any): void { + public changeProperty(propertyName: string, value: unknown): void { const propValue = OSFramework.Maps.Enum.OS_Config_Shape[propertyName]; super.changeProperty(propertyName, value); if (this.drawingTools.isReady) { @@ -107,13 +106,7 @@ namespace Provider.Maps.Google.DrawingTools { * @param element new element provider (shape or marker). The new element results from the marker or shape complete events * @param configs configs to create the new element (on the osframework) */ - protected abstract createElement( - uniqueId: string, - // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types - element: any, - // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types - configs: any - ): void; + protected abstract createElement(uniqueId: string, element: unknown, configs: unknown): void; protected abstract getCoordinates(): string; protected abstract getLocation(): string | string[]; diff --git a/src/Providers/Maps/Google/DrawingTools/DrawCircle.ts b/src/Providers/Maps/Google/DrawingTools/DrawCircle.ts index e2f5a02d..f94e675e 100644 --- a/src/Providers/Maps/Google/DrawingTools/DrawCircle.ts +++ b/src/Providers/Maps/Google/DrawingTools/DrawCircle.ts @@ -22,8 +22,7 @@ namespace Provider.Maps.Google.DrawingTools { private _createConfigsElement( shape: google.maps.Circle, configs: Configuration.Shape.CircleShapeConfig - // eslint-disable-next-line @typescript-eslint/no-explicit-any - ): any { + ): unknown { const providerCenter = shape.getCenter(); const center = `${providerCenter.lat()},${providerCenter.lng()}`; const radius = shape.getRadius(); diff --git a/src/Providers/Maps/Google/DrawingTools/DrawMarker.ts b/src/Providers/Maps/Google/DrawingTools/DrawMarker.ts index b511ab02..559c9d7f 100644 --- a/src/Providers/Maps/Google/DrawingTools/DrawMarker.ts +++ b/src/Providers/Maps/Google/DrawingTools/DrawMarker.ts @@ -12,8 +12,7 @@ namespace Provider.Maps.Google.DrawingTools { drawingTools: OSFramework.Maps.DrawingTools.IDrawingTools, drawingToolsId: string, type: string, - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any - configs: any + configs: unknown ) { super(map, drawingTools, drawingToolsId, type, new Configuration.DrawingTools.DrawMarkerConfig(configs)); } @@ -103,15 +102,12 @@ namespace Provider.Maps.Google.DrawingTools { super.build(); } - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars - public changeProperty(propertyName: string, value: any): void { + public changeProperty(propertyName: string, value: unknown): void { const propValue = OSFramework.Maps.Enum.OS_Config_Marker[propertyName]; super.changeProperty(propertyName, value); if (this.drawingTools.isReady) { - switch (propValue) { - case OSFramework.Maps.Enum.OS_Config_Marker.iconUrl: - this.options = { icon: value }; - return; + if (propValue === OSFramework.Maps.Enum.OS_Config_Marker.iconUrl) { + this.options = { icon: value as string }; } } } diff --git a/src/Providers/Maps/Google/DrawingTools/DrawingTools.ts b/src/Providers/Maps/Google/DrawingTools/DrawingTools.ts index ac840bad..9c84b8aa 100644 --- a/src/Providers/Maps/Google/DrawingTools/DrawingTools.ts +++ b/src/Providers/Maps/Google/DrawingTools/DrawingTools.ts @@ -88,16 +88,14 @@ namespace Provider.Maps.Google.DrawingTools { } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars - public changeProperty(propertyName: string, value: any): void { + public changeProperty(propertyName: string, value: unknown): void { const propValue = OSFramework.Maps.Enum.OS_Config_DrawingTools[propertyName]; super.changeProperty(propertyName, value); if (this.isReady) { - switch (propValue) { - case OSFramework.Maps.Enum.OS_Config_DrawingTools.position: - this.controlOptions = { - position: parseInt(google.maps.ControlPosition[value]), - }; - return; + if (propValue === OSFramework.Maps.Enum.OS_Config_DrawingTools.position) { + this.controlOptions = { + position: parseInt(google.maps.ControlPosition[value as number]), + }; } } } diff --git a/src/Providers/Maps/Google/FileLayer/FileLayer.ts b/src/Providers/Maps/Google/FileLayer/FileLayer.ts index cb927527..220f254f 100644 --- a/src/Providers/Maps/Google/FileLayer/FileLayer.ts +++ b/src/Providers/Maps/Google/FileLayer/FileLayer.ts @@ -57,23 +57,22 @@ namespace Provider.Maps.Google.FileLayer { this.finishBuild(); } - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars - public changeProperty(propertyName: string, value: any): void { + public changeProperty(propertyName: string, value: unknown): void { const propValue = OSFramework.Maps.Enum.OS_Config_FileLayer[propertyName]; super.changeProperty(propertyName, value); if (this.isReady) { switch (propValue) { case OSFramework.Maps.Enum.OS_Config_FileLayer.layerUrl: return this.provider.setOptions({ - url: value, + url: value as string, }); case OSFramework.Maps.Enum.OS_Config_FileLayer.preserveViewport: return this.provider.setOptions({ - preserveViewport: value, + preserveViewport: value as boolean, }); case OSFramework.Maps.Enum.OS_Config_FileLayer.suppressPopups: return this.provider.setOptions({ - suppressInfoWindows: value, + suppressInfoWindows: value as boolean, }); } } diff --git a/src/Providers/Maps/Google/HeatmapLayer/HeatmapLayer.ts b/src/Providers/Maps/Google/HeatmapLayer/HeatmapLayer.ts index 9652a0e5..f973089c 100644 --- a/src/Providers/Maps/Google/HeatmapLayer/HeatmapLayer.ts +++ b/src/Providers/Maps/Google/HeatmapLayer/HeatmapLayer.ts @@ -54,33 +54,32 @@ namespace Provider.Maps.Google.HeatmapLayer { this.finishBuild(); } - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars - public changeProperty(propertyName: string, value: any): void { + public changeProperty(propertyName: string, value: unknown): void { const propValue = OSFramework.Maps.Enum.OS_Config_HeatmapLayer[propertyName]; super.changeProperty(propertyName, value); if (this.isReady) { switch (propValue) { case OSFramework.Maps.Enum.OS_Config_HeatmapLayer.points: - return this.provider.setData(this._pointsToData(JSON.parse(value))); + return this.provider.setData(this._pointsToData(JSON.parse(value as string))); case OSFramework.Maps.Enum.OS_Config_HeatmapLayer.dissipateOnZoom: return this.provider.setOptions({ - dissipating: value, + dissipating: value as boolean, }); case OSFramework.Maps.Enum.OS_Config_HeatmapLayer.gradient: return this.provider.setOptions({ - gradient: this._gradientColors(JSON.parse(value)), + gradient: this._gradientColors(JSON.parse(value as string)), }); case OSFramework.Maps.Enum.OS_Config_HeatmapLayer.maxIntensity: return this.provider.setOptions({ - maxIntensity: value, + maxIntensity: value as number, }); case OSFramework.Maps.Enum.OS_Config_HeatmapLayer.opacity: return this.provider.setOptions({ - opacity: value, + opacity: value as number, }); case OSFramework.Maps.Enum.OS_Config_HeatmapLayer.radius: return this.provider.setOptions({ - radius: value, + radius: value as number, }); } } diff --git a/src/Providers/Maps/Leaflet/Configuration/DrawingTools/DrawConfig.ts b/src/Providers/Maps/Leaflet/Configuration/DrawingTools/DrawConfig.ts index dae27024..39f86476 100644 --- a/src/Providers/Maps/Leaflet/Configuration/DrawingTools/DrawConfig.ts +++ b/src/Providers/Maps/Leaflet/Configuration/DrawingTools/DrawConfig.ts @@ -14,8 +14,7 @@ namespace Provider.Maps.Leaflet.Configuration.DrawingTools { // super(config); // } - // eslint-disable-next-line @typescript-eslint/no-explicit-any - public getProviderConfig(): any { + public getProviderConfig(): unknown[] { // eslint-disable-next-line prefer-const let provider = { repeatMode: false, // allows to create drawing shapes without unselect the tool @@ -31,7 +30,7 @@ namespace Provider.Maps.Leaflet.Configuration.DrawingTools { if (provider[key] === undefined) delete provider[key]; }); - return provider; + return provider as unknown as unknown[]; } } } diff --git a/src/Providers/Maps/Leaflet/Configuration/DrawingTools/DrawingToolsConfig.ts b/src/Providers/Maps/Leaflet/Configuration/DrawingTools/DrawingToolsConfig.ts index 2730ad34..935ed3fa 100644 --- a/src/Providers/Maps/Leaflet/Configuration/DrawingTools/DrawingToolsConfig.ts +++ b/src/Providers/Maps/Leaflet/Configuration/DrawingTools/DrawingToolsConfig.ts @@ -9,8 +9,7 @@ namespace Provider.Maps.Leaflet.Configuration.DrawingTools { public position: string; public uniqueId: string; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - public getProviderConfig(): any { + public getProviderConfig(): unknown { return { position: this.position, }; diff --git a/src/Providers/Maps/Leaflet/Configuration/OSMap/LeafletMapConfiguration.ts b/src/Providers/Maps/Leaflet/Configuration/OSMap/LeafletMapConfiguration.ts index 9a1b95ac..9676aa2b 100644 --- a/src/Providers/Maps/Leaflet/Configuration/OSMap/LeafletMapConfiguration.ts +++ b/src/Providers/Maps/Leaflet/Configuration/OSMap/LeafletMapConfiguration.ts @@ -17,8 +17,7 @@ namespace Provider.Maps.Leaflet.Configuration.OSMap { // super(config); // } - // eslint-disable-next-line @typescript-eslint/no-explicit-any - public getProviderConfig(): any { + public getProviderConfig(): unknown { // eslint-disable-next-line prefer-const let provider = { center: this.center, diff --git a/src/Providers/Maps/Leaflet/Configuration/Shape/RectangleShapeConfig.ts b/src/Providers/Maps/Leaflet/Configuration/Shape/RectangleShapeConfig.ts index 43bbf0da..12cca832 100644 --- a/src/Providers/Maps/Leaflet/Configuration/Shape/RectangleShapeConfig.ts +++ b/src/Providers/Maps/Leaflet/Configuration/Shape/RectangleShapeConfig.ts @@ -12,8 +12,7 @@ namespace Provider.Maps.Leaflet.Configuration.Shape { // super(config); // } - // eslint-disable-next-line @typescript-eslint/no-explicit-any - public getProviderConfig(): any { + public getProviderConfig(): unknown { const provider = super.getProviderConfig(); // Rectangle doesn't have locations on its configurations diff --git a/src/Providers/Maps/Leaflet/DrawingTools/AbstractProviderTool.ts b/src/Providers/Maps/Leaflet/DrawingTools/AbstractProviderTool.ts index 3199d3eb..4d8ce504 100644 --- a/src/Providers/Maps/Leaflet/DrawingTools/AbstractProviderTool.ts +++ b/src/Providers/Maps/Leaflet/DrawingTools/AbstractProviderTool.ts @@ -65,8 +65,7 @@ namespace Provider.Maps.Leaflet.DrawingTools { // Adds the completedElement (completemarker, completepolyline, etc.) event listeners to the correspondent element. // The new handlers will create the shape/markers elements and remove the overlay created by the drawing tool on the map - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any - public addCompletedEvent(event: any): void { + public addCompletedEvent(event: unknown): void { this._addCompletedEventHandler(event); } diff --git a/src/Providers/Maps/Leaflet/DrawingTools/DrawingTools.ts b/src/Providers/Maps/Leaflet/DrawingTools/DrawingTools.ts index 0a551c2f..bb26b8ac 100644 --- a/src/Providers/Maps/Leaflet/DrawingTools/DrawingTools.ts +++ b/src/Providers/Maps/Leaflet/DrawingTools/DrawingTools.ts @@ -126,8 +126,7 @@ namespace Provider.Maps.Leaflet.DrawingTools { } // We don't have the types for the drawingTools features - // eslint-disable-next-line @typescript-eslint/no-explicit-any - protected get controlOptions(): any { + protected get controlOptions(): unknown[] { // eslint-disable-next-line @typescript-eslint/ban-ts-comment //@ts-ignore return this._provider.get('drawingControlOptions'); From 76250a99a49d531a57269c0fcc592f212e73b1a7 Mon Sep 17 00:00:00 2001 From: rug Date: Thu, 15 Feb 2024 18:43:38 +0100 Subject: [PATCH 05/12] Extending Class coordinates type --- src/OSFramework/Maps/OSStructures/OSMap.Coordinates.ts | 6 ++---- src/OutSystems/Maps/MapAPI/ShapeManager.ts | 4 ++-- src/Providers/Maps/Google/Features/Center.ts | 2 +- src/Providers/Maps/Google/Features/Offset.ts | 2 +- src/Providers/Maps/Google/Marker/Marker.ts | 8 ++++---- src/Providers/Maps/Google/Shape/AbstractPolyshape.ts | 4 ++-- src/Providers/Maps/Google/Shape/Polyline.ts | 2 +- src/Providers/Maps/Google/Shape/Rectangle.ts | 4 ++-- .../Maps/Google/SharedComponents/MapsAndSearchPlaces.ts | 4 ++-- src/Providers/Maps/Leaflet/Features/Center.ts | 2 +- src/Providers/Maps/Leaflet/Features/Directions.ts | 2 +- src/Providers/Maps/Leaflet/Features/Offset.ts | 4 +++- src/Providers/Maps/Leaflet/Marker/Marker.ts | 6 +++--- src/Providers/Maps/Leaflet/Shape/AbstractPolyshape.ts | 2 +- src/Providers/Maps/Leaflet/Shape/Polygon.ts | 2 +- src/Providers/Maps/Leaflet/Shape/Polyline.ts | 2 +- src/Providers/Maps/Leaflet/Shape/Rectangle.ts | 4 ++-- 17 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/OSFramework/Maps/OSStructures/OSMap.Coordinates.ts b/src/OSFramework/Maps/OSStructures/OSMap.Coordinates.ts index 5f188fc5..5f79a065 100644 --- a/src/OSFramework/Maps/OSStructures/OSMap.Coordinates.ts +++ b/src/OSFramework/Maps/OSStructures/OSMap.Coordinates.ts @@ -1,10 +1,8 @@ // eslint-disable-next-line @typescript-eslint/no-unused-vars namespace OSFramework.Maps.OSStructures.OSMap { export class Coordinates { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - public lat: any; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - public lng: any; + public lat: number | (() => number); + public lng: number | (() => number); } // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/src/OutSystems/Maps/MapAPI/ShapeManager.ts b/src/OutSystems/Maps/MapAPI/ShapeManager.ts index e5ed9006..30830d75 100644 --- a/src/OutSystems/Maps/MapAPI/ShapeManager.ts +++ b/src/OutSystems/Maps/MapAPI/ShapeManager.ts @@ -55,8 +55,8 @@ namespace OutSystems.Maps.MapAPI.ShapeManager { const properties = new OSFramework.Maps.OSStructures.API.CircleProperties(); if (shape.type === OSFramework.Maps.Enum.ShapeType.Circle) { properties.Center = { - Lat: shape.providerCenter.lat, - Lng: shape.providerCenter.lng, + Lat: shape.providerCenter.lat as number, + Lng: shape.providerCenter.lng as number, }; properties.Radius = shape.providerRadius; } else { diff --git a/src/Providers/Maps/Google/Features/Center.ts b/src/Providers/Maps/Google/Features/Center.ts index be706a62..510c51cf 100644 --- a/src/Providers/Maps/Google/Features/Center.ts +++ b/src/Providers/Maps/Google/Features/Center.ts @@ -53,7 +53,7 @@ namespace Provider.Maps.Google.Feature { } public refreshCenter(value: OSFramework.Maps.OSStructures.OSMap.Coordinates): void { - const coordinates = new google.maps.LatLng(value.lat, value.lng); + const coordinates = new google.maps.LatLng(value.lat as number, value.lng as number); this._map.provider.setCenter(coordinates); this._currentCenter = coordinates.toJSON(); } diff --git a/src/Providers/Maps/Google/Features/Offset.ts b/src/Providers/Maps/Google/Features/Offset.ts index 90d8bcdc..20daf67c 100644 --- a/src/Providers/Maps/Google/Features/Offset.ts +++ b/src/Providers/Maps/Google/Features/Offset.ts @@ -22,7 +22,7 @@ namespace Provider.Maps.Google.Feature { offsetX: value.offsetX || 0, offsetY: value.offsetY || 0, }; - this._map.provider.panTo(this._map.features.center.getCurrentCenter()); + this._map.provider.panTo(this._map.features.center.getCurrentCenter() as google.maps.LatLngAltitudeLiteral); this._map.provider.panBy(this._offset.offsetX, this._offset.offsetY); } } diff --git a/src/Providers/Maps/Google/Marker/Marker.ts b/src/Providers/Maps/Google/Marker/Marker.ts index 7b893b88..4143d390 100644 --- a/src/Providers/Maps/Google/Marker/Marker.ts +++ b/src/Providers/Maps/Google/Marker/Marker.ts @@ -82,8 +82,8 @@ namespace Provider.Maps.Google.Marker { Helper.Conversions.ConvertToCoordinates(this.config.location) .then((response) => { markerOptions.position = { - lat: response.lat, - lng: response.lng, + lat: response.lat as number, + lng: response.lng as number, }; resolve(markerOptions); }) @@ -210,8 +210,8 @@ namespace Provider.Maps.Google.Marker { Helper.Conversions.ConvertToCoordinates(propertyValue as string) .then((response) => { this._provider.setPosition({ - lat: response.lat, - lng: response.lng, + lat: response.lat as number, + lng: response.lng as number, }); this.map.refresh(); }) diff --git a/src/Providers/Maps/Google/Shape/AbstractPolyshape.ts b/src/Providers/Maps/Google/Shape/AbstractPolyshape.ts index 6e0a0d64..943666c0 100644 --- a/src/Providers/Maps/Google/Shape/AbstractPolyshape.ts +++ b/src/Providers/Maps/Google/Shape/AbstractPolyshape.ts @@ -57,13 +57,13 @@ namespace Provider.Maps.Google.Shape { } protected _setProviderPath(path: Array): void { - this._provider.setPath(path); + this._provider.setPath(path as google.maps.LatLngLiteral[]); } public get providerBounds(): google.maps.LatLngBounds { const bounds = new google.maps.LatLngBounds(); this.providerPath.forEach(function (item) { - bounds.extend(new google.maps.LatLng(item.lat, item.lng)); + bounds.extend(new google.maps.LatLng(item.lat as number, item.lng as number)); }); return bounds; } diff --git a/src/Providers/Maps/Google/Shape/Polyline.ts b/src/Providers/Maps/Google/Shape/Polyline.ts index 47e11b2c..0cbac60f 100644 --- a/src/Providers/Maps/Google/Shape/Polyline.ts +++ b/src/Providers/Maps/Google/Shape/Polyline.ts @@ -18,7 +18,7 @@ namespace Provider.Maps.Google.Shape { protected _createProvider(path: Array): google.maps.Polyline { return new google.maps.Polyline({ map: this.map.provider, - path: path, + path: path as google.maps.LatLngAltitudeLiteral[], ...(this.getProviderConfig() as Configuration.Shape.IShapeProviderConfig), }); } diff --git a/src/Providers/Maps/Google/Shape/Rectangle.ts b/src/Providers/Maps/Google/Shape/Rectangle.ts index d722d83e..95c44b8e 100644 --- a/src/Providers/Maps/Google/Shape/Rectangle.ts +++ b/src/Providers/Maps/Google/Shape/Rectangle.ts @@ -58,12 +58,12 @@ namespace Provider.Maps.Google.Shape { switch (cd) { case 'north': case 'south': - newBounds[cd] = response.lat; + newBounds[cd] = response.lat as number; break; case 'east': case 'west': default: - newBounds[cd] = response.lng; + newBounds[cd] = response.lng as number; break; } if (boundsLength === 4) { diff --git a/src/Providers/Maps/Google/SharedComponents/MapsAndSearchPlaces.ts b/src/Providers/Maps/Google/SharedComponents/MapsAndSearchPlaces.ts index fd07f0c0..9735c232 100644 --- a/src/Providers/Maps/Google/SharedComponents/MapsAndSearchPlaces.ts +++ b/src/Providers/Maps/Google/SharedComponents/MapsAndSearchPlaces.ts @@ -112,13 +112,13 @@ namespace Provider.Maps.Google.SharedComponents { case 'north': case 'south': // If the currenct cardinalDirection is north or south, just use the latitude from the response - finalBounds[cd] = response.lat; + finalBounds[cd] = response.lat as number; break; case 'east': case 'west': default: // If the currenct cardinalDirection is east or west use the longitude from the response - finalBounds[cd] = response.lng; + finalBounds[cd] = response.lng as number; break; } // Because this is a cycle we need to ensure if we already have all the cardinal directions to resolve the promise diff --git a/src/Providers/Maps/Leaflet/Features/Center.ts b/src/Providers/Maps/Leaflet/Features/Center.ts index 53f2a9b8..2eaad53d 100644 --- a/src/Providers/Maps/Leaflet/Features/Center.ts +++ b/src/Providers/Maps/Leaflet/Features/Center.ts @@ -53,7 +53,7 @@ namespace Provider.Maps.Leaflet.Feature { } public refreshCenter(value: OSFramework.Maps.OSStructures.OSMap.Coordinates): void { - const coordinates = new L.LatLng(value.lat, value.lng); + const coordinates = new L.LatLng(value.lat as number, value.lng as number); this._map.provider.setView(coordinates); this._currentCenter = coordinates; } diff --git a/src/Providers/Maps/Leaflet/Features/Directions.ts b/src/Providers/Maps/Leaflet/Features/Directions.ts index 9d50ea08..1d4f2b10 100644 --- a/src/Providers/Maps/Leaflet/Features/Directions.ts +++ b/src/Providers/Maps/Leaflet/Features/Directions.ts @@ -202,7 +202,7 @@ namespace Provider.Maps.Leaflet.Feature { waypoints.forEach((wpt) => Helper.Conversions.ValidateCoordinates(wpt) .then((response) => { - wayptsFinal.push(new L.LatLng(response.lat, response.lng)); + wayptsFinal.push(new L.LatLng(response.lat as number, response.lng as number)); if (waypoints.length === wayptsFinal.length) { resolve(wayptsFinal); } diff --git a/src/Providers/Maps/Leaflet/Features/Offset.ts b/src/Providers/Maps/Leaflet/Features/Offset.ts index 84a2f0f2..a11e9bfb 100644 --- a/src/Providers/Maps/Leaflet/Features/Offset.ts +++ b/src/Providers/Maps/Leaflet/Features/Offset.ts @@ -24,7 +24,9 @@ namespace Provider.Maps.Leaflet.Feature { }; // get center coordinates into point - const point = this._map.provider.latLngToLayerPoint(this._map.features.center.getCurrentCenter()); + const point = this._map.provider.latLngToLayerPoint( + this._map.features.center.getCurrentCenter() as L.LatLngExpression + ); // calculate the new center point + offset const newPoint = new L.Point(point.x + this._offset.offsetX, point.y + this._offset.offsetY); diff --git a/src/Providers/Maps/Leaflet/Marker/Marker.ts b/src/Providers/Maps/Leaflet/Marker/Marker.ts index e75635ed..a1cd3c85 100644 --- a/src/Providers/Maps/Leaflet/Marker/Marker.ts +++ b/src/Providers/Maps/Leaflet/Marker/Marker.ts @@ -139,7 +139,7 @@ namespace Provider.Maps.Leaflet.Marker { return new Promise((resolve, reject) => { Helper.Conversions.ValidateCoordinates(this.config.location) .then((response) => { - markerLocation = new L.LatLng(response.lat, response.lng); + markerLocation = new L.LatLng(response.lat as number, response.lng as number); resolve(markerLocation); }) .catch((e) => reject(e)); @@ -261,8 +261,8 @@ namespace Provider.Maps.Leaflet.Marker { Helper.Conversions.ValidateCoordinates(propertyValue as string) .then((response) => { this._provider.setLatLng({ - lat: response.lat, - lng: response.lng, + lat: response.lat as number, + lng: response.lng as number, }); this.map.refresh(); }) diff --git a/src/Providers/Maps/Leaflet/Shape/AbstractPolyshape.ts b/src/Providers/Maps/Leaflet/Shape/AbstractPolyshape.ts index 24baaa27..d638961a 100644 --- a/src/Providers/Maps/Leaflet/Shape/AbstractPolyshape.ts +++ b/src/Providers/Maps/Leaflet/Shape/AbstractPolyshape.ts @@ -70,7 +70,7 @@ namespace Provider.Maps.Leaflet.Shape { /** Set the provider path from an array of coordinates */ private _setProviderPath(path: Array): void { - this._provider.setLatLngs(path); + this._provider.setLatLngs(path as L.LatLngExpression[]); } /** Validates if the locations are accepted for the Shape's path considering the minimum valid address/coordinates */ diff --git a/src/Providers/Maps/Leaflet/Shape/Polygon.ts b/src/Providers/Maps/Leaflet/Shape/Polygon.ts index 39f767e1..904ba376 100644 --- a/src/Providers/Maps/Leaflet/Shape/Polygon.ts +++ b/src/Providers/Maps/Leaflet/Shape/Polygon.ts @@ -30,7 +30,7 @@ namespace Provider.Maps.Leaflet.Shape { } protected createProvider(path: Array): L.Polygon { - return new L.Polygon(path, this.getProviderConfig()); + return new L.Polygon(path as L.LatLngExpression[], this.getProviderConfig()); } protected getShapeCoordinates(): OSFramework.Maps.OSStructures.OSMap.PolylineCoordinates { diff --git a/src/Providers/Maps/Leaflet/Shape/Polyline.ts b/src/Providers/Maps/Leaflet/Shape/Polyline.ts index 32fe8111..d321dae6 100644 --- a/src/Providers/Maps/Leaflet/Shape/Polyline.ts +++ b/src/Providers/Maps/Leaflet/Shape/Polyline.ts @@ -29,7 +29,7 @@ namespace Provider.Maps.Leaflet.Shape { } protected createProvider(path: Array): L.Polyline { - return new L.Polyline(path, this.getProviderConfig()); + return new L.Polyline(path as L.LatLngExpression[], this.getProviderConfig()); } protected getShapeCoordinates(): OSFramework.Maps.OSStructures.OSMap.PolylineCoordinates { diff --git a/src/Providers/Maps/Leaflet/Shape/Rectangle.ts b/src/Providers/Maps/Leaflet/Shape/Rectangle.ts index d244756b..8067a8e2 100644 --- a/src/Providers/Maps/Leaflet/Shape/Rectangle.ts +++ b/src/Providers/Maps/Leaflet/Shape/Rectangle.ts @@ -86,12 +86,12 @@ namespace Provider.Maps.Leaflet.Shape { switch (cd) { case 'north': case 'south': - newBounds[cd] = response.lat; + newBounds[cd] = response.lat as number; break; case 'east': case 'west': default: - newBounds[cd] = response.lng; + newBounds[cd] = response.lng as number; break; } if (boundsLength === 4) { From 8bb0c6622e6e753d5203a17c18d7d6ddaa1f7dd1 Mon Sep 17 00:00:00 2001 From: rug Date: Thu, 15 Feb 2024 18:45:05 +0100 Subject: [PATCH 06/12] Removing comments --- src/OSFramework/Maps/HeatmapLayer/IHeatmapLayer.ts | 2 +- .../Configuration/DrawingTools/DrawBasicShapeConfig.ts | 5 ----- .../Maps/Google/Configuration/DrawingTools/DrawConfig.ts | 5 ----- .../Configuration/DrawingTools/DrawFilledShapeConfig.ts | 5 ----- .../Google/Configuration/DrawingTools/DrawMarkerConfig.ts | 5 ----- .../Configuration/DrawingTools/DrawingToolsConfig.ts | 5 ----- .../Google/Configuration/FileLayer/FileLayerConfigs.ts | 5 ----- .../Configuration/HeatmapLayer/HeatmapLayerConfigs.ts | 5 ----- .../Maps/Google/Configuration/Marker/GoogleMarkerConfig.ts | 5 ----- .../Maps/Google/Configuration/OSMap/GoogleMapConfig.ts | 5 ----- .../Google/Configuration/OSMap/GoogleStaticMapConfig.ts | 5 ----- .../Configuration/SearchPlaces/SearchPlacesConfig.ts | 5 ----- .../Maps/Google/Configuration/Shape/BasicShapeConfig.ts | 5 ----- .../Maps/Google/Configuration/Shape/CircleShapeConfig.ts | 5 ----- .../Maps/Google/Configuration/Shape/FilledShapeConfig.ts | 5 ----- .../Google/Configuration/Shape/RectangleShapeConfig.ts | 5 ----- src/Providers/Maps/Google/DrawingTools/DrawRectangle.ts | 1 - .../Configuration/DrawingTools/DrawBasicShapeConfig.ts | 5 ----- .../Maps/Leaflet/Configuration/DrawingTools/DrawConfig.ts | 5 ----- .../Configuration/DrawingTools/DrawFilledShapeConfig.ts | 5 ----- .../Leaflet/Configuration/Marker/LeafletMarkerConfig.ts | 7 ------- .../Leaflet/Configuration/OSMap/LeafletMapConfiguration.ts | 5 ----- .../Maps/Leaflet/Configuration/Shape/BasicShapeConfig.ts | 7 ------- .../Maps/Leaflet/Configuration/Shape/CircleShapeConfig.ts | 7 ------- .../Maps/Leaflet/Configuration/Shape/FilledShapeConfig.ts | 7 ------- .../Leaflet/Configuration/Shape/RectangleShapeConfig.ts | 7 ------- src/Providers/Maps/Leaflet/DrawingTools/DrawingTools.ts | 1 - 27 files changed, 1 insertion(+), 133 deletions(-) diff --git a/src/OSFramework/Maps/HeatmapLayer/IHeatmapLayer.ts b/src/OSFramework/Maps/HeatmapLayer/IHeatmapLayer.ts index bf18fb93..11c689f5 100644 --- a/src/OSFramework/Maps/HeatmapLayer/IHeatmapLayer.ts +++ b/src/OSFramework/Maps/HeatmapLayer/IHeatmapLayer.ts @@ -1,7 +1,7 @@ // eslint-disable-next-line @typescript-eslint/no-unused-vars namespace OSFramework.Maps.HeatmapLayer { export interface IHeatmapLayer extends Interface.IBuilder, Interface.ISearchById, Interface.IDisposable { - config: Configuration.IConfigurationHeatmapLayer; //IConfigurationHeatmapLayer + config: Configuration.IConfigurationHeatmapLayer; isReady: boolean; map: OSMap.IMap; //IMap // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/src/Providers/Maps/Google/Configuration/DrawingTools/DrawBasicShapeConfig.ts b/src/Providers/Maps/Google/Configuration/DrawingTools/DrawBasicShapeConfig.ts index f71cb083..0e52ddd0 100644 --- a/src/Providers/Maps/Google/Configuration/DrawingTools/DrawBasicShapeConfig.ts +++ b/src/Providers/Maps/Google/Configuration/DrawingTools/DrawBasicShapeConfig.ts @@ -8,11 +8,6 @@ namespace Provider.Maps.Google.Configuration.DrawingTools { public strokeOpacity: number; public strokeWeight: number; - // No need for constructor, as it is not doing anything. Left the constructor, to facilitade future usage. - // constructor(config: JSON) { - // super(config); - // } - public getProviderConfig(): unknown[] { const configs = super.getProviderConfig(); // eslint-disable-next-line prefer-const diff --git a/src/Providers/Maps/Google/Configuration/DrawingTools/DrawConfig.ts b/src/Providers/Maps/Google/Configuration/DrawingTools/DrawConfig.ts index 26d33bf3..18cdb6a3 100644 --- a/src/Providers/Maps/Google/Configuration/DrawingTools/DrawConfig.ts +++ b/src/Providers/Maps/Google/Configuration/DrawingTools/DrawConfig.ts @@ -9,11 +9,6 @@ namespace Provider.Maps.Google.Configuration.DrawingTools { public allowDrag: boolean; public uniqueId: string; - // No need for constructor, as it is not doing anything. Left the constructor, to facilitade future usage. - // constructor(config: JSON) { - // super(config); - // } - // eslint-disable-next-line @typescript-eslint/no-explicit-any public getProviderConfig(): any { // eslint-disable-next-line prefer-const diff --git a/src/Providers/Maps/Google/Configuration/DrawingTools/DrawFilledShapeConfig.ts b/src/Providers/Maps/Google/Configuration/DrawingTools/DrawFilledShapeConfig.ts index 1db2417a..9ea79e8b 100644 --- a/src/Providers/Maps/Google/Configuration/DrawingTools/DrawFilledShapeConfig.ts +++ b/src/Providers/Maps/Google/Configuration/DrawingTools/DrawFilledShapeConfig.ts @@ -6,11 +6,6 @@ namespace Provider.Maps.Google.Configuration.DrawingTools { public fillColor: string; public fillOpacity: number; - // No need for constructor, as it is not doing anything. Left the constructor, to facilitade future usage. - // constructor(config: JSON) { - // super(config); - // } - public getProviderConfig(): unknown[] { const configs = super.getProviderConfig(); // eslint-disable-next-line prefer-const diff --git a/src/Providers/Maps/Google/Configuration/DrawingTools/DrawMarkerConfig.ts b/src/Providers/Maps/Google/Configuration/DrawingTools/DrawMarkerConfig.ts index 6c7f1fc1..b8cee108 100644 --- a/src/Providers/Maps/Google/Configuration/DrawingTools/DrawMarkerConfig.ts +++ b/src/Providers/Maps/Google/Configuration/DrawingTools/DrawMarkerConfig.ts @@ -5,11 +5,6 @@ namespace Provider.Maps.Google.Configuration.DrawingTools { export class DrawMarkerConfig extends DrawConfig { public iconUrl: string; - // No need for constructor, as it is not doing anything. Left the constructor, to facilitade future usage. - // constructor(config: JSON) { - // super(config); - // } - public getProviderConfig(): unknown[] { const provider = super.getProviderConfig(); provider.icon = this.iconUrl; diff --git a/src/Providers/Maps/Google/Configuration/DrawingTools/DrawingToolsConfig.ts b/src/Providers/Maps/Google/Configuration/DrawingTools/DrawingToolsConfig.ts index 6f2b205a..73154603 100644 --- a/src/Providers/Maps/Google/Configuration/DrawingTools/DrawingToolsConfig.ts +++ b/src/Providers/Maps/Google/Configuration/DrawingTools/DrawingToolsConfig.ts @@ -9,11 +9,6 @@ namespace Provider.Maps.Google.Configuration.DrawingTools { public position: string; public uniqueId: string; - // No need for constructor, as it is not doing anything. Left the constructor, to facilitade future usage. - // constructor(config: JSON) { - // super(config); - // } - public getProviderConfig(): unknown { return { position: this.position, diff --git a/src/Providers/Maps/Google/Configuration/FileLayer/FileLayerConfigs.ts b/src/Providers/Maps/Google/Configuration/FileLayer/FileLayerConfigs.ts index d5bfcbe6..9b28581a 100644 --- a/src/Providers/Maps/Google/Configuration/FileLayer/FileLayerConfigs.ts +++ b/src/Providers/Maps/Google/Configuration/FileLayer/FileLayerConfigs.ts @@ -10,11 +10,6 @@ namespace Provider.Maps.Google.Configuration.FileLayer { public preserveViewport: boolean; public suppressPopups: boolean; - // No need for constructor, as it is not doing anything. Left the constructor, to facilitade future usage. - // constructor(config: JSON) { - // super(config); - // } - public getProviderConfig(): unknown { // eslint-disable-next-line prefer-const let provider = { diff --git a/src/Providers/Maps/Google/Configuration/HeatmapLayer/HeatmapLayerConfigs.ts b/src/Providers/Maps/Google/Configuration/HeatmapLayer/HeatmapLayerConfigs.ts index 157a8e59..9b6aa3bb 100644 --- a/src/Providers/Maps/Google/Configuration/HeatmapLayer/HeatmapLayerConfigs.ts +++ b/src/Providers/Maps/Google/Configuration/HeatmapLayer/HeatmapLayerConfigs.ts @@ -13,11 +13,6 @@ namespace Provider.Maps.Google.Configuration.HeatmapLayer { public points: Array; public radius: number; - // No need for constructor, as it is not doing anything. Left the constructor, to facilitade future usage. - // constructor(config: JSON) { - // super(config); - // } - public getProviderConfig(): unknown { // eslint-disable-next-line prefer-const let provider = { diff --git a/src/Providers/Maps/Google/Configuration/Marker/GoogleMarkerConfig.ts b/src/Providers/Maps/Google/Configuration/Marker/GoogleMarkerConfig.ts index 45d4954e..f5e85194 100644 --- a/src/Providers/Maps/Google/Configuration/Marker/GoogleMarkerConfig.ts +++ b/src/Providers/Maps/Google/Configuration/Marker/GoogleMarkerConfig.ts @@ -14,11 +14,6 @@ namespace Provider.Maps.Google.Configuration.Marker { public location: string; public title: string; - // No need for constructor, as it is not doing anything. Left the constructor, to facilitade future usage. - // constructor(config: unknown) { - // super(config); - // } - public getProviderConfig(): unknown { const provider = { draggable: this.allowDrag, diff --git a/src/Providers/Maps/Google/Configuration/OSMap/GoogleMapConfig.ts b/src/Providers/Maps/Google/Configuration/OSMap/GoogleMapConfig.ts index 88b44705..e9c850f7 100644 --- a/src/Providers/Maps/Google/Configuration/OSMap/GoogleMapConfig.ts +++ b/src/Providers/Maps/Google/Configuration/OSMap/GoogleMapConfig.ts @@ -18,11 +18,6 @@ namespace Provider.Maps.Google.Configuration.OSMap { public uniqueId: string; public zoom: OSFramework.Maps.Enum.OSMap.Zoom; - // No need for constructor, as it is not doing anything. Left the constructor, to facilitade future usage. - // constructor(config: JSON) { - // super(config); - // } - public getProviderConfig(): unknown { const provider = { center: this.center, diff --git a/src/Providers/Maps/Google/Configuration/OSMap/GoogleStaticMapConfig.ts b/src/Providers/Maps/Google/Configuration/OSMap/GoogleStaticMapConfig.ts index 0bc11a7d..8a26a018 100644 --- a/src/Providers/Maps/Google/Configuration/OSMap/GoogleStaticMapConfig.ts +++ b/src/Providers/Maps/Google/Configuration/OSMap/GoogleStaticMapConfig.ts @@ -11,11 +11,6 @@ namespace Provider.Maps.Google.Configuration.OSMap { public uniqueId: string; public zoom: OSFramework.Maps.Enum.OSMap.Zoom; - // No need for constructor, as it is not doing anything. Left the constructor, to facilitade future usage. - // constructor(config: JSON) { - // super(config); - // } - public getProviderConfig(): unknown { const provider = { center: this.center, diff --git a/src/Providers/Maps/Google/Configuration/SearchPlaces/SearchPlacesConfig.ts b/src/Providers/Maps/Google/Configuration/SearchPlaces/SearchPlacesConfig.ts index e398079d..e4b5730a 100644 --- a/src/Providers/Maps/Google/Configuration/SearchPlaces/SearchPlacesConfig.ts +++ b/src/Providers/Maps/Google/Configuration/SearchPlaces/SearchPlacesConfig.ts @@ -11,11 +11,6 @@ namespace Provider.Maps.Google.Configuration.SearchPlaces { public searchArea: OSFramework.Maps.OSStructures.OSMap.BoundsString; public searchType: OSFramework.Maps.Enum.SearchTypes; - // No need for constructor, as it is not doing anything. Left the constructor, to facilitade future usage. - // constructor(config: JSON) { - // super(config); - // } - public getProviderConfig(): ISearchPlacesProviderConfig { // eslint-disable-next-line prefer-const let provider: ISearchPlacesProviderConfig = { diff --git a/src/Providers/Maps/Google/Configuration/Shape/BasicShapeConfig.ts b/src/Providers/Maps/Google/Configuration/Shape/BasicShapeConfig.ts index f56bd9f7..e65ff685 100644 --- a/src/Providers/Maps/Google/Configuration/Shape/BasicShapeConfig.ts +++ b/src/Providers/Maps/Google/Configuration/Shape/BasicShapeConfig.ts @@ -14,11 +14,6 @@ namespace Provider.Maps.Google.Configuration.Shape { public strokeWeight: number; public uniqueId: string; - // No need for constructor, as it is not doing anything. Left the constructor, to facilitade future usage. - // constructor(config: unknown) { - // super(config); - // } - public getProviderConfig(): IShapeProviderConfig { // eslint-disable-next-line prefer-const let provider: IShapeProviderConfig = { diff --git a/src/Providers/Maps/Google/Configuration/Shape/CircleShapeConfig.ts b/src/Providers/Maps/Google/Configuration/Shape/CircleShapeConfig.ts index 77d6f002..cca4f796 100644 --- a/src/Providers/Maps/Google/Configuration/Shape/CircleShapeConfig.ts +++ b/src/Providers/Maps/Google/Configuration/Shape/CircleShapeConfig.ts @@ -6,11 +6,6 @@ namespace Provider.Maps.Google.Configuration.Shape { public center: string; public radius: number; - // No need for constructor, as it is not doing anything. Left the constructor, to facilitade future usage. - // constructor(config: unknown) { - // super(config); - // } - public getProviderConfig(): IShapeProviderConfig { const provider = super.getProviderConfig(); provider.radius = this.radius; diff --git a/src/Providers/Maps/Google/Configuration/Shape/FilledShapeConfig.ts b/src/Providers/Maps/Google/Configuration/Shape/FilledShapeConfig.ts index d9d61754..860aed7a 100644 --- a/src/Providers/Maps/Google/Configuration/Shape/FilledShapeConfig.ts +++ b/src/Providers/Maps/Google/Configuration/Shape/FilledShapeConfig.ts @@ -6,11 +6,6 @@ namespace Provider.Maps.Google.Configuration.Shape { public fillColor: string; public fillOpacity: number; - // No need for constructor, as it is not doing anything. Left the constructor, to facilitade future usage. - // constructor(config: unknown) { - // super(config); - // } - public getProviderConfig(): IShapeProviderConfig { const provider_configs = super.getProviderConfig(); provider_configs.fillColor = this.fillColor; diff --git a/src/Providers/Maps/Google/Configuration/Shape/RectangleShapeConfig.ts b/src/Providers/Maps/Google/Configuration/Shape/RectangleShapeConfig.ts index 0c8f0098..cdd77b21 100644 --- a/src/Providers/Maps/Google/Configuration/Shape/RectangleShapeConfig.ts +++ b/src/Providers/Maps/Google/Configuration/Shape/RectangleShapeConfig.ts @@ -5,11 +5,6 @@ namespace Provider.Maps.Google.Configuration.Shape { export class RectangleShapeConfig extends FilledShapeConfig { public bounds: string; - // No need for constructor, as it is not doing anything. Left the constructor, to facilitade future usage. - // constructor(config: unknown) { - // super(config); - // } - public getProviderConfig(): IShapeProviderConfig { const provider = super.getProviderConfig(); diff --git a/src/Providers/Maps/Google/DrawingTools/DrawRectangle.ts b/src/Providers/Maps/Google/DrawingTools/DrawRectangle.ts index 4c42be1c..505e3553 100644 --- a/src/Providers/Maps/Google/DrawingTools/DrawRectangle.ts +++ b/src/Providers/Maps/Google/DrawingTools/DrawRectangle.ts @@ -58,7 +58,6 @@ namespace Provider.Maps.Google.DrawingTools { protected createElement( uniqueId: string, shape: google.maps.Rectangle, - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any configs: Configuration.Shape.RectangleShapeConfig ): OSFramework.Maps.Shape.IShape { const finalConfigs = this._createConfigsElement(shape, configs); diff --git a/src/Providers/Maps/Leaflet/Configuration/DrawingTools/DrawBasicShapeConfig.ts b/src/Providers/Maps/Leaflet/Configuration/DrawingTools/DrawBasicShapeConfig.ts index 0d575f2c..7d8abdaf 100644 --- a/src/Providers/Maps/Leaflet/Configuration/DrawingTools/DrawBasicShapeConfig.ts +++ b/src/Providers/Maps/Leaflet/Configuration/DrawingTools/DrawBasicShapeConfig.ts @@ -8,11 +8,6 @@ namespace Provider.Maps.Leaflet.Configuration.DrawingTools { public strokeOpacity: number; public strokeWeight: number; - // No need for constructor, as it is not doing anything. Left the constructor, to facilitade future usage. - // constructor(config: JSON) { - // super(config); - // } - // eslint-disable-next-line @typescript-eslint/no-explicit-any public getProviderConfig(): any { const configs = super.getProviderConfig(); diff --git a/src/Providers/Maps/Leaflet/Configuration/DrawingTools/DrawConfig.ts b/src/Providers/Maps/Leaflet/Configuration/DrawingTools/DrawConfig.ts index 39f86476..90bbb6e6 100644 --- a/src/Providers/Maps/Leaflet/Configuration/DrawingTools/DrawConfig.ts +++ b/src/Providers/Maps/Leaflet/Configuration/DrawingTools/DrawConfig.ts @@ -9,11 +9,6 @@ namespace Provider.Maps.Leaflet.Configuration.DrawingTools { public allowDrag: boolean; public uniqueId: string; - // No need for constructor, as it is not doing anything. Left the constructor, to facilitade future usage. - // constructor(config: JSON) { - // super(config); - // } - public getProviderConfig(): unknown[] { // eslint-disable-next-line prefer-const let provider = { diff --git a/src/Providers/Maps/Leaflet/Configuration/DrawingTools/DrawFilledShapeConfig.ts b/src/Providers/Maps/Leaflet/Configuration/DrawingTools/DrawFilledShapeConfig.ts index 90aa8a70..7cb72990 100644 --- a/src/Providers/Maps/Leaflet/Configuration/DrawingTools/DrawFilledShapeConfig.ts +++ b/src/Providers/Maps/Leaflet/Configuration/DrawingTools/DrawFilledShapeConfig.ts @@ -6,11 +6,6 @@ namespace Provider.Maps.Leaflet.Configuration.DrawingTools { public fillColor: string; public fillOpacity: number; - // No need for constructor, as it is not doing anything. Left the constructor, to facilitade future usage. - // constructor(config: JSON) { - // super(config); - // } - // eslint-disable-next-line @typescript-eslint/no-explicit-any public getProviderConfig(): any { // eslint-disable-next-line prefer-const diff --git a/src/Providers/Maps/Leaflet/Configuration/Marker/LeafletMarkerConfig.ts b/src/Providers/Maps/Leaflet/Configuration/Marker/LeafletMarkerConfig.ts index 59cd7039..78451dc8 100644 --- a/src/Providers/Maps/Leaflet/Configuration/Marker/LeafletMarkerConfig.ts +++ b/src/Providers/Maps/Leaflet/Configuration/Marker/LeafletMarkerConfig.ts @@ -14,13 +14,6 @@ namespace Provider.Maps.Leaflet.Configuration.Marker { public location: string; public title?: string; - // No need for constructor, as it is not doing anything. Left the constructor, to facilitade future usage. - // constructor( - // config: JSON | OSFramework.Maps.Configuration.IConfigurationMarker - // ) { - // super(config); - // } - public getProviderConfig(): L.MarkerOptions { const provider: L.MarkerOptions = { draggable: this.allowDrag, diff --git a/src/Providers/Maps/Leaflet/Configuration/OSMap/LeafletMapConfiguration.ts b/src/Providers/Maps/Leaflet/Configuration/OSMap/LeafletMapConfiguration.ts index 9676aa2b..b1598635 100644 --- a/src/Providers/Maps/Leaflet/Configuration/OSMap/LeafletMapConfiguration.ts +++ b/src/Providers/Maps/Leaflet/Configuration/OSMap/LeafletMapConfiguration.ts @@ -12,11 +12,6 @@ namespace Provider.Maps.Leaflet.Configuration.OSMap { public uniqueId: string; public zoom: OSFramework.Maps.Enum.OSMap.Zoom; - // No need for constructor, as it is not doing anything. Left the constructor, to facilitade future usage. - // constructor(config: JSON) { - // super(config); - // } - public getProviderConfig(): unknown { // eslint-disable-next-line prefer-const let provider = { diff --git a/src/Providers/Maps/Leaflet/Configuration/Shape/BasicShapeConfig.ts b/src/Providers/Maps/Leaflet/Configuration/Shape/BasicShapeConfig.ts index 97af824f..548f3917 100644 --- a/src/Providers/Maps/Leaflet/Configuration/Shape/BasicShapeConfig.ts +++ b/src/Providers/Maps/Leaflet/Configuration/Shape/BasicShapeConfig.ts @@ -14,13 +14,6 @@ namespace Provider.Maps.Leaflet.Configuration.Shape { public strokeOpacity: number; public strokeWeight: number; - // No need for constructor, as it is not doing anything. Left the constructor, to facilitade future usage. - // constructor( - // config: OSFramework.Maps.Configuration.IConfigurationShape - // ) { - // super(config); - // } - // eslint-disable-next-line @typescript-eslint/no-explicit-any public getProviderConfig(): any { const provider = { diff --git a/src/Providers/Maps/Leaflet/Configuration/Shape/CircleShapeConfig.ts b/src/Providers/Maps/Leaflet/Configuration/Shape/CircleShapeConfig.ts index 96296f48..974d0bb9 100644 --- a/src/Providers/Maps/Leaflet/Configuration/Shape/CircleShapeConfig.ts +++ b/src/Providers/Maps/Leaflet/Configuration/Shape/CircleShapeConfig.ts @@ -6,13 +6,6 @@ namespace Provider.Maps.Leaflet.Configuration.Shape { public center: string; public radius: number; - // No need for constructor, as it is not doing anything. Left the constructor, to facilitade future usage. - // constructor( - // config: OSFramework.Maps.Configuration.IConfigurationShape - // ) { - // super(config); - // } - public getProviderConfig(): L.CircleOptions { const provider = super.getProviderConfig(); provider.radius = this.radius; diff --git a/src/Providers/Maps/Leaflet/Configuration/Shape/FilledShapeConfig.ts b/src/Providers/Maps/Leaflet/Configuration/Shape/FilledShapeConfig.ts index d128b6ce..0f2dbd6f 100644 --- a/src/Providers/Maps/Leaflet/Configuration/Shape/FilledShapeConfig.ts +++ b/src/Providers/Maps/Leaflet/Configuration/Shape/FilledShapeConfig.ts @@ -6,13 +6,6 @@ namespace Provider.Maps.Leaflet.Configuration.Shape { public fillColor: string; public fillOpacity: number; - // No need for constructor, as it is not doing anything. Left the constructor, to facilitade future usage. - // constructor( - // config: OSFramework.Maps.Configuration.IConfigurationShape - // ) { - // super(config); - // } - // eslint-disable-next-line @typescript-eslint/no-explicit-any public getProviderConfig(): any { const provider = super.getProviderConfig(); diff --git a/src/Providers/Maps/Leaflet/Configuration/Shape/RectangleShapeConfig.ts b/src/Providers/Maps/Leaflet/Configuration/Shape/RectangleShapeConfig.ts index 12cca832..a1ebf671 100644 --- a/src/Providers/Maps/Leaflet/Configuration/Shape/RectangleShapeConfig.ts +++ b/src/Providers/Maps/Leaflet/Configuration/Shape/RectangleShapeConfig.ts @@ -5,13 +5,6 @@ namespace Provider.Maps.Leaflet.Configuration.Shape { export class RectangleShapeConfig extends FilledShapeConfig { public bounds: string; - // No need for constructor, as it is not doing anything. Left the constructor, to facilitade future usage. - // constructor( - // config: OSFramework.Maps.Configuration.IConfigurationShape - // ) { - // super(config); - // } - public getProviderConfig(): unknown { const provider = super.getProviderConfig(); diff --git a/src/Providers/Maps/Leaflet/DrawingTools/DrawingTools.ts b/src/Providers/Maps/Leaflet/DrawingTools/DrawingTools.ts index bb26b8ac..436f9965 100644 --- a/src/Providers/Maps/Leaflet/DrawingTools/DrawingTools.ts +++ b/src/Providers/Maps/Leaflet/DrawingTools/DrawingTools.ts @@ -67,7 +67,6 @@ namespace Provider.Maps.Leaflet.DrawingTools { } } - //TODO: create the return structure private _getTools(): ToolsList { const _tools = new ToolsList(); this.tools.forEach((tool) => { From dca4e54eaa450dc5bbb821f2ad2c26068243e549 Mon Sep 17 00:00:00 2001 From: rug Date: Thu, 15 Feb 2024 18:46:15 +0100 Subject: [PATCH 07/12] Improving code --- src/OSFramework/Maps/Helper/JsonFormatter.ts | 8 ++-- .../DrawingTools/AbstractProviderTool.ts | 6 +-- src/Providers/Maps/Google/Shape/Circle.ts | 41 ++++++++++--------- .../Maps/Leaflet/DrawingTools/DrawingTools.ts | 15 +++---- src/Providers/Maps/Leaflet/Shape/Circle.ts | 41 ++++++++++--------- 5 files changed, 55 insertions(+), 56 deletions(-) diff --git a/src/OSFramework/Maps/Helper/JsonFormatter.ts b/src/OSFramework/Maps/Helper/JsonFormatter.ts index 4f09f4e1..b73a96ca 100644 --- a/src/OSFramework/Maps/Helper/JsonFormatter.ts +++ b/src/OSFramework/Maps/Helper/JsonFormatter.ts @@ -1,10 +1,10 @@ // eslint-disable-next-line @typescript-eslint/no-unused-vars namespace OSFramework.Maps.Helper { export function JsonFormatter(text: string): JSON { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - let json: any = {}; - if (text === undefined || text === '') return json; + let json = {}; + if (text === undefined || text === '') return json as JSON; + /* NO SONAR */ // text.substring(1, text.length - 1) // .replace(/ /g, '') // .split(',') @@ -21,6 +21,6 @@ namespace OSFramework.Maps.Helper { // eslint-disable-next-line no-eval json = eval('(' + text + ')'); - return json; + return json as JSON; } } diff --git a/src/Providers/Maps/Google/DrawingTools/AbstractProviderTool.ts b/src/Providers/Maps/Google/DrawingTools/AbstractProviderTool.ts index d8561b31..288aee19 100644 --- a/src/Providers/Maps/Google/DrawingTools/AbstractProviderTool.ts +++ b/src/Providers/Maps/Google/DrawingTools/AbstractProviderTool.ts @@ -82,10 +82,8 @@ namespace Provider.Maps.Google.DrawingTools { const propValue = OSFramework.Maps.Enum.OS_Config_Shape[propertyName]; super.changeProperty(propertyName, value); if (this.drawingTools.isReady) { - switch (propValue) { - case OSFramework.Maps.Enum.OS_Config_Shape.allowDrag: - this.options = { draggable: value }; - return; + if (propValue === OSFramework.Maps.Enum.OS_Config_Shape.allowDrag) { + this.options = { draggable: value }; } } } diff --git a/src/Providers/Maps/Google/Shape/Circle.ts b/src/Providers/Maps/Google/Shape/Circle.ts index a3be13e0..e863a3b3 100644 --- a/src/Providers/Maps/Google/Shape/Circle.ts +++ b/src/Providers/Maps/Google/Shape/Circle.ts @@ -35,10 +35,28 @@ namespace Provider.Maps.Google.Shape { }); } + private _changeCenter(location: string): void { + const shapeCenter = this._buildCenter(location); + // If path is undefined (should be a promise) -> don't create the shape + if (shapeCenter !== undefined) { + shapeCenter + .then((center) => { + this.provider.setCenter(center as google.maps.LatLng); + }) + .catch((error) => { + OSFramework.Maps.Helper.ThrowError( + this.map, + OSFramework.Maps.Enum.ErrorCodes.LIB_FailedGeocodingShapeLocations, + error + ); + }); + } + } + protected _createProvider(center: OSFramework.Maps.OSStructures.OSMap.Coordinates): google.maps.Circle { return new google.maps.Circle({ map: this.map.provider, - center, + center: center as google.maps.LatLngAltitudeLiteral, ...(this.getProviderConfig() as Configuration.Shape.IShapeProviderConfig), }); } @@ -50,8 +68,8 @@ namespace Provider.Maps.Google.Shape { protected getShapeCoordinates(): OSFramework.Maps.OSStructures.OSMap.CircleCoordinates { return { coordinates: { - Lat: this.providerCenter.lat, - Lng: this.providerCenter.lng, + Lat: this.providerCenter.lat as number, + Lng: this.providerCenter.lng as number, }, location: { location: `${this.providerCenter.lat.toString()},${this.providerCenter.lng.toString()}`, @@ -114,22 +132,7 @@ namespace Provider.Maps.Google.Shape { if (this.isReady) { switch (propValue) { case OSFramework.Maps.Enum.OS_Config_Shape.center: - // eslint-disable-next-line no-case-declarations - const shapeCenter = this._buildCenter(propertyValue as string); - // If path is undefined (should be a promise) -> don't create the shape - if (shapeCenter !== undefined) { - shapeCenter - .then((center) => { - this.provider.setCenter(center); - }) - .catch((error) => { - OSFramework.Maps.Helper.ThrowError( - this.map, - OSFramework.Maps.Enum.ErrorCodes.LIB_FailedGeocodingShapeLocations, - error - ); - }); - } + this._changeCenter(propertyValue as string); return; case OSFramework.Maps.Enum.OS_Config_Shape.radius: return this.provider.setRadius(propertyValue as number); diff --git a/src/Providers/Maps/Leaflet/DrawingTools/DrawingTools.ts b/src/Providers/Maps/Leaflet/DrawingTools/DrawingTools.ts index 436f9965..0554043d 100644 --- a/src/Providers/Maps/Leaflet/DrawingTools/DrawingTools.ts +++ b/src/Providers/Maps/Leaflet/DrawingTools/DrawingTools.ts @@ -55,16 +55,14 @@ namespace Provider.Maps.Leaflet.DrawingTools { } private _getDrawingToolsPosition(position: string): Constants.DrawingTools.Positions { - if (Constants.DrawingTools.Positions[position] !== undefined) { - return Constants.DrawingTools.Positions[position]; - } else { + if (Constants.DrawingTools.Positions[position] === undefined) { OSFramework.Maps.Helper.ThrowError( this.map, OSFramework.Maps.Enum.ErrorCodes.CFG_InvalidDrawingToolsPosition, `${position}` ); - return; } + return Constants.DrawingTools.Positions[position]; } private _getTools(): ToolsList { @@ -185,12 +183,9 @@ namespace Provider.Maps.Leaflet.DrawingTools { const propValue = OSFramework.Maps.Enum.OS_Config_DrawingTools[propertyName]; super.changeProperty(propertyName, propertyValue); if (this.isReady) { - switch (propValue) { - case OSFramework.Maps.Enum.OS_Config_DrawingTools.position: - // eslint-disable-next-line no-case-declarations - const positionValue = this._getDrawingToolsPosition(propertyValue as string); - positionValue && this.provider.setPosition(positionValue); - return; + if (propValue === OSFramework.Maps.Enum.OS_Config_DrawingTools.position) { + const positionValue = this._getDrawingToolsPosition(propertyValue as string); + positionValue && this.provider.setPosition(positionValue); } } } diff --git a/src/Providers/Maps/Leaflet/Shape/Circle.ts b/src/Providers/Maps/Leaflet/Shape/Circle.ts index f606c798..1aef8582 100644 --- a/src/Providers/Maps/Leaflet/Shape/Circle.ts +++ b/src/Providers/Maps/Leaflet/Shape/Circle.ts @@ -79,15 +79,33 @@ namespace Provider.Maps.Leaflet.Shape { }); } + private _changeCenter(location: string): void { + const shapeCenter = this._buildCenter(location); + // If path is undefined (should be a promise) -> don't create the shape + if (shapeCenter !== undefined) { + shapeCenter + .then((center) => { + this.provider.setLatLng(center as L.LatLngExpression); + }) + .catch((error) => { + OSFramework.Maps.Helper.ThrowError( + this.map, + OSFramework.Maps.Enum.ErrorCodes.LIB_FailedGeocodingShapeLocations, + error + ); + }); + } + } + protected createProvider(center: OSFramework.Maps.OSStructures.OSMap.Coordinates): L.Circle { - return new L.Circle(center, this.getProviderConfig() as L.CircleOptions); + return new L.Circle(center as L.LatLngExpression, this.getProviderConfig() as L.CircleOptions); } protected getShapeCoordinates(): OSFramework.Maps.OSStructures.OSMap.CircleCoordinates { return { coordinates: { - Lat: this.providerCenter.lat, - Lng: this.providerCenter.lng, + Lat: this.providerCenter.lat as number, + Lng: this.providerCenter.lng as number, }, location: { location: `${this.providerCenter.lat.toString()},${this.providerCenter.lng.toString()}`, @@ -110,22 +128,7 @@ namespace Provider.Maps.Leaflet.Shape { if (this.isReady) { switch (propValue) { case OSFramework.Maps.Enum.OS_Config_Shape.center: - // eslint-disable-next-line no-case-declarations - const shapeCenter = this._buildCenter(propertyValue as string); - // If path is undefined (should be a promise) -> don't create the shape - if (shapeCenter !== undefined) { - shapeCenter - .then((center) => { - this.provider.setLatLng(center); - }) - .catch((error) => { - OSFramework.Maps.Helper.ThrowError( - this.map, - OSFramework.Maps.Enum.ErrorCodes.LIB_FailedGeocodingShapeLocations, - error - ); - }); - } + this._changeCenter(propertyValue as string); return; case OSFramework.Maps.Enum.OS_Config_Shape.radius: this.provider.setRadius(propertyValue as number); From a18f69dec48a51bea36f8e41eee32d54ddac4f9b Mon Sep 17 00:00:00 2001 From: rug Date: Thu, 15 Feb 2024 18:46:45 +0100 Subject: [PATCH 08/12] Removing usage of any --- src/OSFramework/Maps/HeatmapLayer/IHeatmapLayer.ts | 5 ++--- .../Maps/Google/DrawingTools/AbstractProviderTool.ts | 3 +-- src/Providers/Maps/Google/Features/FeatureBuilder.ts | 5 +---- src/Providers/Maps/Leaflet/DrawingTools/DrawingTools.ts | 3 +-- src/Providers/Maps/Leaflet/Features/FeatureBuilder.ts | 5 +---- 5 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/OSFramework/Maps/HeatmapLayer/IHeatmapLayer.ts b/src/OSFramework/Maps/HeatmapLayer/IHeatmapLayer.ts index 11c689f5..216f9cb2 100644 --- a/src/OSFramework/Maps/HeatmapLayer/IHeatmapLayer.ts +++ b/src/OSFramework/Maps/HeatmapLayer/IHeatmapLayer.ts @@ -3,9 +3,8 @@ namespace OSFramework.Maps.HeatmapLayer { export interface IHeatmapLayer extends Interface.IBuilder, Interface.ISearchById, Interface.IDisposable { config: Configuration.IConfigurationHeatmapLayer; isReady: boolean; - map: OSMap.IMap; //IMap - // eslint-disable-next-line @typescript-eslint/no-explicit-any - provider: any; + map: OSMap.IMap; + provider: unknown; uniqueId: string; widgetId: string; diff --git a/src/Providers/Maps/Google/DrawingTools/AbstractProviderTool.ts b/src/Providers/Maps/Google/DrawingTools/AbstractProviderTool.ts index 288aee19..ac3424dc 100644 --- a/src/Providers/Maps/Google/DrawingTools/AbstractProviderTool.ts +++ b/src/Providers/Maps/Google/DrawingTools/AbstractProviderTool.ts @@ -16,8 +16,7 @@ namespace Provider.Maps.Google.DrawingTools { super(map, drawingTools, drawingToolsId, type, configs); } - // eslint-disable-next-line @typescript-eslint/no-explicit-any - private _addCompletedEventHandler(element: any): void { + private _addCompletedEventHandler(element: google.maps.drawing.DrawingManager): void { const uniqueId = OSFramework.Maps.Helper.GenerateUniqueId(); // create the shape/marker element this.newElm = this.createElement( diff --git a/src/Providers/Maps/Google/Features/FeatureBuilder.ts b/src/Providers/Maps/Google/Features/FeatureBuilder.ts index 2370c9f8..19224793 100644 --- a/src/Providers/Maps/Google/Features/FeatureBuilder.ts +++ b/src/Providers/Maps/Google/Features/FeatureBuilder.ts @@ -17,10 +17,7 @@ namespace Provider.Maps.Google.Feature { } // eslint-disable-next-line @typescript-eslint/naming-convention - private _instanceOfIDisposable( - // eslint-disable-next-line @typescript-eslint/no-explicit-any - object: any - ): object is OSFramework.Maps.Interface.IDisposable { + private _instanceOfIDisposable(object: object): object is OSFramework.Maps.Interface.IDisposable { return 'dispose' in object; } diff --git a/src/Providers/Maps/Leaflet/DrawingTools/DrawingTools.ts b/src/Providers/Maps/Leaflet/DrawingTools/DrawingTools.ts index 0554043d..3ca2d394 100644 --- a/src/Providers/Maps/Leaflet/DrawingTools/DrawingTools.ts +++ b/src/Providers/Maps/Leaflet/DrawingTools/DrawingTools.ts @@ -45,8 +45,7 @@ namespace Provider.Maps.Leaflet.DrawingTools { this._toolsGroup = new L.FeatureGroup(); } - // eslint-disable-next-line @typescript-eslint/no-explicit-any - private _addCompletedEventHandler(event: any): void { + private _addCompletedEventHandler(event: { layerType: unknown }): void { const toolType = event.layerType; this.tools diff --git a/src/Providers/Maps/Leaflet/Features/FeatureBuilder.ts b/src/Providers/Maps/Leaflet/Features/FeatureBuilder.ts index 7ac97d15..01fa1614 100644 --- a/src/Providers/Maps/Leaflet/Features/FeatureBuilder.ts +++ b/src/Providers/Maps/Leaflet/Features/FeatureBuilder.ts @@ -17,10 +17,7 @@ namespace Provider.Maps.Leaflet.Feature { } // eslint-disable-next-line @typescript-eslint/naming-convention - private _instanceOfIDisposable( - // eslint-disable-next-line @typescript-eslint/no-explicit-any - object: any - ): object is OSFramework.Maps.Interface.IDisposable { + private _instanceOfIDisposable(object: object): object is OSFramework.Maps.Interface.IDisposable { return 'dispose' in object; } From a2926c9d49e058274137678665f5ea59f218e254 Mon Sep 17 00:00:00 2001 From: rug Date: Thu, 15 Feb 2024 18:47:01 +0100 Subject: [PATCH 09/12] Removing dead code --- .../Maps/Google/DrawingTools/AbstractProviderTool.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/Providers/Maps/Google/DrawingTools/AbstractProviderTool.ts b/src/Providers/Maps/Google/DrawingTools/AbstractProviderTool.ts index ac3424dc..1757091a 100644 --- a/src/Providers/Maps/Google/DrawingTools/AbstractProviderTool.ts +++ b/src/Providers/Maps/Google/DrawingTools/AbstractProviderTool.ts @@ -6,15 +6,6 @@ namespace Provider.Maps.Google.DrawingTools { T extends OSFramework.Maps.Configuration.IConfigurationTool, > extends OSFramework.Maps.DrawingTools.AbstractTool { protected newElm; - constructor( - map: OSFramework.Maps.OSMap.IMap, - drawingTools: OSFramework.Maps.DrawingTools.IDrawingTools, - drawingToolsId: string, - type: string, - configs: T - ) { - super(map, drawingTools, drawingToolsId, type, configs); - } private _addCompletedEventHandler(element: google.maps.drawing.DrawingManager): void { const uniqueId = OSFramework.Maps.Helper.GenerateUniqueId(); From 0ae84ac984b4a7cf95ccd7965f8ca5bd7bca2dc1 Mon Sep 17 00:00:00 2001 From: rug Date: Fri, 16 Feb 2024 13:12:56 +0100 Subject: [PATCH 10/12] Code improvements --- .../Maps/FileLayer/AbstractFileLayer.ts | 7 +------ src/OSFramework/Maps/FileLayer/IFileLayer.ts | 3 +-- src/OSFramework/Maps/Marker/IMarker.ts | 3 +-- src/OSFramework/Maps/OSMap/AbstractMap.ts | 2 +- src/OutSystems/Maps/MapAPI/MarkerManager.ts | 8 ++++++-- .../Maps/Google/DrawingTools/DrawMarker.ts | 12 +++++++----- .../Maps/Google/Features/GoogleMarkerClusterer.ts | 4 +++- src/Providers/Maps/Google/Features/InfoWindow.ts | 2 +- .../Maps/Leaflet/DrawingTools/DrawMarker.ts | 12 +++++++----- src/Providers/Maps/Leaflet/Features/InfoWindow.ts | 15 +++++---------- src/Providers/Maps/Leaflet/Features/Zoom.ts | 2 +- src/Providers/Maps/Leaflet/OSMap/OSMap.ts | 7 ++++--- 12 files changed, 38 insertions(+), 39 deletions(-) diff --git a/src/OSFramework/Maps/FileLayer/AbstractFileLayer.ts b/src/OSFramework/Maps/FileLayer/AbstractFileLayer.ts index ec5c5587..091da0eb 100644 --- a/src/OSFramework/Maps/FileLayer/AbstractFileLayer.ts +++ b/src/OSFramework/Maps/FileLayer/AbstractFileLayer.ts @@ -1,11 +1,6 @@ // eslint-disable-next-line @typescript-eslint/no-unused-vars namespace OSFramework.Maps.FileLayer { - export abstract class AbstractFileLayer< - W, - // eslint-disable-next-line @typescript-eslint/no-unused-vars - T extends Configuration.IConfigurationFileLayer, - > implements IFileLayer - { + export abstract class AbstractFileLayer implements IFileLayer { /** Configuration reference */ private _config: T; private _map: OSMap.IMap; diff --git a/src/OSFramework/Maps/FileLayer/IFileLayer.ts b/src/OSFramework/Maps/FileLayer/IFileLayer.ts index bc99ffd1..47db59e2 100644 --- a/src/OSFramework/Maps/FileLayer/IFileLayer.ts +++ b/src/OSFramework/Maps/FileLayer/IFileLayer.ts @@ -7,8 +7,7 @@ namespace OSFramework.Maps.FileLayer { fileLayerEvents: Event.FileLayer.FileLayersEventsManager; isReady: boolean; map: OSMap.IMap; //IMap - // eslint-disable-next-line @typescript-eslint/no-explicit-any - provider: any; + provider: unknown; uniqueId: string; widgetId: string; diff --git a/src/OSFramework/Maps/Marker/IMarker.ts b/src/OSFramework/Maps/Marker/IMarker.ts index 7cb11ea8..a97b75a9 100644 --- a/src/OSFramework/Maps/Marker/IMarker.ts +++ b/src/OSFramework/Maps/Marker/IMarker.ts @@ -8,8 +8,7 @@ namespace OSFramework.Maps.Marker { isReady: boolean; map: OSMap.IMap; //IMap markerEvents: Event.Marker.MarkerEventsManager; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - provider: any; + provider: unknown; uniqueId: string; widgetId: string; diff --git a/src/OSFramework/Maps/OSMap/AbstractMap.ts b/src/OSFramework/Maps/OSMap/AbstractMap.ts index 18a151e9..df1eca40 100644 --- a/src/OSFramework/Maps/OSMap/AbstractMap.ts +++ b/src/OSFramework/Maps/OSMap/AbstractMap.ts @@ -80,7 +80,7 @@ namespace OSFramework.Maps.OSMap { return Array.from(this._markersSet); } - public get markersReady(): W[] { + public get markersReady(): unknown[] { // We need to go through all the markers and only get the ones that are ready (or have the provider defined) // Then we need to return the providers inside a list return this.markers.filter((marker) => marker.isReady).map((marker) => marker.provider); diff --git a/src/OutSystems/Maps/MapAPI/MarkerManager.ts b/src/OutSystems/Maps/MapAPI/MarkerManager.ts index 7f8c20ae..dbc1a573 100644 --- a/src/OutSystems/Maps/MapAPI/MarkerManager.ts +++ b/src/OutSystems/Maps/MapAPI/MarkerManager.ts @@ -58,12 +58,16 @@ namespace OutSystems.Maps.MapAPI.MarkerManager { if (map.providerType === OSFramework.Maps.Enum.ProviderType.Google) { // Check if the feature is enabled! if (map.hasMarkerClusterer()) { - const marker = map.markers.find((marker) => marker.provider.location === markerPosition); + const marker = map.markers.find((marker) => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return (marker.provider as any).location === markerPosition; + }); // Check if there is a marker with the given Position/Location if (marker !== undefined) { map.features.markerClusterer.removeMarker(marker); - marker.provider.setMap(map.provider); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (marker.provider as any).setMap(map.provider); } else { responseObj.isSuccess = false; responseObj.message = `There are not a marker with position:'${markerPosition}' to be removed.`; diff --git a/src/Providers/Maps/Google/DrawingTools/DrawMarker.ts b/src/Providers/Maps/Google/DrawingTools/DrawMarker.ts index 559c9d7f..4bbac68b 100644 --- a/src/Providers/Maps/Google/DrawingTools/DrawMarker.ts +++ b/src/Providers/Maps/Google/DrawingTools/DrawMarker.ts @@ -18,20 +18,22 @@ namespace Provider.Maps.Google.DrawingTools { } private _setOnChangeEvent(_marker: OSFramework.Maps.Marker.IMarker): void { + const markerProvider = _marker.provider as google.maps.Marker; _marker.markerEvents.addHandler( // changing the marker location is only available via the drag-and-drop, so the solution passes by adding the dragend event listener as the marker's OnChanged event 'dragend' as OSFramework.Maps.Event.Marker.MarkerEventType, // Trigger the onDrawingChangeEvent with the extra information (marker uniqueId and flag indicating that the element is not new) - () => + () => { this.triggerOnDrawingChangeEvent( _marker.uniqueId, false, JSON.stringify({ - Lat: _marker.provider.getPosition().lat(), - Lng: _marker.provider.getPosition().lng(), + Lat: markerProvider.getPosition().lat(), + Lng: markerProvider.getPosition().lng(), }), - `${_marker.provider.getPosition().lat()},${_marker.provider.getPosition().lng()}` - ) + `${markerProvider.getPosition().lat()}, ${markerProvider.getPosition().lng()}` + ); + } ); } diff --git a/src/Providers/Maps/Google/Features/GoogleMarkerClusterer.ts b/src/Providers/Maps/Google/Features/GoogleMarkerClusterer.ts index 8d5615f0..b3cd30c8 100644 --- a/src/Providers/Maps/Google/Features/GoogleMarkerClusterer.ts +++ b/src/Providers/Maps/Google/Features/GoogleMarkerClusterer.ts @@ -70,7 +70,9 @@ namespace Provider.Maps.Google.Feature { this._rebuildClusters(); } else { this._markerClusterer.clearMarkers(); - this._map.markers.forEach((marker) => marker.provider.setMap(this._map.provider)); + this._map.markers.forEach((marker) => { + (marker.provider as google.maps.Marker).setMap(this._map.provider); + }); } } diff --git a/src/Providers/Maps/Google/Features/InfoWindow.ts b/src/Providers/Maps/Google/Features/InfoWindow.ts index 6cac314d..5389717d 100644 --- a/src/Providers/Maps/Google/Features/InfoWindow.ts +++ b/src/Providers/Maps/Google/Features/InfoWindow.ts @@ -34,7 +34,7 @@ namespace Provider.Maps.Google.Feature { if (this._popupIsOpened === true) { this.closePopup(); } - this._infoWindow.open(this._map.provider, marker.provider); + this._infoWindow.open(this._map.provider, marker.provider as google.maps.Marker); this._popupIsOpened = true; } diff --git a/src/Providers/Maps/Leaflet/DrawingTools/DrawMarker.ts b/src/Providers/Maps/Leaflet/DrawingTools/DrawMarker.ts index 94ebc213..99b9aea5 100644 --- a/src/Providers/Maps/Leaflet/DrawingTools/DrawMarker.ts +++ b/src/Providers/Maps/Leaflet/DrawingTools/DrawMarker.ts @@ -61,20 +61,22 @@ namespace Provider.Maps.Leaflet.DrawingTools { } private _setOnChangeEvent(_marker: OSFramework.Maps.Marker.IMarker): void { + const markerProvider = _marker.provider as L.Marker; _marker.markerEvents.addHandler( // changing the marker location is only available via the drag-and-drop, so the solution passes by adding the dragend event listener as the marker's OnChanged event 'dragend' as OSFramework.Maps.Event.Marker.MarkerEventType, // Trigger the onDrawingChangeEvent with the extra information (marker uniqueId and flag indicating that the element is not new) - () => + () => { this.triggerOnDrawingChangeEvent( _marker.uniqueId, false, JSON.stringify({ - Lat: _marker.provider.getLatLng().lat, - Lng: _marker.provider.getLatLng().lng, + Lat: markerProvider.getLatLng().lat, + Lng: markerProvider.getLatLng().lng, }), - `${_marker.provider.getLatLng().lat},${_marker.provider.getLatLng().lng}` - ) + `${markerProvider.getLatLng().lat}, ${markerProvider.getLatLng().lng}` + ); + } ); } diff --git a/src/Providers/Maps/Leaflet/Features/InfoWindow.ts b/src/Providers/Maps/Leaflet/Features/InfoWindow.ts index 8a6ffa89..0b046565 100644 --- a/src/Providers/Maps/Leaflet/Features/InfoWindow.ts +++ b/src/Providers/Maps/Leaflet/Features/InfoWindow.ts @@ -2,16 +2,11 @@ namespace Provider.Maps.Leaflet.Feature { export class InfoWindow implements OSFramework.Maps.Feature.IInfoWindow, OSFramework.Maps.Interface.IBuilder { private _infoWindow: L.Popup; - private _map: OSMap.IMapLeaflet; private _popupIsOpened: boolean; - constructor(map: OSMap.IMapLeaflet) { - this._map = map; - } - // This method is a way of getting the options which include the offset. // The offset needs to be acquired dynamically as it should change according to the height of the icon applied to the marker. - private _getOptions(marker: OSFramework.Maps.Marker.IMarkerPopup): L.PopupOptions { + private _getOptions(marker: Marker.MarkerPopup): L.PopupOptions { // Let's use the height of the marker icon as the offsetY. But if the height of the icon is not defined: use the runtime offsetHeight of the marker element const offsetHeight = marker.config.iconHeight > 0 ? marker.config.iconHeight : marker.provider.getElement().offsetHeight; @@ -31,7 +26,7 @@ namespace Provider.Maps.Leaflet.Feature { this._popupIsOpened = false; } - public closePopup(marker: OSFramework.Maps.Marker.IMarkerPopup): void { + public closePopup(marker: Marker.MarkerPopup): void { if (this._popupIsOpened) { marker.provider.closePopup(); // Let's make sure the popup gets unlinked from the Marker @@ -40,7 +35,7 @@ namespace Provider.Maps.Leaflet.Feature { } } - public openPopup(marker: OSFramework.Maps.Marker.IMarkerPopup): void { + public openPopup(marker: Marker.MarkerPopup): void { if (this._popupIsOpened === true) { this.closePopup(marker); } @@ -49,10 +44,10 @@ namespace Provider.Maps.Leaflet.Feature { this._popupIsOpened = true; } - public setPopupContent(content: string, marker: OSFramework.Maps.Marker.IMarkerPopup): void { + public setPopupContent(content: string, marker: Marker.MarkerPopup): void { this._infoWindow.setContent(content); this._infoWindow.update(); - marker.provider.setPopupContent(this._infoWindow.getContent()); + marker.provider.setPopupContent(this._infoWindow.getContent() as L.Content); } } } diff --git a/src/Providers/Maps/Leaflet/Features/Zoom.ts b/src/Providers/Maps/Leaflet/Features/Zoom.ts index c2f4a718..c9c0c788 100644 --- a/src/Providers/Maps/Leaflet/Features/Zoom.ts +++ b/src/Providers/Maps/Leaflet/Features/Zoom.ts @@ -21,7 +21,7 @@ namespace Provider.Maps.Leaflet.Feature { let bounds: L.LatLngBounds; this._map.markers.forEach(function (marker) { if (marker.provider === undefined) return; - const loc: L.LatLng = marker.provider.getLatLng(); + const loc: L.LatLng = (marker.provider as L.Marker).getLatLng(); bounds = bounds ? bounds.extend(loc) : new L.LatLngBounds(loc, loc); }); if (useShapes) { diff --git a/src/Providers/Maps/Leaflet/OSMap/OSMap.ts b/src/Providers/Maps/Leaflet/OSMap/OSMap.ts index 79d6b1b7..6e84d003 100644 --- a/src/Providers/Maps/Leaflet/OSMap/OSMap.ts +++ b/src/Providers/Maps/Leaflet/OSMap/OSMap.ts @@ -269,6 +269,7 @@ namespace Provider.Maps.Leaflet.OSMap { //If there are markers, let's choose the map center accordingly. //Otherwise, the map center will be the one defined in the configs. if (this.markers.length > 0) { + const markerProvider = this.markers[0].provider as L.Marker; if (this.markers.length > 1) { //As the map has more than one marker, let's see if the map //center should be changed. @@ -276,16 +277,16 @@ namespace Provider.Maps.Leaflet.OSMap { //If the user hasn't change zoom, or the developer is ignoring //it (current behavior), then the map will be centered tentatively //in the first marker. - position = this.markers[0].provider.getLatLng(); + position = markerProvider.getLatLng(); } else { //If the user has zoomed and the developer intends to respect user zoom //then the current map center will be used. position = this.provider.getCenter(); } - } else if (this.markers[0].provider !== undefined) { + } else if (markerProvider !== undefined) { //If there's only one marker, and is already created, its location will be //used as the map center. - position = this.markers[0].provider.getLatLng(); + position = markerProvider.getLatLng(); } } From af38a2bd70d173f1324835ea0c007fa3745ffc72 Mon Sep 17 00:00:00 2001 From: rug Date: Fri, 16 Feb 2024 15:07:33 +0100 Subject: [PATCH 11/12] Code improvements --- src/OSFramework/Maps/OSMap/AbstractMap.ts | 2 +- src/Providers/Maps/Google/Features/Zoom.ts | 4 +++- src/Providers/Maps/Google/OSMap/OSMap.ts | 8 ++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/OSFramework/Maps/OSMap/AbstractMap.ts b/src/OSFramework/Maps/OSMap/AbstractMap.ts index df1eca40..7da7b262 100644 --- a/src/OSFramework/Maps/OSMap/AbstractMap.ts +++ b/src/OSFramework/Maps/OSMap/AbstractMap.ts @@ -236,7 +236,7 @@ namespace OSFramework.Maps.OSMap { } public hasMarkerClusterer(): boolean { - return this._features && this._features.markerClusterer && this._features.markerClusterer.isEnabled; + return this._features?.markerClusterer?.isEnabled; } public hasShape(shapeId: string): boolean { diff --git a/src/Providers/Maps/Google/Features/Zoom.ts b/src/Providers/Maps/Google/Features/Zoom.ts index 6a2c6009..216e9d02 100644 --- a/src/Providers/Maps/Google/Features/Zoom.ts +++ b/src/Providers/Maps/Google/Features/Zoom.ts @@ -21,7 +21,9 @@ namespace Provider.Maps.Google.Feature { const bounds = new google.maps.LatLngBounds(); this._map.markers.forEach(function (item) { if (item.provider === undefined) return; - bounds.extend(item.provider.position.toJSON()); + // The TS definitions appear to be outdated. + // eslint-disable-next-line @typescript-eslint/no-explicit-any + bounds.extend((item.provider as google.maps.Marker as any).position.toJSON()); }); if (useShapes) { diff --git a/src/Providers/Maps/Google/OSMap/OSMap.ts b/src/Providers/Maps/Google/OSMap/OSMap.ts index 23b392f4..5ee0a939 100644 --- a/src/Providers/Maps/Google/OSMap/OSMap.ts +++ b/src/Providers/Maps/Google/OSMap/OSMap.ts @@ -411,7 +411,9 @@ namespace Provider.Maps.Google.OSMap { //center will not be changed. if (isDefault || this.features.zoom.isAutofit) { //Let's use the first marker as the center of the map. - position = this.markers[0].provider.position.toJSON(); + // The TS definitions appear to be outdated. + // eslint-disable-next-line @typescript-eslint/no-explicit-any + position = (this.markers[0].provider as google.maps.Marker as any).position.toJSON(); } } } else { @@ -422,7 +424,9 @@ namespace Provider.Maps.Google.OSMap { } else if (this.markers[0].provider !== undefined) { //If there's only one marker, and is already created, its location will be //used as the map center. - position = this.markers[0].provider.position.toJSON(); + // The TS definitions appear to be outdated. + // eslint-disable-next-line @typescript-eslint/no-explicit-any + position = (this.markers[0].provider as google.maps.Marker as any).position.toJSON(); } } From ec16fde10b500327b1e08c8aa90541eb53b9831f Mon Sep 17 00:00:00 2001 From: rug Date: Mon, 19 Feb 2024 12:27:53 +0100 Subject: [PATCH 12/12] Removing comment --- src/Providers/Maps/Leaflet/DrawingTools/DrawingTools.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Providers/Maps/Leaflet/DrawingTools/DrawingTools.ts b/src/Providers/Maps/Leaflet/DrawingTools/DrawingTools.ts index 3ca2d394..daf1384c 100644 --- a/src/Providers/Maps/Leaflet/DrawingTools/DrawingTools.ts +++ b/src/Providers/Maps/Leaflet/DrawingTools/DrawingTools.ts @@ -31,9 +31,6 @@ namespace Provider.Maps.Leaflet.DrawingTools { > { // FeatureGroup : as required by Leaflet private _toolsGroup: L.FeatureGroup; - //TODO - At the moment the type is not well defined and it doesn't included setDrawingOptions for example, - // - When this is done the overwrite of the _provider is not needed anymore. - //protected _provider: any; constructor( map: OSFramework.Maps.OSMap.IMap,