Skip to content

Commit b8201ed

Browse files
authored
fix(google-maps): deprecate heatmap layer (angular#33208)
The APIs that the heatmap layer is based on have been deprecated for about a year and Google Maps will remove them later this month. These changes turn the `map-heatmap-layer` into a no-op and log an error message so that users know what is happening.
1 parent 05cc247 commit b8201ed

9 files changed

Lines changed: 33 additions & 460 deletions

File tree

goldens/google-maps/index.api.md

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,8 @@ export class GoogleMapsModule {
305305
static ɵmod: i0.ɵɵNgModuleDeclaration<GoogleMapsModule, never, [typeof GoogleMap, typeof MapBaseLayer, typeof MapBicyclingLayer, typeof MapCircle, typeof MapDirectionsRenderer, typeof MapGroundOverlay, typeof MapHeatmapLayer, typeof MapInfoWindow, typeof MapKmlLayer, typeof MapMarker, typeof MapAdvancedMarker, typeof DeprecatedMapMarkerClusterer, typeof MapPolygon, typeof MapPolyline, typeof MapRectangle, typeof MapTrafficLayer, typeof MapTransitLayer, typeof MapMarkerClusterer], [typeof GoogleMap, typeof MapBaseLayer, typeof MapBicyclingLayer, typeof MapCircle, typeof MapDirectionsRenderer, typeof MapGroundOverlay, typeof MapHeatmapLayer, typeof MapInfoWindow, typeof MapKmlLayer, typeof MapMarker, typeof MapAdvancedMarker, typeof DeprecatedMapMarkerClusterer, typeof MapPolygon, typeof MapPolyline, typeof MapRectangle, typeof MapTrafficLayer, typeof MapTransitLayer, typeof MapMarkerClusterer]>;
306306
}
307307

308-
// @public
309-
export type HeatmapData = google.maps.MVCArray<google.maps.LatLng | google.maps.visualization.WeightedLocation | google.maps.LatLngLiteral> | (google.maps.LatLng | google.maps.visualization.WeightedLocation | google.maps.LatLngLiteral)[];
308+
// @public @deprecated
309+
export type HeatmapData = any;
310310

311311
// @public
312312
export class MapAdvancedMarker implements OnInit, OnChanges, OnDestroy, MapAnchorPoint, MarkerDirective {
@@ -532,19 +532,14 @@ export class MapGroundOverlay implements OnInit, OnDestroy {
532532
static ɵfac: i0.ɵɵFactoryDeclaration<MapGroundOverlay, never>;
533533
}
534534

535-
// @public
536-
export class MapHeatmapLayer implements OnInit, OnChanges, OnDestroy {
535+
// @public @deprecated
536+
export class MapHeatmapLayer {
537+
constructor();
537538
set data(data: HeatmapData);
538539
getData(): HeatmapData;
539-
heatmap?: google.maps.visualization.HeatmapLayer;
540-
readonly heatmapInitialized: EventEmitter<google.maps.visualization.HeatmapLayer>;
541-
// (undocumented)
542-
ngOnChanges(changes: SimpleChanges<this>): void;
543-
// (undocumented)
544-
ngOnDestroy(): void;
545-
// (undocumented)
546-
ngOnInit(): void;
547-
set options(options: Partial<google.maps.visualization.HeatmapLayerOptions>);
540+
heatmap?: any;
541+
readonly heatmapInitialized: EventEmitter<any>;
542+
set options(options: any);
548543
// (undocumented)
549544
static ɵdir: i0.ɵɵDirectiveDeclaration<MapHeatmapLayer, "map-heatmap-layer", ["mapHeatmapLayer"], { "data": { "alias": "data"; "required": false; }; "options": { "alias": "options"; "required": false; }; }, { "heatmapInitialized": "heatmapInitialized"; }, never, never, true, never>;
550545
// (undocumented)

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,6 @@
7272
@if (directionsResult) {
7373
<map-directions-renderer [directions]="directionsResult"></map-directions-renderer>
7474
}
75-
@if (isHeatmapDisplayed) {
76-
<map-heatmap-layer
77-
[data]="heatmapData"
78-
[options]="heatmapOptions"></map-heatmap-layer>
79-
}
8075
</google-map>
8176

8277
<p><label>Latitude:</label> {{display?.lat}}</p>
@@ -206,13 +201,6 @@
206201
</label>
207202
</div>
208203

209-
<div>
210-
<label for="heatmap-layer-checkbox">
211-
Toggle Heatmap Layer
212-
<input type="checkbox" (click)="toggleHeatmapLayerDisplay()">
213-
</label>
214-
</div>
215-
216204
<div>
217205
<label>
218206
Toggle Advanced Marker with custom content

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

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import {
2424
MapDirectionsRenderer,
2525
MapDirectionsService,
2626
MapGroundOverlay,
27-
MapHeatmapLayer,
2827
MapInfoWindow,
2928
MapKmlLayer,
3029
MapPolygon,
@@ -73,7 +72,6 @@ let apiLoadingPromise: Promise<unknown> | null = null;
7372
MapCircle,
7473
MapDirectionsRenderer,
7574
MapGroundOverlay,
76-
MapHeatmapLayer,
7775
MapInfoWindow,
7876
MapKmlLayer,
7977
MapMarkerClusterer,
@@ -108,10 +106,6 @@ export class GoogleMapDemo {
108106
strokeOpacity: 0.8,
109107
};
110108

111-
heatmapData = this._getHeatmapData(5, 1);
112-
heatmapOptions = {radius: 50};
113-
isHeatmapDisplayed = false;
114-
115109
isPolygonDisplayed = false;
116110
polygonOptions: google.maps.PolygonOptions = {
117111
paths: POLYGON_PATH,
@@ -234,22 +228,6 @@ export class GoogleMapDemo {
234228
}
235229
}
236230

237-
toggleHeatmapLayerDisplay() {
238-
this.isHeatmapDisplayed = !this.isHeatmapDisplayed;
239-
}
240-
241-
private _getHeatmapData(offset: number, increment: number) {
242-
const result: google.maps.LatLngLiteral[] = [];
243-
244-
for (let lat = this.center.lat - offset; lat < this.center.lat + offset; lat += increment) {
245-
for (let lng = this.center.lng - offset; lng < this.center.lng + offset; lng += increment) {
246-
result.push({lat, lng});
247-
}
248-
}
249-
250-
return result;
251-
}
252-
253231
private _loadApi() {
254232
if (this.hasLoaded) {
255233
return;

src/google-maps/map-heatmap-layer/README.md

Lines changed: 0 additions & 48 deletions
This file was deleted.

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

Lines changed: 0 additions & 167 deletions
This file was deleted.

0 commit comments

Comments
 (0)