-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Expand file tree
/
Copy pathmap-base-layer.ts
More file actions
47 lines (40 loc) · 1.14 KB
/
map-base-layer.ts
File metadata and controls
47 lines (40 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {Directive, NgZone, OnDestroy, OnInit, inject} from '@angular/core';
import {GoogleMap} from './google-map/google-map';
@Directive({
selector: 'map-base-layer',
exportAs: 'mapBaseLayer',
})
export class MapBaseLayer implements OnInit, OnDestroy {
protected readonly _map = inject(GoogleMap);
protected readonly _ngZone = inject(NgZone);
ngOnInit() {
if (this._map._isBrowser) {
this._ngZone.runOutsideAngular(() => {
this._initializeObject();
});
this._assertInitialized();
this._setMap();
}
}
ngOnDestroy() {
this._unsetMap();
}
private _assertInitialized() {
if (!this._map.googleMap) {
throw Error(
'Cannot access Google Map information before the API has been initialized. ' +
'Please wait for the API to load before trying to interact with it.',
);
}
}
protected _initializeObject() {}
protected _setMap() {}
protected _unsetMap() {}
}