Skip to content

Commit 7c16258

Browse files
authored
feat(google-maps): switch to non-deprecated typings (#23350)
Moves the `google-maps` package away from the deprecated typings. Fixes #22818.
1 parent 3913883 commit 7c16258

File tree

32 files changed

+101
-94
lines changed

32 files changed

+101
-94
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"@angular/core": "13.0.0-next.8",
5959
"@angular/forms": "13.0.0-next.8",
6060
"@angular/platform-browser": "13.0.0-next.8",
61-
"@types/googlemaps": "^3.43.1",
61+
"@types/google.maps": "^3.45.6",
6262
"@types/youtube": "^0.0.42",
6363
"core-js-bundle": "^3.8.2",
6464
"material-components-web": "13.0.0-canary.860ad06a1.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: 9 additions & 9 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,
@@ -370,7 +370,7 @@ export class GoogleMap implements OnChanges, OnInit, OnDestroy {
370370
* See
371371
* https://developers.google.com/maps/documentation/javascript/reference/map#Map.getCenter
372372
*/
373-
getCenter(): google.maps.LatLng {
373+
getCenter(): google.maps.LatLng | undefined {
374374
this._assertInitialized();
375375
return this.googleMap.getCenter();
376376
}
@@ -379,7 +379,7 @@ export class GoogleMap implements OnChanges, OnInit, OnDestroy {
379379
* See
380380
* https://developers.google.com/maps/documentation/javascript/reference/map#Map.getClickableIcons
381381
*/
382-
getClickableIcons(): boolean {
382+
getClickableIcons(): boolean | undefined {
383383
this._assertInitialized();
384384
return this.googleMap.getClickableIcons();
385385
}
@@ -388,7 +388,7 @@ export class GoogleMap implements OnChanges, OnInit, OnDestroy {
388388
* See
389389
* https://developers.google.com/maps/documentation/javascript/reference/map#Map.getHeading
390390
*/
391-
getHeading(): number {
391+
getHeading(): number | undefined {
392392
this._assertInitialized();
393393
return this.googleMap.getHeading();
394394
}
@@ -397,7 +397,7 @@ export class GoogleMap implements OnChanges, OnInit, OnDestroy {
397397
* See
398398
* https://developers.google.com/maps/documentation/javascript/reference/map#Map.getMapTypeId
399399
*/
400-
getMapTypeId(): google.maps.MapTypeId|string {
400+
getMapTypeId(): google.maps.MapTypeId | string | undefined {
401401
this._assertInitialized();
402402
return this.googleMap.getMapTypeId();
403403
}
@@ -406,9 +406,9 @@ export class GoogleMap implements OnChanges, OnInit, OnDestroy {
406406
* See
407407
* https://developers.google.com/maps/documentation/javascript/reference/map#Map.getProjection
408408
*/
409-
getProjection(): google.maps.Projection|null {
409+
getProjection(): google.maps.Projection | null {
410410
this._assertInitialized();
411-
return this.googleMap.getProjection();
411+
return this.googleMap.getProjection() || null;
412412
}
413413

414414
/**
@@ -424,7 +424,7 @@ export class GoogleMap implements OnChanges, OnInit, OnDestroy {
424424
* See
425425
* https://developers.google.com/maps/documentation/javascript/reference/map#Map.getTilt
426426
*/
427-
getTilt(): number {
427+
getTilt(): number | undefined {
428428
this._assertInitialized();
429429
return this.googleMap.getTilt();
430430
}
@@ -433,7 +433,7 @@ export class GoogleMap implements OnChanges, OnInit, OnDestroy {
433433
* See
434434
* https://developers.google.com/maps/documentation/javascript/reference/map#Map.getZoom
435435
*/
436-
getZoom(): number {
436+
getZoom(): number | undefined {
437437
this._assertInitialized();
438438
return this.googleMap.getZoom();
439439
}

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';
@@ -181,7 +181,7 @@ export class MapCircle implements OnInit, OnDestroy {
181181
* @see
182182
* developers.google.com/maps/documentation/javascript/reference/polygon#Circle.getBounds
183183
*/
184-
getBounds(): google.maps.LatLngBounds {
184+
getBounds(): google.maps.LatLngBounds | null {
185185
this._assertInitialized();
186186
return this.circle.getBounds();
187187
}
@@ -190,7 +190,7 @@ export class MapCircle implements OnInit, OnDestroy {
190190
* @see
191191
* developers.google.com/maps/documentation/javascript/reference/polygon#Circle.getCenter
192192
*/
193-
getCenter(): google.maps.LatLng {
193+
getCenter(): google.maps.LatLng | null {
194194
this._assertInitialized();
195195
return this.circle.getCenter();
196196
}

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,
@@ -106,7 +106,7 @@ export class MapDirectionsRenderer implements OnInit, OnChanges, OnDestroy {
106106
* See developers.google.com/maps/documentation/javascript/reference/directions
107107
* #DirectionsRenderer.getDirections
108108
*/
109-
getDirections(): google.maps.DirectionsResult {
109+
getDirections(): google.maps.DirectionsResult | null {
110110
this._assertInitialized();
111111
return this.directionsRenderer.getDirections();
112112
}
@@ -115,7 +115,7 @@ export class MapDirectionsRenderer implements OnInit, OnChanges, OnDestroy {
115115
* See developers.google.com/maps/documentation/javascript/reference/directions
116116
* #DirectionsRenderer.getPanel
117117
*/
118-
getPanel(): Node {
118+
getPanel(): Node | null {
119119
this._assertInitialized();
120120
return this.directionsRenderer.getPanel();
121121
}

0 commit comments

Comments
 (0)