@angular/google-maps 17.1.0-next.3 → 17.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -68,6 +68,13 @@ class MapEventManager {
68
68
  }
69
69
  }
70
70
 
71
+ /** Imports a Google Maps library. */
72
+ function importLibrary(name, symbol) {
73
+ // TODO(crisbeto): needs to cast to `any` to avoid some internal limitations around typings.
74
+ // Should be cleaned up eventually.
75
+ return window.google.maps.importLibrary(name).then((library) => library[symbol]);
76
+ }
77
+
71
78
  /// <reference types="google.maps" />
72
79
  /** default options set to the Googleplex */
73
80
  const DEFAULT_OPTIONS = {
@@ -248,14 +255,25 @@ class GoogleMap {
248
255
  // Create the object outside the zone so its events don't trigger change detection.
249
256
  // We'll bring it back in inside the `MapEventManager` only for the events that the
250
257
  // user has subscribed to.
251
- this._ngZone.runOutsideAngular(() => {
252
- this.googleMap = new google.maps.Map(this._mapEl, this._combineOptions());
253
- });
258
+ if (google.maps.Map) {
259
+ this._initialize(google.maps.Map);
260
+ }
261
+ else {
262
+ this._ngZone.runOutsideAngular(() => {
263
+ importLibrary('maps', 'Map').then(mapConstructor => this._initialize(mapConstructor));
264
+ });
265
+ }
266
+ }
267
+ }
268
+ _initialize(mapConstructor) {
269
+ this._ngZone.runOutsideAngular(() => {
270
+ this.googleMap = new mapConstructor(this._mapEl, this._combineOptions());
254
271
  this._eventManager.setTarget(this.googleMap);
255
272
  this.mapInitialized.emit(this.googleMap);
256
- }
273
+ });
257
274
  }
258
275
  ngOnDestroy() {
276
+ this.mapInitialized.complete();
259
277
  this._eventManager.destroy();
260
278
  if (this._isBrowser) {
261
279
  const googleMapsWindow = window;
@@ -398,6 +416,12 @@ class GoogleMap {
398
416
  this._assertInitialized();
399
417
  return this.googleMap.overlayMapTypes;
400
418
  }
419
+ /** Returns a promise that resolves when the map has been initialized. */
420
+ _resolveMap() {
421
+ return this.googleMap
422
+ ? Promise.resolve(this.googleMap)
423
+ : this.mapInitialized.pipe(take(1)).toPromise();
424
+ }
401
425
  _setSize() {
402
426
  if (this._mapEl) {
403
427
  const styles = this._mapEl.style;
@@ -427,10 +451,10 @@ class GoogleMap {
427
451
  'Please wait for the API to load before trying to interact with it.');
428
452
  }
429
453
  }
430
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: GoogleMap, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Component }); }
431
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.1.0-next.2", type: GoogleMap, isStandalone: true, selector: "google-map", inputs: { height: "height", width: "width", mapTypeId: "mapTypeId", center: "center", zoom: "zoom", options: "options" }, outputs: { mapInitialized: "mapInitialized", authFailure: "authFailure", boundsChanged: "boundsChanged", centerChanged: "centerChanged", mapClick: "mapClick", mapDblclick: "mapDblclick", mapDrag: "mapDrag", mapDragend: "mapDragend", mapDragstart: "mapDragstart", headingChanged: "headingChanged", idle: "idle", maptypeidChanged: "maptypeidChanged", mapMousemove: "mapMousemove", mapMouseout: "mapMouseout", mapMouseover: "mapMouseover", projectionChanged: "projectionChanged", mapRightclick: "mapRightclick", tilesloaded: "tilesloaded", tiltChanged: "tiltChanged", zoomChanged: "zoomChanged" }, exportAs: ["googleMap"], usesOnChanges: true, ngImport: i0, template: '<div class="map-container"></div><ng-content />', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
454
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: GoogleMap, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Component }); }
455
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.1.0-next.5", type: GoogleMap, isStandalone: true, selector: "google-map", inputs: { height: "height", width: "width", mapTypeId: "mapTypeId", center: "center", zoom: "zoom", options: "options" }, outputs: { mapInitialized: "mapInitialized", authFailure: "authFailure", boundsChanged: "boundsChanged", centerChanged: "centerChanged", mapClick: "mapClick", mapDblclick: "mapDblclick", mapDrag: "mapDrag", mapDragend: "mapDragend", mapDragstart: "mapDragstart", headingChanged: "headingChanged", idle: "idle", maptypeidChanged: "maptypeidChanged", mapMousemove: "mapMousemove", mapMouseout: "mapMouseout", mapMouseover: "mapMouseover", projectionChanged: "projectionChanged", mapRightclick: "mapRightclick", tilesloaded: "tilesloaded", tiltChanged: "tiltChanged", zoomChanged: "zoomChanged" }, exportAs: ["googleMap"], usesOnChanges: true, ngImport: i0, template: '<div class="map-container"></div><ng-content />', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
432
456
  }
