diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts index bdd3f8875d..7a2d091588 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts @@ -39,7 +39,7 @@ import { BehaviorSubject, Observable, of } from 'rxjs'; import { filter } from 'rxjs/operators'; import { Polyline } from './polyline'; import { Polygon } from './polygon'; -import { createTooltip, parseArray, safeExecute } from '@home/components/widget/lib/maps/maps-utils'; +import { createLoadingDiv, createTooltip, parseArray, safeExecute } from '@home/components/widget/lib/maps/maps-utils'; import { WidgetContext } from '@home/models/widget-component.models'; import { DatasourceData } from '@shared/models/widget.models'; import { deepClone, isDefinedAndNotNull } from '@core/utils'; @@ -60,6 +60,8 @@ export default abstract class LeafletMap { markersData: FormattedData[] = []; polygonsData: FormattedData[] = []; defaultMarkerIconInfo: { size: number[], icon: Icon }; + loadingDiv: JQuery; + loading = false; protected constructor(public ctx: WidgetContext, public $container: HTMLElement, @@ -169,6 +171,24 @@ export default abstract class LeafletMap { } } + public setLoading(loading: boolean) { + if (this.loading !== loading) { + this.loading = loading; + this.ready$.subscribe(() => { + if (this.loading) { + if (!this.loadingDiv) { + this.loadingDiv = createLoadingDiv(this.ctx.translate.instant('common.loading')); + } + this.$container.append(this.loadingDiv[0]); + } else { + if (this.loadingDiv) { + this.loadingDiv.remove(); + } + } + }); + } + } + public setMap(map: L.Map) { this.map = map; if (this.options.useDefaultCenterPosition) { diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/map-widget2.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/map-widget2.ts index fd06598fb3..7acc6e92e5 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/map-widget2.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/map-widget2.ts @@ -85,6 +85,7 @@ export class MapWidgetController implements MapWidgetInterface { textSearch: null, dynamic: true }; + this.map.setLoading(true); this.ctx.defaultSubscription.subscribeAllForPaginatedData(this.pageLink, null); } @@ -279,6 +280,7 @@ export class MapWidgetController implements MapWidgetInterface { if (this.settings.draggableMarker) { this.map.setDataSources(formattedData); } + this.map.setLoading(false); } resize() { diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/maps-utils.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/maps-utils.ts index 0bb6c05aac..ee785e6b04 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/maps-utils.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/maps-utils.ts @@ -322,3 +322,28 @@ export function calculateNewPointCoordinate(coordinate: number, imageSize: numbe } return pointCoordinate; } + +export function createLoadingDiv(loadingText: string): JQuery { + return $(` +
+ ${loadingText} +
+ `); +}