...
|
...
|
@@ -39,7 +39,7 @@ import { BehaviorSubject, Observable, of } from 'rxjs'; |
39
|
39
|
import { filter } from 'rxjs/operators';
|
40
|
40
|
import { Polyline } from './polyline';
|
41
|
41
|
import { Polygon } from './polygon';
|
42
|
|
-import { createTooltip, parseArray, safeExecute } from '@home/components/widget/lib/maps/maps-utils';
|
|
42
|
+import { createLoadingDiv, createTooltip, parseArray, safeExecute } from '@home/components/widget/lib/maps/maps-utils';
|
43
|
43
|
import { WidgetContext } from '@home/models/widget-component.models';
|
44
|
44
|
import { DatasourceData } from '@shared/models/widget.models';
|
45
|
45
|
import { deepClone, isDefinedAndNotNull } from '@core/utils';
|
...
|
...
|
@@ -60,6 +60,8 @@ export default abstract class LeafletMap { |
60
|
60
|
markersData: FormattedData[] = [];
|
61
|
61
|
polygonsData: FormattedData[] = [];
|
62
|
62
|
defaultMarkerIconInfo: { size: number[], icon: Icon };
|
|
63
|
+ loadingDiv: JQuery<HTMLElement>;
|
|
64
|
+ loading = false;
|
63
|
65
|
|
64
|
66
|
protected constructor(public ctx: WidgetContext,
|
65
|
67
|
public $container: HTMLElement,
|
...
|
...
|
@@ -169,6 +171,24 @@ export default abstract class LeafletMap { |
169
|
171
|
}
|
170
|
172
|
}
|
171
|
173
|
|
|
174
|
+ public setLoading(loading: boolean) {
|
|
175
|
+ if (this.loading !== loading) {
|
|
176
|
+ this.loading = loading;
|
|
177
|
+ this.ready$.subscribe(() => {
|
|
178
|
+ if (this.loading) {
|
|
179
|
+ if (!this.loadingDiv) {
|
|
180
|
+ this.loadingDiv = createLoadingDiv(this.ctx.translate.instant('common.loading'));
|
|
181
|
+ }
|
|
182
|
+ this.$container.append(this.loadingDiv[0]);
|
|
183
|
+ } else {
|
|
184
|
+ if (this.loadingDiv) {
|
|
185
|
+ this.loadingDiv.remove();
|
|
186
|
+ }
|
|
187
|
+ }
|
|
188
|
+ });
|
|
189
|
+ }
|
|
190
|
+ }
|
|
191
|
+
|
172
|
192
|
public setMap(map: L.Map) {
|
173
|
193
|
this.map = map;
|
174
|
194
|
if (this.options.useDefaultCenterPosition) {
|
...
|
...
|
|