433
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: GoogleMap, decorators: [{
457
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: GoogleMap, decorators: [{
434
458
  type: Component,
435
459
  args: [{
436
460
  selector: 'google-map',
@@ -532,10 +556,10 @@ class MapBaseLayer {
532
556
  _initializeObject() { }
533
557
  _setMap() { }
534
558
  _unsetMap() { }
535
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapBaseLayer, deps: [{ token: GoogleMap }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
536
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.0-next.2", type: MapBaseLayer, isStandalone: true, selector: "map-base-layer", exportAs: ["mapBaseLayer"], ngImport: i0 }); }
559
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapBaseLayer, deps: [{ token: GoogleMap }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
560
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.0-next.5", type: MapBaseLayer, isStandalone: true, selector: "map-base-layer", exportAs: ["mapBaseLayer"], ngImport: i0 }); }
537
561
  }
538
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapBaseLayer, decorators: [{
562
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapBaseLayer, decorators: [{
539
563
  type: Directive,
540
564
  args: [{
541
565
  selector: 'map-base-layer',
@@ -550,36 +574,60 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2",
550
574
  *
551
575
  * See developers.google.com/maps/documentation/javascript/reference/map#BicyclingLayer
552
576
  */
553
- class MapBicyclingLayer extends MapBaseLayer {
554
- _initializeObject() {
555
- this.bicyclingLayer = new google.maps.BicyclingLayer();
577
+ class MapBicyclingLayer {
578
+ constructor() {
579
+ this._map = inject(GoogleMap);
580
+ this._zone = inject(NgZone);
581
+ /** Event emitted when the bicycling layer is initialized. */
582
+ this.bicyclingLayerInitialized = new EventEmitter();
556
583
  }
557
- _setMap() {
558
- this._assertLayerInitialized();
559
- this.bicyclingLayer.setMap(this._map.googleMap);
560
- }
561
- _unsetMap() {
562
- if (this.bicyclingLayer) {
563
- this.bicyclingLayer.setMap(null);
584
+ ngOnInit() {
585
+ if (this._map._isBrowser) {
586
+ if (google.maps.BicyclingLayer && this._map.googleMap) {
587
+ this._initialize(this._map.googleMap, google.maps.BicyclingLayer);
588
+ }
589
+ else {
590
+ this._zone.runOutsideAngular(() => {
591
+ Promise.all([
592
+ this._map._resolveMap(),
593
+ importLibrary('maps', 'BicyclingLayer'),
594
+ ]).then(([map, layerConstructor]) => {
595
+ this._initialize(map, layerConstructor);
596
+ });
597
+ });
598
+ }
564
599
  }
565
600
  }
601
+ _initialize(map, layerConstructor) {
602
+ this._zone.runOutsideAngular(() => {
603
+ this.bicyclingLayer = new layerConstructor();
604
+ this.bicyclingLayerInitialized.emit(this.bicyclingLayer);
605
+ this._assertLayerInitialized();
606
+ this.bicyclingLayer.setMap(map);
607
+ });
608
+ }
609
+ ngOnDestroy() {
610
+ this.bicyclingLayer?.setMap(null);
611
+ }
566
612
  _assertLayerInitialized() {
567
613
  if (!this.bicyclingLayer) {
568
614
  throw Error('Cannot interact with a Google Map Bicycling Layer before it has been initialized. ' +
569
615
  'Please wait for the Transit Layer to load before trying to interact with it.');
570
616
  }
571
617
  }
572
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapBicyclingLayer, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
573
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.0-next.2", type: MapBicyclingLayer, isStandalone: true, selector: "map-bicycling-layer", exportAs: ["mapBicyclingLayer"], usesInheritance: true, ngImport: i0 }); }
618
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapBicyclingLayer, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
619
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.0-next.5", type: MapBicyclingLayer, isStandalone: true, selector: "map-bicycling-layer", outputs: { bicyclingLayerInitialized: "bicyclingLayerInitialized" }, exportAs: ["mapBicyclingLayer"], ngImport: i0 }); }
574
620
  }
575
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapBicyclingLayer, decorators: [{
621
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapBicyclingLayer, decorators: [{
576
622
  type: Directive,
577
623
  args: [{
578
624
  selector: 'map-bicycling-layer',
579
625
  exportAs: 'mapBicyclingLayer',
580
626
  standalone: true,
581
627
  }]
582
- }] });
628
+ }], propDecorators: { bicyclingLayerInitialized: [{
629
+ type: Output
630
+ }] } });
583
631
 
584
632
  /// <reference types="google.maps" />
585
633
  /**
@@ -669,34 +717,51 @@ class MapCircle {
669
717
  * developers.google.com/maps/documentation/javascript/reference/polygon#Circle.rightclick
670
718
  */
671
719
  this.circleRightclick = this._eventManager.getLazyEmitter('rightclick');
720
+ /** Event emitted when the circle is initialized. */
721
+ this.circleInitialized = new EventEmitter();
672
722
  }
673
723
  ngOnInit() {
674
- if (this._map._isBrowser) {
675
- this._combineOptions()
676
- .pipe(take(1))
677
- .subscribe(options => {
678
- // Create the object outside the zone so its events don't trigger change detection.
679
- // We'll bring it back in inside the `MapEventManager` only for the events that the
680
- // user has subscribed to.
724
+ if (!this._map._isBrowser) {
725
+ return;
726
+ }
727
+ this._combineOptions()
728
+ .pipe(take(1))
729
+ .subscribe(options => {
730
+ if (google.maps.Circle && this._map.googleMap) {
731
+ this._initialize(this._map.googleMap, google.maps.Circle, options);
732
+ }
733
+ else {
681
734
  this._ngZone.runOutsideAngular(() => {
682
- this.circle = new google.maps.Circle(options);
735
+ Promise.all([
736
+ this._map._resolveMap(),
737
+ importLibrary('maps', 'Circle'),
738
+ ]).then(([map, circleConstructor]) => {
739
+ this._initialize(map, circleConstructor, options);
740
+ });
683
741
  });
684
- this._assertInitialized();
685
- this.circle.setMap(this._map.googleMap);
686
- this._eventManager.setTarget(this.circle);
687
- });
742
+ }
743
+ });
744
+ }
745
+ _initialize(map, circleConstructor, options) {
746
+ // Create the object outside the zone so its events don't trigger change detection.
747
+ // We'll bring it back in inside the `MapEventManager` only for the events that the
748
+ // user has subscribed to.
749
+ this._ngZone.runOutsideAngular(() => {
750
+ this.circle = new circleConstructor(options);
751
+ this._assertInitialized();
752
+ this.circle.setMap(map);
753
+ this._eventManager.setTarget(this.circle);
754
+ this.circleInitialized.emit(this.circle);
688
755
  this._watchForOptionsChanges();
689
756
  this._watchForCenterChanges();
690
757
  this._watchForRadiusChanges();
691
- }
758
+ });
692
759
  }
693
760
  ngOnDestroy() {
694
761
  this._eventManager.destroy();
695
762
  this._destroyed.next();
696
763
  this._destroyed.complete();
697
- if (this.circle) {
698
- this.circle.setMap(null);
699
- }
764
+ this.circle?.setMap(null);
700
765
  }
701
766
  /**
702
767
  * @see
@@ -780,20 +845,16 @@ class MapCircle {
780
845
  }
781
846
  _assertInitialized() {
782
847
  if (typeof ngDevMode === 'undefined' || ngDevMode) {
783
- if (!this._map.googleMap) {
784
- throw Error('Cannot access Google Map information before the API has been initialized. ' +
785
- 'Please wait for the API to load before trying to interact with it.');
786
- }
787
848
  if (!this.circle) {
788
849
  throw Error('Cannot interact with a Google Map Circle before it has been ' +
789
850
  'initialized. Please wait for the Circle to load before trying to interact with it.');
790
851
  }
791
852
  }
792
853
  }
793
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapCircle, deps: [{ token: GoogleMap }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
794
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.0-next.2", type: MapCircle, isStandalone: true, selector: "map-circle", inputs: { options: "options", center: "center", radius: "radius" }, outputs: { centerChanged: "centerChanged", circleClick: "circleClick", circleDblclick: "circleDblclick", circleDrag: "circleDrag", circleDragend: "circleDragend", circleDragstart: "circleDragstart", circleMousedown: "circleMousedown", circleMousemove: "circleMousemove", circleMouseout: "circleMouseout", circleMouseover: "circleMouseover", circleMouseup: "circleMouseup", radiusChanged: "radiusChanged", circleRightclick: "circleRightclick" }, exportAs: ["mapCircle"], ngImport: i0 }); }
854
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapCircle, deps: [{ token: GoogleMap }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
855
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.0-next.5", type: MapCircle, isStandalone: true, selector: "map-circle", inputs: { options: "options", center: "center", radius: "radius" }, outputs: { centerChanged: "centerChanged", circleClick: "circleClick", circleDblclick: "circleDblclick", circleDrag: "circleDrag", circleDragend: "circleDragend", circleDragstart: "circleDragstart", circleMousedown: "circleMousedown", circleMousemove: "circleMousemove", circleMouseout: "circleMouseout", circleMouseover: "circleMouseover", circleMouseup: "circleMouseup", radiusChanged: "radiusChanged", circleRightclick: "circleRightclick", circleInitialized: "circleInitialized" }, exportAs: ["mapCircle"], ngImport: i0 }); }
795
856
  }
796
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapCircle, decorators: [{
857
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapCircle, decorators: [{
797
858
  type: Directive,
798
859
  args: [{
799
860
  selector: 'map-circle',
@@ -832,6 +893,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2",
832
893
  type: Output
833
894
  }], circleRightclick: [{
834
895
  type: Output
896
+ }], circleInitialized: [{
897
+ type: Output
835
898
  }] } });
836
899
 
837
900
  /// <reference types="google.maps" />
@@ -865,19 +928,37 @@ class MapDirectionsRenderer {
865
928
  * #DirectionsRenderer.directions_changed
866
929
  */
867
930
  this.directionsChanged = this._eventManager.getLazyEmitter('directions_changed');
931
+ /** Event emitted when the directions renderer is initialized. */
932
+ this.directionsRendererInitialized = new EventEmitter();
868
933
  }
869
934
  ngOnInit() {
870
935
  if (this._googleMap._isBrowser) {
871
- // Create the object outside the zone so its events don't trigger change detection.
872
- // We'll bring it back in inside the `MapEventManager` only for the events that the
873
- // user has subscribed to.
874
- this._ngZone.runOutsideAngular(() => {
875
- this.directionsRenderer = new google.maps.DirectionsRenderer(this._combineOptions());
876
- });
936
+ if (google.maps.DirectionsRenderer && this._googleMap.googleMap) {
937
+ this._initialize(this._googleMap.googleMap, google.maps.DirectionsRenderer);
938
+ }
939
+ else {
940
+ this._ngZone.runOutsideAngular(() => {
941
+ Promise.all([
942
+ this._googleMap._resolveMap(),
943
+ importLibrary('routes', 'DirectionsRenderer'),
944
+ ]).then(([map, rendererConstructor]) => {
945
+ this._initialize(map, rendererConstructor);
946
+ });
947
+ });
948
+ }
949
+ }
950
+ }
951
+ _initialize(map, rendererConstructor) {
952
+ // Create the object outside the zone so its events don't trigger change detection.
953
+ // We'll bring it back in inside the `MapEventManager` only for the events that the
954
+ // user has subscribed to.
955
+ this._ngZone.runOutsideAngular(() => {
956
+ this.directionsRenderer = new rendererConstructor(this._combineOptions());
877
957
  this._assertInitialized();
878
- this.directionsRenderer.setMap(this._googleMap.googleMap);
958
+ this.directionsRenderer.setMap(map);
879
959
  this._eventManager.setTarget(this.directionsRenderer);
880
- }
960
+ this.directionsRendererInitialized.emit(this.directionsRenderer);
961
+ });
881
962
  }
882
963
  ngOnChanges(changes) {
883
964
  if (this.directionsRenderer) {
@@ -891,9 +972,7 @@ class MapDirectionsRenderer {
891
972
  }
892
973
  ngOnDestroy() {
893
974
  this._eventManager.destroy();
894
- if (this.directionsRenderer) {
895
- this.directionsRenderer.setMap(null);
896
- }
975
+ this.directionsRenderer?.setMap(null);
897
976
  }
898
977
  /**
899
978
  * See developers.google.com/maps/documentation/javascript/reference/directions
@@ -929,10 +1008,6 @@ class MapDirectionsRenderer {
929
1008
  }
930
1009
  _assertInitialized() {
931
1010
  if (typeof ngDevMode === 'undefined' || ngDevMode) {
932
- if (!this._googleMap.googleMap) {
933
- throw Error('Cannot access Google Map information before the API has been initialized. ' +
934
- 'Please wait for the API to load before trying to interact with it.');
935
- }
936
1011
  if (!this.directionsRenderer) {
937
1012
  throw Error('Cannot interact with a Google Map Directions Renderer before it has been ' +
938
1013
  'initialized. Please wait for the Directions Renderer to load before trying ' +
@@ -940,10 +1015,10 @@ class MapDirectionsRenderer {
940
1015
  }
941
1016
  }
942
1017
  }
943
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapDirectionsRenderer, deps: [{ token: GoogleMap }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
944
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.0-next.2", type: MapDirectionsRenderer, isStandalone: true, selector: "map-directions-renderer", inputs: { directions: "directions", options: "options" }, outputs: { directionsChanged: "directionsChanged" }, exportAs: ["mapDirectionsRenderer"], usesOnChanges: true, ngImport: i0 }); }
1018
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapDirectionsRenderer, deps: [{ token: GoogleMap }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
1019
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.0-next.5", type: MapDirectionsRenderer, isStandalone: true, selector: "map-directions-renderer", inputs: { directions: "directions", options: "options" }, outputs: { directionsChanged: "directionsChanged", directionsRendererInitialized: "directionsRendererInitialized" }, exportAs: ["mapDirectionsRenderer"], usesOnChanges: true, ngImport: i0 }); }
945
1020
  }
946
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapDirectionsRenderer, decorators: [{
1021
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapDirectionsRenderer, decorators: [{
947
1022
  type: Directive,
948
1023
  args: [{
949
1024
  selector: 'map-directions-renderer',
@@ -956,6 +1031,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2",
956
1031
  type: Input
957
1032
  }], directionsChanged: [{
958
1033
  type: Output
1034
+ }], directionsRendererInitialized: [{
1035
+ type: Output
959
1036
  }] } });
960
1037
 
961
1038
  /// <reference types="google.maps" />
@@ -1001,6 +1078,8 @@ class MapGroundOverlay {
1001
1078
  * #GroundOverlay.dblclick
1002
1079
  */
1003
1080
  this.mapDblclick = this._eventManager.getLazyEmitter('dblclick');
1081
+ /** Event emitted when the ground overlay is initialized. */
1082
+ this.groundOverlayInitialized = new EventEmitter();
1004
1083
  }
1005
1084
  ngOnInit() {
1006
1085
  if (this._map._isBrowser) {
@@ -1012,32 +1091,51 @@ class MapGroundOverlay {
1012
1091
  this.groundOverlay.setMap(null);
1013
1092
  this.groundOverlay = undefined;
1014
1093
  }
1015
- // Create the object outside the zone so its events don't trigger change detection.
1016
- // We'll bring it back in inside the `MapEventManager` only for the events that the
1017
- // user has subscribed to.
1018
- if (bounds) {
1094
+ if (!bounds) {
1095
+ return;
1096
+ }
1097
+ if (google.maps.GroundOverlay && this._map.googleMap) {
1098
+ this._initialize(this._map.googleMap, google.maps.GroundOverlay, bounds);
1099
+ }
1100
+ else {
1019
1101
  this._ngZone.runOutsideAngular(() => {
1020
- this.groundOverlay = new google.maps.GroundOverlay(this._url.getValue(), bounds, {
1021
- clickable: this.clickable,
1022
- opacity: this._opacity.value,
1102
+ Promise.all([
1103
+ this._map._resolveMap(),
1104
+ importLibrary('maps', 'GroundOverlay'),
1105
+ ]).then(([map, overlayConstructor]) => {
1106
+ this._initialize(map, overlayConstructor, bounds);
1023
1107
  });
1024
1108
  });
1025
- this._assertInitialized();
1026
- this.groundOverlay.setMap(this._map.googleMap);
1027
- this._eventManager.setTarget(this.groundOverlay);
1028
1109
  }
1029
1110
  });
1030
- this._watchForOpacityChanges();
1031
- this._watchForUrlChanges();
1032
1111
  }
1033
1112
  }
1113
+ _initialize(map, overlayConstructor, bounds) {
1114
+ // Create the object outside the zone so its events don't trigger change detection.
1115
+ // We'll bring it back in inside the `MapEventManager` only for the events that the
1116
+ // user has subscribed to.
1117
+ this._ngZone.runOutsideAngular(() => {
1118
+ this.groundOverlay = new overlayConstructor(this._url.getValue(), bounds, {
1119
+ clickable: this.clickable,
1120
+ opacity: this._opacity.value,
1121
+ });
1122
+ this._assertInitialized();
1123
+ this.groundOverlay.setMap(map);
1124
+ this._eventManager.setTarget(this.groundOverlay);
1125
+ this.groundOverlayInitialized.emit(this.groundOverlay);
1126
+ // We only need to set up the watchers once.
1127
+ if (!this._hasWatchers) {
1128
+ this._hasWatchers = true;
1129
+ this._watchForOpacityChanges();
1130
+ this._watchForUrlChanges();
1131
+ }
1132
+ });
1133
+ }
1034
1134
  ngOnDestroy() {
1035
1135
  this._eventManager.destroy();
1036
1136
  this._destroyed.next();
1037
1137
  this._destroyed.complete();
1038
- if (this.groundOverlay) {
1039
- this.groundOverlay.setMap(null);
1040
- }
1138
+ this.groundOverlay?.setMap(null);
1041
1139
  }
1042
1140
  /**
1043
1141
  * See
@@ -1069,37 +1167,33 @@ class MapGroundOverlay {
1069
1167
  _watchForOpacityChanges() {
1070
1168
  this._opacity.pipe(takeUntil(this._destroyed)).subscribe(opacity => {
1071
1169
  if (opacity != null) {
1072
- this._assertInitialized();
1073
- this.groundOverlay.setOpacity(opacity);
1170
+ this.groundOverlay?.setOpacity(opacity);
1074
1171
  }
1075
1172
  });
1076
1173
  }
1077
1174
  _watchForUrlChanges() {
1078
1175
  this._url.pipe(takeUntil(this._destroyed)).subscribe(url => {
1079
- this._assertInitialized();
1080
1176
  const overlay = this.groundOverlay;
1081
- overlay.set('url', url);
1082
- // Google Maps only redraws the overlay if we re-set the map.
1083
- overlay.setMap(null);
1084
- overlay.setMap(this._map.googleMap);
1177
+ if (overlay) {
1178
+ overlay.set('url', url);
1179
+ // Google Maps only redraws the overlay if we re-set the map.
1180
+ overlay.setMap(null);
1181
+ overlay.setMap(this._map.googleMap);
1182
+ }
1085
1183
  });
1086
1184
  }
1087
1185
  _assertInitialized() {
1088
1186
  if (typeof ngDevMode === 'undefined' || ngDevMode) {
1089
- if (!this._map.googleMap) {
1090
- throw Error('Cannot access Google Map information before the API has been initialized. ' +
1091
- 'Please wait for the API to load before trying to interact with it.');
1092
- }
1093
1187
  if (!this.groundOverlay) {
1094
1188
  throw Error('Cannot interact with a Google Map GroundOverlay before it has been initialized. ' +
1095
1189
  'Please wait for the GroundOverlay to load before trying to interact with it.');
1096
1190
  }
1097
1191
  }
1098
1192
  }
1099
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapGroundOverlay, deps: [{ token: GoogleMap }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
1100
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.0-next.2", type: MapGroundOverlay, isStandalone: true, selector: "map-ground-overlay", inputs: { url: "url", bounds: "bounds", clickable: "clickable", opacity: "opacity" }, outputs: { mapClick: "mapClick", mapDblclick: "mapDblclick" }, exportAs: ["mapGroundOverlay"], ngImport: i0 }); }
1193
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapGroundOverlay, deps: [{ token: GoogleMap }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
1194
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.0-next.5", type: MapGroundOverlay, isStandalone: true, selector: "map-ground-overlay", inputs: { url: "url", bounds: "bounds", clickable: "clickable", opacity: "opacity" }, outputs: { mapClick: "mapClick", mapDblclick: "mapDblclick", groundOverlayInitialized: "groundOverlayInitialized" }, exportAs: ["mapGroundOverlay"], ngImport: i0 }); }
1101
1195
  }
1102
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapGroundOverlay, decorators: [{
1196
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapGroundOverlay, decorators: [{
1103
1197
  type: Directive,
1104
1198
  args: [{
1105
1199
  selector: 'map-ground-overlay',
@@ -1118,6 +1212,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2",
1118
1212
  type: Output
1119
1213
  }], mapDblclick: [{
1120
1214
  type: Output
1215
+ }], groundOverlayInitialized: [{
1216
+ type: Output
1121
1217
  }] } });
1122
1218
 
1123
1219
  /// <reference types="google.maps" />
@@ -1169,22 +1265,36 @@ class MapInfoWindow {
1169
1265
  * #InfoWindow.zindex_changed
1170
1266
  */
1171
1267
  this.zindexChanged = this._eventManager.getLazyEmitter('zindex_changed');
1268
+ /** Event emitted when the info window is initialized. */
1269
+ this.infoWindowInitialized = new EventEmitter();
1172
1270
  }
1173
1271
  ngOnInit() {
1174
1272
  if (this._googleMap._isBrowser) {
1175
- const combinedOptionsChanges = this._combineOptions();
1176
- combinedOptionsChanges.pipe(take(1)).subscribe(options => {
1177
- // Create the object outside the zone so its events don't trigger change detection.
1178
- // We'll bring it back in inside the `MapEventManager` only for the events that the
1179
- // user has subscribed to.
1180
- this._ngZone.runOutsideAngular(() => {
1181
- this.infoWindow = new google.maps.InfoWindow(options);
1182
- });
1183
- this._eventManager.setTarget(this.infoWindow);
1273
+ this._combineOptions()
1274
+ .pipe(take(1))
1275
+ .subscribe(options => {
1276
+ if (google.maps.InfoWindow) {
1277
+ this._initialize(google.maps.InfoWindow, options);
1278
+ }
1279
+ else {
1280
+ this._ngZone.runOutsideAngular(() => {
1281
+ importLibrary('maps', 'InfoWindow').then(infoWindowConstructor => this._initialize(infoWindowConstructor, options));
1282
+ });
1283
+ }
1184
1284
  });
1285
+ }
1286
+ }
1287
+ _initialize(infoWindowConstructor, options) {
1288
+ // Create the object outside the zone so its events don't trigger change detection.
1289
+ // We'll bring it back in inside the `MapEventManager` only for the events that the
1290
+ // user has subscribed to.
1291
+ this._ngZone.runOutsideAngular(() => {
1292
+ this.infoWindow = new infoWindowConstructor(options);
1293
+ this._eventManager.setTarget(this.infoWindow);
1294
+ this.infoWindowInitialized.emit(this.infoWindow);
1185
1295
  this._watchForOptionsChanges();
1186
1296
  this._watchForPositionChanges();
1187
- }
1297
+ });
1188
1298
  }
1189
1299
  ngOnDestroy() {
1190
1300
  this._eventManager.destroy();
@@ -1275,10 +1385,6 @@ class MapInfoWindow {
1275
1385
  }
1276
1386
  _assertInitialized() {
1277
1387
  if (typeof ngDevMode === 'undefined' || ngDevMode) {
1278
- if (!this._googleMap.googleMap) {
1279
- throw Error('Cannot access Google Map information before the API has been initialized. ' +
1280
- 'Please wait for the API to load before trying to interact with it.');
1281
- }
1282
1388
  if (!this.infoWindow) {
1283
1389
  throw Error('Cannot interact with a Google Map Info Window before it has been ' +
1284
1390
  'initialized. Please wait for the Info Window to load before trying to interact with ' +
@@ -1286,10 +1392,10 @@ class MapInfoWindow {
1286
1392
  }
1287
1393
  }
1288
1394
  }
1289
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapInfoWindow, deps: [{ token: GoogleMap }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
1290
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.0-next.2", type: MapInfoWindow, isStandalone: true, selector: "map-info-window", inputs: { options: "options", position: "position" }, outputs: { closeclick: "closeclick", contentChanged: "contentChanged", domready: "domready", positionChanged: "positionChanged", zindexChanged: "zindexChanged" }, host: { styleAttribute: "display: none" }, exportAs: ["mapInfoWindow"], ngImport: i0 }); }
1395
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapInfoWindow, deps: [{ token: GoogleMap }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
1396
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.0-next.5", type: MapInfoWindow, isStandalone: true, selector: "map-info-window", inputs: { options: "options", position: "position" }, outputs: { closeclick: "closeclick", contentChanged: "contentChanged", domready: "domready", positionChanged: "positionChanged", zindexChanged: "zindexChanged", infoWindowInitialized: "infoWindowInitialized" }, host: { styleAttribute: "display: none" }, exportAs: ["mapInfoWindow"], ngImport: i0 }); }
1291
1397
  }
1292
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapInfoWindow, decorators: [{
1398
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapInfoWindow, decorators: [{
1293
1399
  type: Directive,
1294
1400
  args: [{
1295
1401
  selector: 'map-info-window',
@@ -1311,6 +1417,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2",
1311
1417
  type: Output
1312
1418
  }], zindexChanged: [{
1313
1419
  type: Output
1420
+ }], infoWindowInitialized: [{
1421
+ type: Output
1314
1422
  }] } });
1315
1423
 
1316
1424
  /// <reference types="google.maps" />
@@ -1347,31 +1455,49 @@ class MapKmlLayer {
1347
1455
  * See developers.google.com/maps/documentation/javascript/reference/kml#KmlLayer.status_changed
1348
1456
  */
1349
1457
  this.statusChanged = this._eventManager.getLazyEmitter('status_changed');
1458
+ /** Event emitted when the KML layer is initialized. */
1459
+ this.kmlLayerInitialized = new EventEmitter();
1350
1460
  }
1351
1461
  ngOnInit() {
1352
1462
  if (this._map._isBrowser) {
1353
1463
  this._combineOptions()
1354
1464
  .pipe(take(1))
1355
1465
  .subscribe(options => {
1356
- // Create the object outside the zone so its events don't trigger change detection.
1357
- // We'll bring it back in inside the `MapEventManager` only for the events that the
1358
- // user has subscribed to.
1359
- this._ngZone.runOutsideAngular(() => (this.kmlLayer = new google.maps.KmlLayer(options)));
1360
- this._assertInitialized();
1361
- this.kmlLayer.setMap(this._map.googleMap);
1362
- this._eventManager.setTarget(this.kmlLayer);
1466
+ if (google.maps.KmlLayer && this._map.googleMap) {
1467
+ this._initialize(this._map.googleMap, google.maps.KmlLayer, options);
1468
+ }
1469
+ else {
1470
+ this._ngZone.runOutsideAngular(() => {
1471
+ Promise.all([
1472
+ this._map._resolveMap(),
1473
+ importLibrary('maps', 'KmlLayer'),
1474
+ ]).then(([map, layerConstructor]) => {
1475
+ this._initialize(map, layerConstructor, options);
1476
+ });
1477
+ });
1478
+ }
1363
1479
  });
1480
+ }
1481
+ }
1482
+ _initialize(map, layerConstructor, options) {
1483
+ // Create the object outside the zone so its events don't trigger change detection.
1484
+ // We'll bring it back in inside the `MapEventManager` only for the events that the
1485
+ // user has subscribed to.
1486
+ this._ngZone.runOutsideAngular(() => {
1487
+ this.kmlLayer = new layerConstructor(options);
1488
+ this._assertInitialized();
1489
+ this.kmlLayer.setMap(map);
1490
+ this._eventManager.setTarget(this.kmlLayer);
1491
+ this.kmlLayerInitialized.emit(this.kmlLayer);
1364
1492
  this._watchForOptionsChanges();
1365
1493
  this._watchForUrlChanges();
1366
- }
1494
+ });
1367
1495
  }
1368
1496
  ngOnDestroy() {
1369
1497
  this._eventManager.destroy();
1370
1498
  this._destroyed.next();
1371
1499
  this._destroyed.complete();
1372
- if (this.kmlLayer) {
1373
- this.kmlLayer.setMap(null);
1374
- }
1500
+ this.kmlLayer?.setMap(null);
1375
1501
  }
1376
1502
  /**
1377
1503
  * See
@@ -1436,20 +1562,16 @@ class MapKmlLayer {
1436
1562
  }
1437
1563
  _assertInitialized() {
1438
1564
  if (typeof ngDevMode === 'undefined' || ngDevMode) {
1439
- if (!this._map.googleMap) {
1440
- throw Error('Cannot access Google Map information before the API has been initialized. ' +
1441
- 'Please wait for the API to load before trying to interact with it.');
1442
- }
1443
1565
  if (!this.kmlLayer) {
1444
1566
  throw Error('Cannot interact with a Google Map KmlLayer before it has been ' +
1445
1567
  'initialized. Please wait for the KmlLayer to load before trying to interact with it.');
1446
1568
  }
1447
1569
  }
1448
1570
  }
1449
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapKmlLayer, deps: [{ token: GoogleMap }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
1450
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.0-next.2", type: MapKmlLayer, isStandalone: true, selector: "map-kml-layer", inputs: { options: "options", url: "url" }, outputs: { kmlClick: "kmlClick", defaultviewportChanged: "defaultviewportChanged", statusChanged: "statusChanged" }, exportAs: ["mapKmlLayer"], ngImport: i0 }); }
1571
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapKmlLayer, deps: [{ token: GoogleMap }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
1572
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.0-next.5", type: MapKmlLayer, isStandalone: true, selector: "map-kml-layer", inputs: { options: "options", url: "url" }, outputs: { kmlClick: "kmlClick", defaultviewportChanged: "defaultviewportChanged", statusChanged: "statusChanged", kmlLayerInitialized: "kmlLayerInitialized" }, exportAs: ["mapKmlLayer"], ngImport: i0 }); }
1451
1573
  }
1452
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapKmlLayer, decorators: [{
1574
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapKmlLayer, decorators: [{
1453
1575
  type: Directive,
1454
1576
  args: [{
1455
1577
  selector: 'map-kml-layer',
@@ -1466,6 +1588,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2",
1466
1588
  type: Output
1467
1589
  }], statusChanged: [{
1468
1590
  type: Output
1591
+ }], kmlLayerInitialized: [{
1592
+ type: Output
1469
1593
  }] } });
1470
1594
 
1471
1595
  /// <reference types="google.maps" />
@@ -1640,19 +1764,38 @@ class MapMarker {
1640
1764
  * developers.google.com/maps/documentation/javascript/reference/marker#Marker.zindex_changed
1641
1765
  */
1642
1766
  this.zindexChanged = this._eventManager.getLazyEmitter('zindex_changed');
1767
+ /** Event emitted when the marker is initialized. */
1768
+ this.markerInitialized = new EventEmitter();
1643
1769
  }
1644
1770
  ngOnInit() {
1645
- if (this._googleMap._isBrowser) {
1646
- // Create the object outside the zone so its events don't trigger change detection.
1647
- // We'll bring it back in inside the `MapEventManager` only for the events that the
1648
- // user has subscribed to.
1771
+ if (!this._googleMap._isBrowser) {
1772
+ return;
1773
+ }
1774
+ if (google.maps.Marker && this._googleMap.googleMap) {
1775
+ this._initialize(this._googleMap.googleMap, google.maps.Marker);
1776
+ }
1777
+ else {
1649
1778
  this._ngZone.runOutsideAngular(() => {
1650
- this.marker = new google.maps.Marker(this._combineOptions());
1779
+ Promise.all([
1780
+ this._googleMap._resolveMap(),
1781
+ importLibrary('marker', 'Marker'),
1782
+ ]).then(([map, markerConstrutor]) => {
1783
+ this._initialize(map, markerConstrutor);
1784
+ });
1651
1785
  });
1786
+ }
1787
+ }
1788
+ _initialize(map, markerConstructor) {
1789
+ // Create the object outside the zone so its events don't trigger change detection.
1790
+ // We'll bring it back in inside the `MapEventManager` only for the events that the
1791
+ // user has subscribed to.
1792
+ this._ngZone.runOutsideAngular(() => {
1793
+ this.marker = new markerConstructor(this._combineOptions());
1652
1794
  this._assertInitialized();
1653
- this.marker.setMap(this._googleMap.googleMap);
1795
+ this.marker.setMap(map);
1654
1796
  this._eventManager.setTarget(this.marker);
1655
- }
1797
+ this.markerInitialized.next(this.marker);
1798
+ });
1656
1799
  }
1657
1800
  ngOnChanges(changes) {
1658
1801
  const { marker, _title, _position, _label, _clickable, _icon, _visible } = this;
@@ -1681,10 +1824,9 @@ class MapMarker {
1681
1824
  }
1682
1825
  }
1683
1826
  ngOnDestroy() {
1827
+ this.markerInitialized.complete();
1684
1828
  this._eventManager.destroy();
1685
- if (this.marker) {
1686
- this.marker.setMap(null);
1687
- }
1829
+ this.marker?.setMap(null);
1688
1830
  }
1689
1831
  /**
1690
1832
  * See
@@ -1787,6 +1929,12 @@ class MapMarker {
1787
1929
  this._assertInitialized();
1788
1930
  return this.marker;
1789
1931
  }
1932
+ /** Returns a promise that resolves when the marker has been initialized. */
1933
+ _resolveMarker() {
1934
+ return this.marker
1935
+ ? Promise.resolve(this.marker)
1936
+ : this.markerInitialized.pipe(take(1)).toPromise();
1937
+ }
1790
1938
  /** Creates a combined options object using the passed-in options and the individual inputs. */
1791
1939
  _combineOptions() {
1792
1940
  const options = this._options || DEFAULT_MARKER_OPTIONS;
@@ -1803,20 +1951,16 @@ class MapMarker {
1803
1951
  }
1804
1952
  _assertInitialized() {
1805
1953
  if (typeof ngDevMode === 'undefined' || ngDevMode) {
1806
- if (!this._googleMap.googleMap) {
1807
- throw Error('Cannot access Google Map information before the API has been initialized. ' +
1808
- 'Please wait for the API to load before trying to interact with it.');
1809
- }
1810
1954
  if (!this.marker) {
1811
1955
  throw Error('Cannot interact with a Google Map Marker before it has been ' +
1812
1956
  'initialized. Please wait for the Marker to load before trying to interact with it.');
1813
1957
  }
1814
1958
  }
1815
1959
  }
1816
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapMarker, deps: [{ token: GoogleMap }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
1817
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.0-next.2", type: MapMarker, isStandalone: true, selector: "map-marker", inputs: { title: "title", position: "position", label: "label", clickable: "clickable", options: "options", icon: "icon", visible: "visible" }, outputs: { animationChanged: "animationChanged", mapClick: "mapClick", clickableChanged: "clickableChanged", cursorChanged: "cursorChanged", mapDblclick: "mapDblclick", mapDrag: "mapDrag", mapDragend: "mapDragend", draggableChanged: "draggableChanged", mapDragstart: "mapDragstart", flatChanged: "flatChanged", iconChanged: "iconChanged", mapMousedown: "mapMousedown", mapMouseout: "mapMouseout", mapMouseover: "mapMouseover", mapMouseup: "mapMouseup", positionChanged: "positionChanged", mapRightclick: "mapRightclick", shapeChanged: "shapeChanged", titleChanged: "titleChanged", visibleChanged: "visibleChanged", zindexChanged: "zindexChanged" }, exportAs: ["mapMarker"], usesOnChanges: true, ngImport: i0 }); }
1960
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapMarker, deps: [{ token: GoogleMap }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
1961
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.0-next.5", type: MapMarker, isStandalone: true, selector: "map-marker", inputs: { title: "title", position: "position", label: "label", clickable: "clickable", options: "options", icon: "icon", visible: "visible" }, outputs: { animationChanged: "animationChanged", mapClick: "mapClick", clickableChanged: "clickableChanged", cursorChanged: "cursorChanged", mapDblclick: "mapDblclick", mapDrag: "mapDrag", mapDragend: "mapDragend", draggableChanged: "draggableChanged", mapDragstart: "mapDragstart", flatChanged: "flatChanged", iconChanged: "iconChanged", mapMousedown: "mapMousedown", mapMouseout: "mapMouseout", mapMouseover: "mapMouseover", mapMouseup: "mapMouseup", positionChanged: "positionChanged", mapRightclick: "mapRightclick", shapeChanged: "shapeChanged", titleChanged: "titleChanged", visibleChanged: "visibleChanged", zindexChanged: "zindexChanged", markerInitialized: "markerInitialized" }, exportAs: ["mapMarker"], usesOnChanges: true, ngImport: i0 }); }
1818
1962
  }
1819
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapMarker, decorators: [{
1963
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapMarker, decorators: [{
1820
1964
  type: Directive,
1821
1965
  args: [{
1822
1966
  selector: 'map-marker',
@@ -1879,6 +2023,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2",
1879
2023
  type: Output
1880
2024
  }], zindexChanged: [{
1881
2025
  type: Output
2026
+ }], markerInitialized: [{
2027
+ type: Output
1882
2028
  }] } });
1883
2029
 
1884
2030
  /// <reference types="google.maps" />
@@ -1961,29 +2107,43 @@ class MapMarkerClusterer {
1961
2107
  this.clusteringend = this._eventManager.getLazyEmitter('clusteringend');
1962
2108
  /** Emits when a cluster has been clicked. */
1963
2109
  this.clusterClick = this._eventManager.getLazyEmitter('click');
1964
- this._canInitialize = this._googleMap._isBrowser;
2110
+ /** Event emitted when the clusterer is initialized. */
2111
+ this.markerClustererInitialized = new EventEmitter();
2112
+ this._canInitialize = _googleMap._isBrowser;
1965
2113
  }
1966
2114
  ngOnInit() {
1967
2115
  if (this._canInitialize) {
1968
- if (typeof MarkerClusterer !== 'function' &&
1969
- (typeof ngDevMode === 'undefined' || ngDevMode)) {
1970
- throw Error('MarkerClusterer class not found, cannot construct a marker cluster. ' +
1971
- 'Please install the MarkerClustererPlus library: ' +
1972
- 'https://github.com/googlemaps/js-markerclustererplus');
1973
- }
1974
- // Create the object outside the zone so its events don't trigger change detection.
1975
- // We'll bring it back in inside the `MapEventManager` only for the events that the
1976
- // user has subscribed to.
1977
2116
  this._ngZone.runOutsideAngular(() => {
1978
- this.markerClusterer = new MarkerClusterer(this._googleMap.googleMap, [], this._combineOptions());
2117
+ this._googleMap._resolveMap().then(map => {
2118
+ if (typeof MarkerClusterer !== 'function' &&
2119
+ (typeof ngDevMode === 'undefined' || ngDevMode)) {
2120
+ throw Error('MarkerClusterer class not found, cannot construct a marker cluster. ' +
2121
+ 'Please install the MarkerClustererPlus library: ' +
2122
+ 'https://github.com/googlemaps/js-markerclustererplus');
2123
+ }
2124
+ // Create the object outside the zone so its events don't trigger change detection.
2125
+ // We'll bring it back in inside the `MapEventManager` only for the events that the
2126
+ // user has subscribed to.
2127
+ this.markerClusterer = this._ngZone.runOutsideAngular(() => {
2128
+ return new MarkerClusterer(map, [], this._combineOptions());
2129
+ });
2130
+ this._assertInitialized();
2131
+ this._eventManager.setTarget(this.markerClusterer);
2132
+ this.markerClustererInitialized.emit(this.markerClusterer);
2133
+ });
1979
2134
  });
1980
- this._assertInitialized();
1981
- this._eventManager.setTarget(this.markerClusterer);
1982
2135
  }
1983
2136
  }
1984
2137
  ngAfterContentInit() {
1985
2138
  if (this._canInitialize) {
1986
- this._watchForMarkerChanges();
2139
+ if (this.markerClusterer) {
2140
+ this._watchForMarkerChanges();
2141
+ }
2142
+ else {
2143
+ this.markerClustererInitialized
2144
+ .pipe(take(1), takeUntil(this._destroy))
2145
+ .subscribe(() => this._watchForMarkerChanges());
2146
+ }
1987
2147
  }
1988
2148
  }
1989
2149
  ngOnChanges(changes) {
@@ -2049,9 +2209,7 @@ class MapMarkerClusterer {
2049
2209
  this._destroy.next();
2050
2210
  this._destroy.complete();
2051
2211
  this._eventManager.destroy();
2052
- if (this.markerClusterer) {
2053
- this.markerClusterer.setMap(null);
2054
- }
2212
+ this.markerClusterer?.setMap(null);
2055
2213
  }
2056
2214
  fitMapToMarkers(padding) {
2057
2215
  this._assertInitialized();
@@ -2159,59 +2317,61 @@ class MapMarkerClusterer {
2159
2317
  }
2160
2318
  _watchForMarkerChanges() {
2161
2319
  this._assertInitialized();
2162
- const initialMarkers = [];
2163
- for (const marker of this._getInternalMarkers(this._markers.toArray())) {
2164
- this._currentMarkers.add(marker);
2165
- initialMarkers.push(marker);
2166
- }
2167
- this.markerClusterer.addMarkers(initialMarkers);
2320
+ this._ngZone.runOutsideAngular(() => {
2321
+ this._getInternalMarkers(this._markers).then(markers => {
2322
+ const initialMarkers = [];
2323
+ for (const marker of markers) {
2324
+ this._currentMarkers.add(marker);
2325
+ initialMarkers.push(marker);
2326
+ }
2327
+ this.markerClusterer.addMarkers(initialMarkers);
2328
+ });
2329
+ });
2168
2330
  this._markers.changes
2169
2331
  .pipe(takeUntil(this._destroy))
2170
2332
  .subscribe((markerComponents) => {
2171
2333
  this._assertInitialized();
2172
- const newMarkers = new Set(this._getInternalMarkers(markerComponents));
2173
- const markersToAdd = [];
2174
- const markersToRemove = [];
2175
- for (const marker of Array.from(newMarkers)) {
2176
- if (!this._currentMarkers.has(marker)) {
2177
- this._currentMarkers.add(marker);
2178
- markersToAdd.push(marker);
2179
- }
2180
- }
2181
- for (const marker of Array.from(this._currentMarkers)) {
2182
- if (!newMarkers.has(marker)) {
2183
- markersToRemove.push(marker);
2184
- }
2185
- }
2186
- this.markerClusterer.addMarkers(markersToAdd, true);
2187
- this.markerClusterer.removeMarkers(markersToRemove, true);
2188
- this.markerClusterer.repaint();
2189
- for (const marker of markersToRemove) {
2190
- this._currentMarkers.delete(marker);
2191
- }
2334
+ this._ngZone.runOutsideAngular(() => {
2335
+ this._getInternalMarkers(markerComponents).then(markers => {
2336
+ const newMarkers = new Set(markers);
2337
+ const markersToAdd = [];
2338
+ const markersToRemove = [];
2339
+ for (const marker of Array.from(newMarkers)) {
2340
+ if (!this._currentMarkers.has(marker)) {
2341
+ this._currentMarkers.add(marker);
2342
+ markersToAdd.push(marker);
2343
+ }
2344
+ }
2345
+ for (const marker of Array.from(this._currentMarkers)) {
2346
+ if (!newMarkers.has(marker)) {
2347
+ markersToRemove.push(marker);
2348
+ }
2349
+ }
2350
+ this.markerClusterer.addMarkers(markersToAdd, true);
2351
+ this.markerClusterer.removeMarkers(markersToRemove, true);
2352
+ this.markerClusterer.repaint();
2353
+ for (const marker of markersToRemove) {
2354
+ this._currentMarkers.delete(marker);
2355
+ }
2356
+ });
2357
+ });
2192
2358
  });
2193
2359
  }
2194
2360
  _getInternalMarkers(markers) {
2195
- return markers
2196
- .filter(markerComponent => !!markerComponent.marker)
2197
- .map(markerComponent => markerComponent.marker);
2361
+ return Promise.all(markers.map(markerComponent => markerComponent._resolveMarker()));
2198
2362
  }
2199
2363
  _assertInitialized() {
2200
2364
  if (typeof ngDevMode === 'undefined' || ngDevMode) {
2201
- if (!this._googleMap.googleMap) {
2202
- throw Error('Cannot access Google Map information before the API has been initialized. ' +
2203
- 'Please wait for the API to load before trying to interact with it.');
2204
- }
2205
2365
  if (!this.markerClusterer) {
2206
2366
  throw Error('Cannot interact with a MarkerClusterer before it has been initialized. ' +
2207
2367
  'Please wait for the MarkerClusterer to load before trying to interact with it.');
2208
2368
  }
2209
2369
  }
2210
2370
  }
2211
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapMarkerClusterer, deps: [{ token: GoogleMap }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component }); }
2212
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.1.0-next.2", type: MapMarkerClusterer, isStandalone: true, selector: "map-marker-clusterer", inputs: { ariaLabelFn: "ariaLabelFn", averageCenter: "averageCenter", batchSize: "batchSize", batchSizeIE: "batchSizeIE", calculator: "calculator", clusterClass: "clusterClass", enableRetinaIcons: "enableRetinaIcons", gridSize: "gridSize", ignoreHidden: "ignoreHidden", imageExtension: "imageExtension", imagePath: "imagePath", imageSizes: "imageSizes", maxZoom: "maxZoom", minimumClusterSize: "minimumClusterSize", styles: "styles", title: "title", zIndex: "zIndex", zoomOnClick: "zoomOnClick", options: "options" }, outputs: { clusteringbegin: "clusteringbegin", clusteringend: "clusteringend", clusterClick: "clusterClick" }, queries: [{ propertyName: "_markers", predicate: MapMarker, descendants: true }], exportAs: ["mapMarkerClusterer"], usesOnChanges: true, ngImport: i0, template: '<ng-content />', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
2371
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapMarkerClusterer, deps: [{ token: GoogleMap }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component }); }
2372
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.1.0-next.5", type: MapMarkerClusterer, isStandalone: true, selector: "map-marker-clusterer", inputs: { ariaLabelFn: "ariaLabelFn", averageCenter: "averageCenter", batchSize: "batchSize", batchSizeIE: "batchSizeIE", calculator: "calculator", clusterClass: "clusterClass", enableRetinaIcons: "enableRetinaIcons", gridSize: "gridSize", ignoreHidden: "ignoreHidden", imageExtension: "imageExtension", imagePath: "imagePath", imageSizes: "imageSizes", maxZoom: "maxZoom", minimumClusterSize: "minimumClusterSize", styles: "styles", title: "title", zIndex: "zIndex", zoomOnClick: "zoomOnClick", options: "options" }, outputs: { clusteringbegin: "clusteringbegin", clusteringend: "clusteringend", clusterClick: "clusterClick", markerClustererInitialized: "markerClustererInitialized" }, queries: [{ propertyName: "_markers", predicate: MapMarker, descendants: true }], exportAs: ["mapMarkerClusterer"], usesOnChanges: true, ngImport: i0, template: '<ng-content />', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
2213
2373
  }
2214
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapMarkerClusterer, decorators: [{
2374
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapMarkerClusterer, decorators: [{
2215
2375
  type: Component,
2216
2376
  args: [{
2217
2377
  selector: 'map-marker-clusterer',
@@ -2268,6 +2428,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2",
2268
2428
  }], _markers: [{
2269
2429
  type: ContentChildren,
2270
2430
  args: [MapMarker, { descendants: true }]
2431
+ }], markerClustererInitialized: [{
2432
+ type: Output
2271
2433
  }] } });
2272
2434
 
2273
2435
  /// <reference types="google.maps" />
@@ -2334,33 +2496,49 @@ class MapPolygon {
2334
2496
  * See developers.google.com/maps/documentation/javascript/reference/polygon#Polygon.rightclick
2335
2497
  */
2336
2498
  this.polygonRightclick = this._eventManager.getLazyEmitter('rightclick');
2499
+ /** Event emitted when the polygon is initialized. */
2500
+ this.polygonInitialized = new EventEmitter();
2337
2501
  }
2338
2502
  ngOnInit() {
2339
2503
  if (this._map._isBrowser) {
2340
2504
  this._combineOptions()
2341
2505
  .pipe(take(1))
2342
2506
  .subscribe(options => {
2343
- // Create the object outside the zone so its events don't trigger change detection.
2344
- // We'll bring it back in inside the `MapEventManager` only for the events that the
2345
- // user has subscribed to.
2346
- this._ngZone.runOutsideAngular(() => {
2347
- this.polygon = new google.maps.Polygon(options);
2348
- });
2349
- this._assertInitialized();
2350
- this.polygon.setMap(this._map.googleMap);
2351
- this._eventManager.setTarget(this.polygon);
2507
+ if (google.maps.Polygon && this._map.googleMap) {
2508
+ this._initialize(this._map.googleMap, google.maps.Polygon, options);
2509
+ }
2510
+ else {
2511
+ this._ngZone.runOutsideAngular(() => {
2512
+ Promise.all([
2513
+ this._map._resolveMap(),
2514
+ importLibrary('maps', 'Polygon'),
2515
+ ]).then(([map, polygonConstructor]) => {
2516
+ this._initialize(map, polygonConstructor, options);
2517
+ });
2518
+ });
2519
+ }
2352
2520
  });
2521
+ }
2522
+ }
2523
+ _initialize(map, polygonConstructor, options) {
2524
+ // Create the object outside the zone so its events don't trigger change detection.
2525
+ // We'll bring it back in inside the `MapEventManager` only for the events that the
2526
+ // user has subscribed to.
2527
+ this._ngZone.runOutsideAngular(() => {
2528
+ this.polygon = new polygonConstructor(options);
2529
+ this._assertInitialized();
2530
+ this.polygon.setMap(map);
2531
+ this._eventManager.setTarget(this.polygon);
2532
+ this.polygonInitialized.emit(this.polygon);
2353
2533
  this._watchForOptionsChanges();
2354
2534
  this._watchForPathChanges();
2355
- }
2535
+ });
2356
2536
  }
2357
2537
  ngOnDestroy() {
2358
2538
  this._eventManager.destroy();
2359
2539
  this._destroyed.next();
2360
2540
  this._destroyed.complete();
2361
- if (this.polygon) {
2362
- this.polygon.setMap(null);
2363
- }
2541
+ this.polygon?.setMap(null);
2364
2542
  }
2365
2543
  /**
2366
2544
  * See
@@ -2423,20 +2601,16 @@ class MapPolygon {
2423
2601
  }
2424
2602
  _assertInitialized() {
2425
2603
  if (typeof ngDevMode === 'undefined' || ngDevMode) {
2426
- if (!this._map.googleMap) {
2427
- throw Error('Cannot access Google Map information before the API has been initialized. ' +
2428
- 'Please wait for the API to load before trying to interact with it.');
2429
- }
2430
2604
  if (!this.polygon) {
2431
2605
  throw Error('Cannot interact with a Google Map Polygon before it has been ' +
2432
2606
  'initialized. Please wait for the Polygon to load before trying to interact with it.');
2433
2607
  }
2434
2608
  }
2435
2609
  }
2436
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapPolygon, deps: [{ token: GoogleMap }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
2437
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.0-next.2", type: MapPolygon, isStandalone: true, selector: "map-polygon", inputs: { options: "options", paths: "paths" }, outputs: { polygonClick: "polygonClick", polygonDblclick: "polygonDblclick", polygonDrag: "polygonDrag", polygonDragend: "polygonDragend", polygonDragstart: "polygonDragstart", polygonMousedown: "polygonMousedown", polygonMousemove: "polygonMousemove", polygonMouseout: "polygonMouseout", polygonMouseover: "polygonMouseover", polygonMouseup: "polygonMouseup", polygonRightclick: "polygonRightclick" }, exportAs: ["mapPolygon"], ngImport: i0 }); }
2610
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapPolygon, deps: [{ token: GoogleMap }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
2611
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.0-next.5", type: MapPolygon, isStandalone: true, selector: "map-polygon", inputs: { options: "options", paths: "paths" }, outputs: { polygonClick: "polygonClick", polygonDblclick: "polygonDblclick", polygonDrag: "polygonDrag", polygonDragend: "polygonDragend", polygonDragstart: "polygonDragstart", polygonMousedown: "polygonMousedown", polygonMousemove: "polygonMousemove", polygonMouseout: "polygonMouseout", polygonMouseover: "polygonMouseover", polygonMouseup: "polygonMouseup", polygonRightclick: "polygonRightclick", polygonInitialized: "polygonInitialized" }, exportAs: ["mapPolygon"], ngImport: i0 }); }
2438
2612
  }
2439
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapPolygon, decorators: [{
2613
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapPolygon, decorators: [{
2440
2614
  type: Directive,
2441
2615
  args: [{
2442
2616
  selector: 'map-polygon',
@@ -2469,6 +2643,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2",
2469
2643
  type: Output
2470
2644
  }], polygonRightclick: [{
2471
2645
  type: Output
2646
+ }], polygonInitialized: [{
2647
+ type: Output
2472
2648
  }] } });
2473
2649
 
2474
2650
  /// <reference types="google.maps" />
@@ -2535,31 +2711,49 @@ class MapPolyline {
2535
2711
  * See developers.google.com/maps/documentation/javascript/reference/polygon#Polyline.rightclick
2536
2712
  */
2537
2713
  this.polylineRightclick = this._eventManager.getLazyEmitter('rightclick');
2714
+ /** Event emitted when the polyline is initialized. */
2715
+ this.polylineInitialized = new EventEmitter();
2538
2716
  }
2539
2717
  ngOnInit() {
2540
2718
  if (this._map._isBrowser) {
2541
2719
  this._combineOptions()
2542
2720
  .pipe(take(1))
2543
2721
  .subscribe(options => {
2544
- // Create the object outside the zone so its events don't trigger change detection.
2545
- // We'll bring it back in inside the `MapEventManager` only for the events that the
2546
- // user has subscribed to.
2547
- this._ngZone.runOutsideAngular(() => (this.polyline = new google.maps.Polyline(options)));
2548
- this._assertInitialized();
2549
- this.polyline.setMap(this._map.googleMap);
2550
- this._eventManager.setTarget(this.polyline);
2722
+ if (google.maps.Polyline && this._map.googleMap) {
2723
+ this._initialize(this._map.googleMap, google.maps.Polyline, options);
2724
+ }
2725
+ else {
2726
+ this._ngZone.runOutsideAngular(() => {
2727
+ Promise.all([
2728
+ this._map._resolveMap(),
2729
+ importLibrary('maps', 'Polyline'),
2730
+ ]).then(([map, polylineConstructor]) => {
2731
+ this._initialize(map, polylineConstructor, options);
2732
+ });
2733
+ });
2734
+ }
2551
2735
  });
2736
+ }
2737
+ }
2738
+ _initialize(map, polylineConstructor, options) {
2739
+ // Create the object outside the zone so its events don't trigger change detection.
2740
+ // We'll bring it back in inside the `MapEventManager` only for the events that the
2741
+ // user has subscribed to.
2742
+ this._ngZone.runOutsideAngular(() => {
2743
+ this.polyline = new polylineConstructor(options);
2744
+ this._assertInitialized();
2745
+ this.polyline.setMap(map);
2746
+ this._eventManager.setTarget(this.polyline);
2747
+ this.polylineInitialized.emit(this.polyline);
2552
2748
  this._watchForOptionsChanges();
2553
2749
  this._watchForPathChanges();
2554
- }
2750
+ });
2555
2751
  }
2556
2752
  ngOnDestroy() {
2557
2753
  this._eventManager.destroy();
2558
2754
  this._destroyed.next();
2559
2755
  this._destroyed.complete();
2560
- if (this.polyline) {
2561
- this.polyline.setMap(null);
2562
- }
2756
+ this.polyline?.setMap(null);
2563
2757
  }
2564
2758
  /**
2565
2759
  * See
@@ -2615,20 +2809,16 @@ class MapPolyline {
2615
2809
  }
2616
2810
  _assertInitialized() {
2617
2811
  if (typeof ngDevMode === 'undefined' || ngDevMode) {
2618
- if (!this._map.googleMap) {
2619
- throw Error('Cannot access Google Map information before the API has been initialized. ' +
2620
- 'Please wait for the API to load before trying to interact with it.');
2621
- }
2622
2812
  if (!this.polyline) {
2623
2813
  throw Error('Cannot interact with a Google Map Polyline before it has been ' +
2624
2814
  'initialized. Please wait for the Polyline to load before trying to interact with it.');
2625
2815
  }
2626
2816
  }
2627
2817
  }
2628
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapPolyline, deps: [{ token: GoogleMap }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
2629
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.0-next.2", type: MapPolyline, isStandalone: true, selector: "map-polyline", inputs: { options: "options", path: "path" }, outputs: { polylineClick: "polylineClick", polylineDblclick: "polylineDblclick", polylineDrag: "polylineDrag", polylineDragend: "polylineDragend", polylineDragstart: "polylineDragstart", polylineMousedown: "polylineMousedown", polylineMousemove: "polylineMousemove", polylineMouseout: "polylineMouseout", polylineMouseover: "polylineMouseover", polylineMouseup: "polylineMouseup", polylineRightclick: "polylineRightclick" }, exportAs: ["mapPolyline"], ngImport: i0 }); }
2818
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapPolyline, deps: [{ token: GoogleMap }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
2819
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.0-next.5", type: MapPolyline, isStandalone: true, selector: "map-polyline", inputs: { options: "options", path: "path" }, outputs: { polylineClick: "polylineClick", polylineDblclick: "polylineDblclick", polylineDrag: "polylineDrag", polylineDragend: "polylineDragend", polylineDragstart: "polylineDragstart", polylineMousedown: "polylineMousedown", polylineMousemove: "polylineMousemove", polylineMouseout: "polylineMouseout", polylineMouseover: "polylineMouseover", polylineMouseup: "polylineMouseup", polylineRightclick: "polylineRightclick", polylineInitialized: "polylineInitialized" }, exportAs: ["mapPolyline"], ngImport: i0 }); }
2630
2820
  }
2631
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapPolyline, decorators: [{
2821
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapPolyline, decorators: [{
2632
2822
  type: Directive,
2633
2823
  args: [{
2634
2824
  selector: 'map-polyline',
@@ -2661,6 +2851,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2",
2661
2851
  type: Output
2662
2852
  }], polylineRightclick: [{
2663
2853
  type: Output
2854
+ }], polylineInitialized: [{
2855
+ type: Output
2664
2856
  }] } });
2665
2857
 
2666
2858
  /// <reference types="google.maps" />
@@ -2742,33 +2934,49 @@ class MapRectangle {
2742
2934
  * developers.google.com/maps/documentation/javascript/reference/polygon#Rectangle.rightclick
2743
2935
  */
2744
2936
  this.rectangleRightclick = this._eventManager.getLazyEmitter('rightclick');
2937
+ /** Event emitted when the rectangle is initialized. */
2938
+ this.rectangleInitialized = new EventEmitter();
2745
2939
  }
2746
2940
  ngOnInit() {
2747
2941
  if (this._map._isBrowser) {
2748
2942
  this._combineOptions()
2749
2943
  .pipe(take(1))
2750
2944
  .subscribe(options => {
2751
- // Create the object outside the zone so its events don't trigger change detection.
2752
- // We'll bring it back in inside the `MapEventManager` only for the events that the
2753
- // user has subscribed to.
2754
- this._ngZone.runOutsideAngular(() => {
2755
- this.rectangle = new google.maps.Rectangle(options);
2756
- });
2757
- this._assertInitialized();
2758
- this.rectangle.setMap(this._map.googleMap);
2759
- this._eventManager.setTarget(this.rectangle);
2945
+ if (google.maps.Rectangle && this._map.googleMap) {
2946
+ this._initialize(this._map.googleMap, google.maps.Rectangle, options);
2947
+ }
2948
+ else {
2949
+ this._ngZone.runOutsideAngular(() => {
2950
+ Promise.all([
2951
+ this._map._resolveMap(),
2952
+ importLibrary('maps', 'Rectangle'),
2953
+ ]).then(([map, rectangleConstructor]) => {
2954
+ this._initialize(map, rectangleConstructor, options);
2955
+ });
2956
+ });
2957
+ }
2760
2958
  });
2959
+ }
2960
+ }
2961
+ _initialize(map, rectangleConstructor, options) {
2962
+ // Create the object outside the zone so its events don't trigger change detection.
2963
+ // We'll bring it back in inside the `MapEventManager` only for the events that the
2964
+ // user has subscribed to.
2965
+ this._ngZone.runOutsideAngular(() => {
2966
+ this.rectangle = new rectangleConstructor(options);
2967
+ this._assertInitialized();
2968
+ this.rectangle.setMap(map);
2969
+ this._eventManager.setTarget(this.rectangle);
2970
+ this.rectangleInitialized.emit(this.rectangle);
2761
2971
  this._watchForOptionsChanges();
2762
2972
  this._watchForBoundsChanges();
2763
- }
2973
+ });
2764
2974
  }
2765
2975
  ngOnDestroy() {
2766
2976
  this._eventManager.destroy();
2767
2977
  this._destroyed.next();
2768
2978
  this._destroyed.complete();
2769
- if (this.rectangle) {
2770
- this.rectangle.setMap(null);
2771
- }
2979
+ this.rectangle?.setMap(null);
2772
2980
  }
2773
2981
  /**
2774
2982
  * See
@@ -2827,20 +3035,16 @@ class MapRectangle {
2827
3035
  }
2828
3036
  _assertInitialized() {
2829
3037
  if (typeof ngDevMode === 'undefined' || ngDevMode) {
2830
- if (!this._map.googleMap) {
2831
- throw Error('Cannot access Google Map information before the API has been initialized. ' +
2832
- 'Please wait for the API to load before trying to interact with it.');
2833
- }
2834
3038
  if (!this.rectangle) {
2835
3039
  throw Error('Cannot interact with a Google Map Rectangle before it has been initialized. ' +
2836
3040
  'Please wait for the Rectangle to load before trying to interact with it.');
2837
3041
  }
2838
3042
  }
2839
3043
  }
2840
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapRectangle, deps: [{ token: GoogleMap }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
2841
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.0-next.2", type: MapRectangle, isStandalone: true, selector: "map-rectangle", inputs: { options: "options", bounds: "bounds" }, outputs: { boundsChanged: "boundsChanged", rectangleClick: "rectangleClick", rectangleDblclick: "rectangleDblclick", rectangleDrag: "rectangleDrag", rectangleDragend: "rectangleDragend", rectangleDragstart: "rectangleDragstart", rectangleMousedown: "rectangleMousedown", rectangleMousemove: "rectangleMousemove", rectangleMouseout: "rectangleMouseout", rectangleMouseover: "rectangleMouseover", rectangleMouseup: "rectangleMouseup", rectangleRightclick: "rectangleRightclick" }, exportAs: ["mapRectangle"], ngImport: i0 }); }
3044
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapRectangle, deps: [{ token: GoogleMap }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
3045
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.0-next.5", type: MapRectangle, isStandalone: true, selector: "map-rectangle", inputs: { options: "options", bounds: "bounds" }, outputs: { boundsChanged: "boundsChanged", rectangleClick: "rectangleClick", rectangleDblclick: "rectangleDblclick", rectangleDrag: "rectangleDrag", rectangleDragend: "rectangleDragend", rectangleDragstart: "rectangleDragstart", rectangleMousedown: "rectangleMousedown", rectangleMousemove: "rectangleMousemove", rectangleMouseout: "rectangleMouseout", rectangleMouseover: "rectangleMouseover", rectangleMouseup: "rectangleMouseup", rectangleRightclick: "rectangleRightclick", rectangleInitialized: "rectangleInitialized" }, exportAs: ["mapRectangle"], ngImport: i0 }); }
2842
3046
  }
2843
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapRectangle, decorators: [{
3047
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapRectangle, decorators: [{
2844
3048
  type: Directive,
2845
3049
  args: [{
2846
3050
  selector: 'map-rectangle',
@@ -2875,6 +3079,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2",
2875
3079
  type: Output
2876
3080
  }], rectangleRightclick: [{
2877
3081
  type: Output
3082
+ }], rectangleInitialized: [{
3083
+ type: Output
2878
3084
  }] } });
2879
3085
 
2880
3086
  /// <reference types="google.maps" />
@@ -2895,28 +3101,43 @@ class MapTrafficLayer {
2895
3101
  this._ngZone = _ngZone;
2896
3102
  this._autoRefresh = new BehaviorSubject(true);
2897
3103
  this._destroyed = new Subject();
3104
+ /** Event emitted when the traffic layer is initialized. */
3105
+ this.trafficLayerInitialized = new EventEmitter();
2898
3106
  }
2899
3107
  ngOnInit() {
2900
3108
  if (this._map._isBrowser) {
2901
3109
  this._combineOptions()
2902
3110
  .pipe(take(1))
2903
3111
  .subscribe(options => {
2904
- // Create the object outside the zone so its events don't trigger change detection.
2905
- this._ngZone.runOutsideAngular(() => {
2906
- this.trafficLayer = new google.maps.TrafficLayer(options);
2907
- });
2908
- this._assertInitialized();
2909
- this.trafficLayer.setMap(this._map.googleMap);
3112
+ if (google.maps.TrafficLayer && this._map.googleMap) {
3113
+ this._initialize(this._map.googleMap, google.maps.TrafficLayer, options);
3114
+ }
3115
+ else {
3116
+ this._ngZone.runOutsideAngular(() => {
3117
+ Promise.all([
3118
+ this._map._resolveMap(),
3119
+ importLibrary('maps', 'TrafficLayer'),
3120
+ ]).then(([map, layerConstructor]) => {
3121
+ this._initialize(map, layerConstructor, options);
3122
+ });
3123
+ });
3124
+ }
2910
3125
  });
2911
- this._watchForAutoRefreshChanges();
2912
3126
  }
2913
3127
  }
3128
+ _initialize(map, layerConstructor, options) {
3129
+ this._ngZone.runOutsideAngular(() => {
3130
+ this.trafficLayer = new layerConstructor(options);
3131
+ this._assertInitialized();
3132
+ this.trafficLayer.setMap(map);
3133
+ this.trafficLayerInitialized.emit(this.trafficLayer);
3134
+ this._watchForAutoRefreshChanges();
3135
+ });
3136
+ }
2914
3137
  ngOnDestroy() {
2915
3138
  this._destroyed.next();
2916
3139
  this._destroyed.complete();
2917
- if (this.trafficLayer) {
2918
- this.trafficLayer.setMap(null);
2919
- }
3140
+ this.trafficLayer?.setMap(null);
2920
3141
  }
2921
3142
  _combineOptions() {
2922
3143
  return this._autoRefresh.pipe(map(autoRefresh => {
@@ -2933,19 +3154,15 @@ class MapTrafficLayer {
2933
3154
  });
2934
3155
  }
2935
3156
  _assertInitialized() {
2936
- if (!this._map.googleMap) {
2937
- throw Error('Cannot access Google Map information before the API has been initialized. ' +
2938
- 'Please wait for the API to load before trying to interact with it.');
2939
- }
2940
3157
  if (!this.trafficLayer) {
2941
3158
  throw Error('Cannot interact with a Google Map Traffic Layer before it has been initialized. ' +
2942
3159
  'Please wait for the Traffic Layer to load before trying to interact with it.');
2943
3160
  }
2944
3161
  }
2945
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapTrafficLayer, deps: [{ token: GoogleMap }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
2946
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.0-next.2", type: MapTrafficLayer, isStandalone: true, selector: "map-traffic-layer", inputs: { autoRefresh: "autoRefresh" }, exportAs: ["mapTrafficLayer"], ngImport: i0 }); }
3162
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapTrafficLayer, deps: [{ token: GoogleMap }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
3163
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.0-next.5", type: MapTrafficLayer, isStandalone: true, selector: "map-traffic-layer", inputs: { autoRefresh: "autoRefresh" }, outputs: { trafficLayerInitialized: "trafficLayerInitialized" }, exportAs: ["mapTrafficLayer"], ngImport: i0 }); }
2947
3164
  }
2948
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapTrafficLayer, decorators: [{
3165
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapTrafficLayer, decorators: [{
2949
3166
  type: Directive,
2950
3167
  args: [{
2951
3168
  selector: 'map-traffic-layer',
@@ -2954,6 +3171,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2",
2954
3171
  }]
2955
3172
  }], ctorParameters: () => [{ type: GoogleMap }, { type: i0.NgZone }], propDecorators: { autoRefresh: [{
2956
3173
  type: Input
3174
+ }], trafficLayerInitialized: [{
3175
+ type: Output
2957
3176
  }] } });
2958
3177
 
2959
3178
  /// <reference types="google.maps" />
@@ -2962,36 +3181,60 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2",
2962
3181
  *
2963
3182
  * See developers.google.com/maps/documentation/javascript/reference/map#TransitLayer
2964
3183
  */
2965
- class MapTransitLayer extends MapBaseLayer {
2966
- _initializeObject() {
2967
- this.transitLayer = new google.maps.TransitLayer();
2968
- }
2969
- _setMap() {
2970
- this._assertLayerInitialized();
2971
- this.transitLayer.setMap(this._map.googleMap);
3184
+ class MapTransitLayer {
3185
+ constructor() {
3186
+ this._map = inject(GoogleMap);
3187
+ this._zone = inject(NgZone);
3188
+ /** Event emitted when the transit layer is initialized. */
3189
+ this.transitLayerInitialized = new EventEmitter();
2972
3190
  }
2973
- _unsetMap() {
2974
- if (this.transitLayer) {
2975
- this.transitLayer.setMap(null);
3191
+ ngOnInit() {
3192
+ if (this._map._isBrowser) {
3193
+ if (google.maps.TransitLayer && this._map.googleMap) {
3194
+ this._initialize(this._map.googleMap, google.maps.TransitLayer);
3195
+ }
3196
+ else {
3197
+ this._zone.runOutsideAngular(() => {
3198
+ Promise.all([
3199
+ this._map._resolveMap(),
3200
+ importLibrary('maps', 'TransitLayer'),
3201
+ ]).then(([map, layerConstructor]) => {
3202
+ this._initialize(map, layerConstructor);
3203
+ });
3204
+ });
3205
+ }
2976
3206
  }
2977
3207
  }
3208
+ _initialize(map, layerConstructor) {
3209
+ this._zone.runOutsideAngular(() => {
3210
+ this.transitLayer = new layerConstructor();
3211
+ this.transitLayerInitialized.emit(this.transitLayer);
3212
+ this._assertLayerInitialized();
3213
+ this.transitLayer.setMap(map);
3214
+ });
3215
+ }
3216
+ ngOnDestroy() {
3217
+ this.transitLayer?.setMap(null);
3218
+ }
2978
3219
  _assertLayerInitialized() {
2979
3220
  if (!this.transitLayer) {
2980
3221
  throw Error('Cannot interact with a Google Map Transit Layer before it has been initialized. ' +
2981
3222
  'Please wait for the Transit Layer to load before trying to interact with it.');
2982
3223
  }
2983
3224
  }
2984
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapTransitLayer, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
2985
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.0-next.2", type: MapTransitLayer, isStandalone: true, selector: "map-transit-layer", exportAs: ["mapTransitLayer"], usesInheritance: true, ngImport: i0 }); }
3225
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapTransitLayer, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
3226
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.0-next.5", type: MapTransitLayer, isStandalone: true, selector: "map-transit-layer", outputs: { transitLayerInitialized: "transitLayerInitialized" }, exportAs: ["mapTransitLayer"], ngImport: i0 }); }
2986
3227
  }
2987
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapTransitLayer, decorators: [{
3228
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapTransitLayer, decorators: [{
2988
3229
  type: Directive,
2989
3230
  args: [{
2990
3231
  selector: 'map-transit-layer',
2991
3232
  exportAs: 'mapTransitLayer',
2992
3233
  standalone: true,
2993
3234
  }]
2994
- }] });
3235
+ }], propDecorators: { transitLayerInitialized: [{
3236
+ type: Output
3237
+ }] } });
2995
3238
 
2996
3239
  /// <reference types="google.maps" />
2997
3240
  /**
@@ -3017,24 +3260,44 @@ class MapHeatmapLayer {
3017
3260
  constructor(_googleMap, _ngZone) {
3018
3261
  this._googleMap = _googleMap;
3019
3262
  this._ngZone = _ngZone;
3263
+ /** Event emitted when the heatmap is initialized. */
3264
+ this.heatmapInitialized = new EventEmitter();
3020
3265
  }
3021
3266
  ngOnInit() {
3022
3267
  if (this._googleMap._isBrowser) {
3023
- if (!window.google?.maps?.visualization && (typeof ngDevMode === 'undefined' || ngDevMode)) {
3268
+ if (!window.google?.maps?.visualization &&
3269
+ !window.google?.maps.importLibrary &&
3270
+ (typeof ngDevMode === 'undefined' || ngDevMode)) {
3024
3271
  throw Error('Namespace `google.maps.visualization` not found, cannot construct heatmap. ' +
3025
3272
  'Please install the Google Maps JavaScript API with the "visualization" library: ' +
3026
3273
  'https://developers.google.com/maps/documentation/javascript/visualization');
3027
3274
  }
3028
- // Create the object outside the zone so its events don't trigger change detection.
3029
- // We'll bring it back in inside the `MapEventManager` only for the events that the
3030
- // user has subscribed to.
3031
- this._ngZone.runOutsideAngular(() => {
3032
- this.heatmap = new google.maps.visualization.HeatmapLayer(this._combineOptions());
3033
- });
3034
- this._assertInitialized();
3035
- this.heatmap.setMap(this._googleMap.googleMap);
3275
+ if (google.maps.visualization?.HeatmapLayer && this._googleMap.googleMap) {
3276
+ this._initialize(this._googleMap.googleMap, google.maps.visualization.HeatmapLayer);
3277
+ }
3278
+ else {
3279
+ this._ngZone.runOutsideAngular(() => {
3280
+ Promise.all([
3281
+ this._googleMap._resolveMap(),
3282
+ importLibrary('visualization', 'HeatmapLayer'),
3283
+ ]).then(([map, heatmapConstructor]) => {
3284
+ this._initialize(map, heatmapConstructor);
3285
+ });
3286
+ });
3287
+ }
3036
3288
  }
3037
3289
  }
3290
+ _initialize(map, heatmapConstructor) {
3291
+ // Create the object outside the zone so its events don't trigger change detection.
3292
+ // We'll bring it back in inside the `MapEventManager` only for the events that the
3293
+ // user has subscribed to.
3294
+ this._ngZone.runOutsideAngular(() => {
3295
+ this.heatmap = new heatmapConstructor(this._combineOptions());
3296
+ this._assertInitialized();
3297
+ this.heatmap.setMap(map);
3298
+ this.heatmapInitialized.emit(this.heatmap);
3299
+ });
3300
+ }
3038
3301
  ngOnChanges(changes) {
3039
3302
  const { _data, heatmap } = this;
3040
3303
  if (heatmap) {
@@ -3047,9 +3310,7 @@ class MapHeatmapLayer {
3047
3310
  }
3048
3311
  }
3049
3312
  ngOnDestroy() {
3050
- if (this.heatmap) {
3051
- this.heatmap.setMap(null);
3052
- }
3313
+ this.heatmap?.setMap(null);
3053
3314
  }
3054
3315
  /**
3055
3316
  * Gets the data that is currently shown on the heatmap.
@@ -3086,20 +3347,16 @@ class MapHeatmapLayer {
3086
3347
  /** Asserts that the heatmap object has been initialized. */
3087
3348
  _assertInitialized() {
3088
3349
  if (typeof ngDevMode === 'undefined' || ngDevMode) {
3089
- if (!this._googleMap.googleMap) {
3090
- throw Error('Cannot access Google Map information before the API has been initialized. ' +
3091
- 'Please wait for the API to load before trying to interact with it.');
3092
- }
3093
3350
  if (!this.heatmap) {
3094
3351
  throw Error('Cannot interact with a Google Map HeatmapLayer before it has been ' +
3095
3352
  'initialized. Please wait for the heatmap to load before trying to interact with it.');
3096
3353
  }
3097
3354
  }
3098
3355
  }
3099
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapHeatmapLayer, deps: [{ token: GoogleMap }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
3100
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.0-next.2", type: MapHeatmapLayer, isStandalone: true, selector: "map-heatmap-layer", inputs: { data: "data", options: "options" }, exportAs: ["mapHeatmapLayer"], usesOnChanges: true, ngImport: i0 }); }
3356
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapHeatmapLayer, deps: [{ token: GoogleMap }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
3357
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.0-next.5", type: MapHeatmapLayer, isStandalone: true, selector: "map-heatmap-layer", inputs: { data: "data", options: "options" }, outputs: { heatmapInitialized: "heatmapInitialized" }, exportAs: ["mapHeatmapLayer"], usesOnChanges: true, ngImport: i0 }); }
3101
3358
  }
3102
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapHeatmapLayer, decorators: [{
3359
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapHeatmapLayer, decorators: [{
3103
3360
  type: Directive,
3104
3361
  args: [{
3105
3362
  selector: 'map-heatmap-layer',
@@ -3110,6 +3367,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2",
3110
3367
  type: Input
3111
3368
  }], options: [{
3112
3369
  type: Input
3370
+ }], heatmapInitialized: [{
3371
+ type: Output
3113
3372
  }] } });
3114
3373
  /** Asserts that an object is a `LatLngLiteral`. */
3115
3374
  function isLatLngLiteral(value) {
@@ -3135,8 +3394,8 @@ const COMPONENTS = [
3135
3394
  MapTransitLayer,
3136
3395
  ];
3137
3396
  class GoogleMapsModule {
3138
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: GoogleMapsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
3139
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.1.0-next.2", ngImport: i0, type: GoogleMapsModule, imports: [GoogleMap,
3397
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: GoogleMapsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
3398
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.1.0-next.5", ngImport: i0, type: GoogleMapsModule, imports: [GoogleMap,
3140
3399
  MapBaseLayer,
3141
3400
  MapBicyclingLayer,
3142
3401
  MapCircle,
@@ -3167,9 +3426,9 @@ class GoogleMapsModule {
3167
3426
  MapRectangle,
3168
3427
  MapTrafficLayer,
3169
3428
  MapTransitLayer] }); }
3170
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: GoogleMapsModule }); }
3429
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: GoogleMapsModule }); }
3171
3430
  }
3172
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: GoogleMapsModule, decorators: [{
3431
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: GoogleMapsModule, decorators: [{
3173
3432
  type: NgModule,
3174
3433
  args: [{
3175
3434
  imports: COMPONENTS,
@@ -3195,23 +3454,34 @@ class MapDirectionsService {
3195
3454
  */
3196
3455
  route(request) {
3197
3456
  return new Observable(observer => {
3198
- // Initialize the `DirectionsService` lazily since the Google Maps API may
3199
- // not have been loaded when the provider is instantiated.
3200
- if (!this._directionsService) {
3201
- this._directionsService = new google.maps.DirectionsService();
3202
- }
3203
- this._directionsService.route(request, (result, status) => {
3204
- this._ngZone.run(() => {
3205
- observer.next({ result: result || undefined, status });
3206
- observer.complete();
3457
+ this._getService().then(service => {
3458
+ service.route(request, (result, status) => {
3459
+ this._ngZone.run(() => {
3460
+ observer.next({ result: result || undefined, status });
3461
+ observer.complete();
3462
+ });
3207
3463
  });
3208
3464
  });
3209
3465
  });
3210
3466
  }
3211
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapDirectionsService, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable }); }
3212
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapDirectionsService, providedIn: 'root' }); }
3467
+ _getService() {
3468
+ if (!this._directionsService) {
3469
+ if (google.maps.DirectionsService) {
3470
+ this._directionsService = new google.maps.DirectionsService();
3471
+ }
3472
+ else {
3473
+ return importLibrary('routes', 'DirectionsService').then(serviceConstructor => {
3474
+ this._directionsService = new serviceConstructor();
3475
+ return this._directionsService;
3476
+ });
3477
+ }
3478
+ }
3479
+ return Promise.resolve(this._directionsService);
3480
+ }
3481
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapDirectionsService, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable }); }
3482
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapDirectionsService, providedIn: 'root' }); }
3213
3483
  }
3214
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapDirectionsService, decorators: [{
3484
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapDirectionsService, decorators: [{
3215
3485
  type: Injectable,
3216
3486
  args: [{ providedIn: 'root' }]
3217
3487
  }], ctorParameters: () => [{ type: i0.NgZone }] });
@@ -3230,23 +3500,34 @@ class MapGeocoder {
3230
3500
  */
3231
3501
  geocode(request) {
3232
3502
  return new Observable(observer => {
3233
- // Initialize the `Geocoder` lazily since the Google Maps API may
3234
- // not have been loaded when the provider is instantiated.
3235
- if (!this._geocoder) {
3236
- this._geocoder = new google.maps.Geocoder();
3237
- }
3238
- this._geocoder.geocode(request, (results, status) => {
3239
- this._ngZone.run(() => {
3240
- observer.next({ results: results || [], status });
3241
- observer.complete();
3503
+ this._getGeocoder().then(geocoder => {
3504
+ geocoder.geocode(request, (results, status) => {
3505
+ this._ngZone.run(() => {
3506
+ observer.next({ results: results || [], status });
3507
+ observer.complete();
3508
+ });
3242
3509
  });
3243
3510
  });
3244
3511
  });
3245
3512
  }
3246
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapGeocoder, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable }); }
3247
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapGeocoder, providedIn: 'root' }); }
3513
+ _getGeocoder() {
3514
+ if (!this._geocoder) {
3515
+ if (google.maps.Geocoder) {
3516
+ this._geocoder = new google.maps.Geocoder();
3517
+ }
3518
+ else {
3519
+ return importLibrary('geocoding', 'Geocoder').then(geocoderConstructor => {
3520
+ this._geocoder = new geocoderConstructor();
3521
+ return this._geocoder;
3522
+ });
3523
+ }
3524
+ }
3525
+ return Promise.resolve(this._geocoder);
3526
+ }
3527
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapGeocoder, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable }); }
3528
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapGeocoder, providedIn: 'root' }); }
3248
3529
  }
3249
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.2", ngImport: i0, type: MapGeocoder, decorators: [{
3530
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.0-next.5", ngImport: i0, type: MapGeocoder, decorators: [{
3250
3531
  type: Injectable,
3251
3532
  args: [{ providedIn: 'root' }]
3252
3533
  }], ctorParameters: () => [{ type: i0.NgZone }] });