Skip to content

Commit 7b0cd0f

Browse files
committed
feat(google-maps): switch to non-deprecated typings
Moves the `google-maps` package away from the deprecated typings. Fixes #22818.
1 parent 9107ac0 commit 7b0cd0f

File tree

32 files changed

+84
-77
lines changed

32 files changed

+84
-77
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"@angular/core": "12.1.2",
6262
"@angular/forms": "12.1.2",
6363
"@angular/platform-browser": "12.1.2",
64-
"@types/googlemaps": "^3.43.1",
64+
"@types/google.maps": "^3.45.6",
6565
"@types/youtube": "^0.0.42",
6666
"core-js-bundle": "^3.8.2",
6767
"material-components-web": "12.0.0-canary.5f00e454a.0",

src/dev-app/google-map/google-map-demo.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,13 @@ export class GoogleMapDemo {
112112
}
113113

114114
handleClick(event: google.maps.MapMouseEvent) {
115-
this.markerPositions.push(event.latLng.toJSON());
115+
if (event.latLng) {
116+
this.markerPositions.push(event.latLng.toJSON());
117+
}
116118
}
117119

118120
handleMove(event: google.maps.MapMouseEvent) {
119-
this.display = event.latLng.toJSON();
121+
this.display = event.latLng?.toJSON();
120122
}
121123

122124
clickMarker(marker: MapMarker) {

src/google-maps/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ng_module(
1414
"//src:dev_mode_types",
1515
"@npm//@angular/common",
1616
"@npm//@angular/core",
17-
"@npm//@types/googlemaps",
17+
"@npm//@types/google.maps",
1818
"@npm//rxjs",
1919
],
2020
)

src/google-maps/google-map/google-map.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ describe('GoogleMap', () => {
257257

258258
const component = fixture.debugElement.query(By.directive(GoogleMap)).componentInstance;
259259

260-
mapSpy.getBounds.and.returnValue(null);
260+
mapSpy.getBounds.and.returnValue(undefined);
261261
expect(component.getBounds()).toBe(null);
262262

263263
component.getCenter();
@@ -272,7 +272,7 @@ describe('GoogleMap', () => {
272272
component.getMapTypeId();
273273
expect(mapSpy.getMapTypeId).toHaveBeenCalled();
274274

275-
mapSpy.getProjection.and.returnValue(null);
275+
mapSpy.getProjection.and.returnValue(undefined);
276276
expect(component.getProjection()).toBe(null);
277277

278278
component.getStreetView();

src/google-maps/google-map/google-map.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
// Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1265
10-
/// <reference types="googlemaps" />
10+
/// <reference types="google.maps" />
1111

1212
import {
1313
ChangeDetectionStrategy,
@@ -372,7 +372,7 @@ export class GoogleMap implements OnChanges, OnInit, OnDestroy {
372372
*/
373373
getCenter(): google.maps.LatLng {
374374
this._assertInitialized();
375-
return this.googleMap.getCenter();
375+
return this.googleMap.getCenter()!;
376376
}
377377

378378
/**
@@ -381,7 +381,7 @@ export class GoogleMap implements OnChanges, OnInit, OnDestroy {
381381
*/
382382
getClickableIcons(): boolean {
383383
this._assertInitialized();
384-
return this.googleMap.getClickableIcons();
384+
return this.googleMap.getClickableIcons()!;
385385
}
386386

387387
/**
@@ -390,7 +390,7 @@ export class GoogleMap implements OnChanges, OnInit, OnDestroy {
390390
*/
391391
getHeading(): number {
392392
this._assertInitialized();
393-
return this.googleMap.getHeading();
393+
return this.googleMap.getHeading()!;
394394
}
395395

396396
/**
@@ -399,7 +399,7 @@ export class GoogleMap implements OnChanges, OnInit, OnDestroy {
399399
*/
400400
getMapTypeId(): google.maps.MapTypeId|string {
401401
this._assertInitialized();
402-
return this.googleMap.getMapTypeId();
402+
return this.googleMap.getMapTypeId()!;
403403
}
404404

405405
/**
@@ -408,7 +408,7 @@ export class GoogleMap implements OnChanges, OnInit, OnDestroy {
408408
*/
409409
getProjection(): google.maps.Projection|null {
410410
this._assertInitialized();
411-
return this.googleMap.getProjection();
411+
return this.googleMap.getProjection() || null;
412412
}
413413

414414
/**
@@ -426,7 +426,7 @@ export class GoogleMap implements OnChanges, OnInit, OnDestroy {
426426
*/
427427
getTilt(): number {
428428
this._assertInitialized();
429-
return this.googleMap.getTilt();
429+
return this.googleMap.getTilt()!;
430430
}
431431

432432
/**
@@ -435,7 +435,7 @@ export class GoogleMap implements OnChanges, OnInit, OnDestroy {
435435
*/
436436
getZoom(): number {
437437
this._assertInitialized();
438-
return this.googleMap.getZoom();
438+
return this.googleMap.getZoom()!;
439439
}
440440

441441
/**

src/google-maps/map-anchor-point.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
// Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1265
10-
/// <reference types="googlemaps" />
10+
/// <reference types="google.maps" />
1111

1212
export interface MapAnchorPoint {
1313
getAnchor(): google.maps.MVCObject;

src/google-maps/map-base-layer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
// Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1265
10-
/// <reference types="googlemaps" />
10+
/// <reference types="google.maps" />
1111

1212
import {Directive, NgZone, OnDestroy, OnInit} from '@angular/core';
1313

src/google-maps/map-bicycling-layer/map-bicycling-layer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
// Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1265
10-
/// <reference types="googlemaps" />
10+
/// <reference types="google.maps" />
1111

1212
import {Directive} from '@angular/core';
1313

src/google-maps/map-circle/map-circle.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
// Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1265
10-
/// <reference types="googlemaps" />
10+
/// <reference types="google.maps" />
1111

1212
import {Directive, Input, NgZone, OnDestroy, OnInit, Output} from '@angular/core';
1313
import {BehaviorSubject, combineLatest, Observable, Subject} from 'rxjs';
@@ -183,7 +183,7 @@ export class MapCircle implements OnInit, OnDestroy {
183183
*/
184184
getBounds(): google.maps.LatLngBounds {
185185
this._assertInitialized();
186-
return this.circle.getBounds();
186+
return this.circle.getBounds()!;
187187
}
188188

189189
/**
@@ -192,7 +192,7 @@ export class MapCircle implements OnInit, OnDestroy {
192192
*/
193193
getCenter(): google.maps.LatLng {
194194
this._assertInitialized();
195-
return this.circle.getCenter();
195+
return this.circle.getCenter()!;
196196
}
197197

198198
/**

src/google-maps/map-directions-renderer/map-directions-renderer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
// Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1265
10-
/// <reference types="googlemaps" />
10+
/// <reference types="google.maps" />
1111

1212
import {
1313
Directive,
@@ -108,7 +108,7 @@ export class MapDirectionsRenderer implements OnInit, OnChanges, OnDestroy {
108108
*/
109109
getDirections(): google.maps.DirectionsResult {
110110
this._assertInitialized();
111-
return this.directionsRenderer.getDirections();
111+
return this.directionsRenderer.getDirections()!;
112112
}
113113

114114
/**
@@ -117,7 +117,7 @@ export class MapDirectionsRenderer implements OnInit, OnChanges, OnDestroy {
117117
*/
118118
getPanel(): Node {
119119
this._assertInitialized();
120-
return this.directionsRenderer.getPanel();
120+
return this.directionsRenderer.getPanel()!;
121121
}
122122

123123
/**

0 commit comments

Comments
 (0)