widgets.maps.layer.provider.custom.attribution
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/map-layer-settings-panel.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/map-layer-settings-panel.component.ts
index b8e2951813..65d69b3982 100644
--- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/map-layer-settings-panel.component.ts
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/map-layer-settings-panel.component.ts
@@ -1,5 +1,6 @@
// SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
-// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
+// SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
import { Component, DestroyRef, EventEmitter, Input, OnInit, Output, ViewEncapsulation } from '@angular/core';
import { TbPopoverComponent } from '@shared/components/popover.component';
import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms';
@@ -9,6 +10,8 @@ import {
cartoLayerTypes,
defaultLayerTitle,
defaultMapLayerSettings,
+ esriLayerTranslationMap,
+ esriLayerTypes,
googleMapLayerTranslationMap,
googleMapLayerTypes,
hereLayerTranslationMap,
@@ -19,8 +22,9 @@ import {
mapProviderTranslationMap,
openFreeMapStyleTranslationMap,
openFreeMapStyleTypes,
+ mapLayerHasReferenceLayerApiKey,
mapProviderHasApiKey,
- mapProviderRequiresApiKey,
+ mapProviderApiKeyMissingWarningMap,
openStreetLayerTypes,
openStreetMapLayerTranslationMap, referenceLayerTypes, referenceLayerTypeTranslationMap,
tencentLayerTranslationMap,
@@ -56,6 +60,10 @@ export class MapLayerSettingsPanelComponent implements OnInit {
cartoLayerTranslationMap = cartoLayerTranslationMap;
+ esriLayerTypes = esriLayerTypes;
+
+ esriLayerTranslationMap = esriLayerTranslationMap;
+
googleMapLayerTypes = googleMapLayerTypes;
googleMapLayerTranslationMap = googleMapLayerTranslationMap;
@@ -97,8 +105,9 @@ export class MapLayerSettingsPanelComponent implements OnInit {
tileUrl: [null, [Validators.required]],
vectorTiles: [false, []],
customAttribution: [null, []],
- apiKey: [null, [Validators.required]],
- referenceLayer: [null, []]
+ apiKey: [null, []],
+ referenceLayer: [null, []],
+ referenceLayerApiKey: [null, []]
}
);
this.layerFormGroup.patchValue(
@@ -109,6 +118,11 @@ export class MapLayerSettingsPanelComponent implements OnInit {
).subscribe((newProvider: MapProvider) => {
this.onProviderChanged(newProvider);
});
+ this.layerFormGroup.get('referenceLayer').valueChanges.pipe(
+ takeUntilDestroyed(this.destroyRef)
+ ).subscribe(() => {
+ this.updateValidators();
+ });
this.layerFormGroup.get('vectorTiles').valueChanges.pipe(
takeUntilDestroyed(this.destroyRef)
).subscribe(() => {
@@ -133,6 +147,19 @@ export class MapLayerSettingsPanelComponent implements OnInit {
return mapProviderHasApiKey(this.layerFormGroup.get('provider').value);
}
+ referenceLayerHasOwnApiKey(): boolean {
+ return mapLayerHasReferenceLayerApiKey(this.layerFormGroup.get('provider').value, this.layerFormGroup.get('referenceLayer').value);
+ }
+
+ apiKeyMissingWarning(): string {
+ return this.layerFormGroup.get('apiKey').value ? null :
+ mapProviderApiKeyMissingWarningMap.get(this.layerFormGroup.get('provider').value);
+ }
+
+ referenceLayerApiKeyMissing(): boolean {
+ return !this.layerFormGroup.get('referenceLayerApiKey').value;
+ }
+
applyLayerSettings() {
const layerSettings: MapLayerSettings = this.layerFormGroup.value;
this.mapLayerSettingsApplied.emit(layerSettings);
@@ -161,10 +188,14 @@ export class MapLayerSettingsPanelComponent implements OnInit {
this.layerFormGroup.get('layerType').enable({emitEvent: false});
}
if (mapProviderHasApiKey(provider)) {
- this.layerFormGroup.get('apiKey').setValidators(mapProviderRequiresApiKey(provider) ? [Validators.required] : []);
this.layerFormGroup.get('apiKey').enable({emitEvent: false});
} else {
this.layerFormGroup.get('apiKey').disable({emitEvent: false});
}
+ if (mapLayerHasReferenceLayerApiKey(provider, this.layerFormGroup.get('referenceLayer').value)) {
+ this.layerFormGroup.get('referenceLayerApiKey').enable({emitEvent: false});
+ } else {
+ this.layerFormGroup.get('referenceLayerApiKey').disable({emitEvent: false});
+ }
}
}
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/map/legacy/google-map-provider-settings.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/settings/map/legacy/google-map-provider-settings.component.html
index d68b258d43..6d807e6d6f 100644
--- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/map/legacy/google-map-provider-settings.component.html
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/map/legacy/google-map-provider-settings.component.html
@@ -1,13 +1,29 @@