Skip to content

Commit 28eff59

Browse files
committed
feat(google-maps): switch to non-deprecated API for clustering
The marker clusterer component is currently based on the `@googlemaps/markerclustererplus` package which is deprecated. These changes rewrite the component to use `@googlemaps/markerclusterer` instead. BREAKING CHANGES: The new `@googlemaps/markerclusterer` API should be imported instead of the old one. Read more at: https://github.com/googlemaps/js-markerclusterer Furthermore, the new clustering package doesn't offer the same set of public APIs. As a result, the following inputs to the `MapMarkerClusterer` component have been removed: * `ariaLabelFn` * `averageCenter` * `batchSizeIE` * `calculator` * `clusterClass` * `enableRetinaIcons` * `gridSize` * `ignoreHidden` * `imageExtension` * `imagePath` * `imageSizes` * `maxZoom` * `minimumClusterSize` * `styles` * `title` * `zIndex` * `zoomOnClick` * `options` It is now recommended to customize the cluster using the `renderer` and `algorithm` inputs. Fixes #23695.
1 parent fb4e395 commit 28eff59

File tree

9 files changed

+326
-901
lines changed

9 files changed

+326
-901
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
(mapMousemove)="handleMove($event)"
99
(mapRightclick)="handleRightclick()"
1010
[mapTypeId]="mapTypeId">
11-
<map-marker-clusterer [imagePath]="markerClustererImagePath">
11+
<map-marker-clusterer>
1212
<map-marker #firstMarker="mapMarker"
1313
[position]="center"
1414
(mapClick)="clickMarker(firstMarker)"></map-marker>

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,6 @@ export class GoogleMapDemo {
119119
google.maps.MapTypeId.TERRAIN,
120120
];
121121

122-
markerClustererImagePath =
123-
'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m';
124-
125122
directionsResult?: google.maps.DirectionsResult;
126123

127124
constructor(private readonly _mapDirectionsService: MapDirectionsService) {}

src/dev-app/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
<script src="zone.js/dist/zone.js"></script>
2222
<script src="https://www.youtube.com/iframe_api"></script>
23-
<script src="https://unpkg.com/@googlemaps/markerclustererplus/dist/index.min.js"></script>
23+
<script src="https://unpkg.com/@googlemaps/markerclusterer/dist/index.min.js"></script>
2424
<script>
2525
(function loadGoogleMaps() {
2626
// Key can be set through the `GOOGLE_MAPS_KEY` environment variable.

src/google-maps/map-marker-clusterer/README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
#MapMarkerClusterer
1+
# MapMarkerClusterer
22

3-
The `MapMarkerClusterer` component wraps the [`MarkerClusterer` class](https://googlemaps.github.io/js-markerclustererplus/classes/markerclusterer.html) from the [Google Maps JavaScript MarkerClustererPlus Library](https://github.com/googlemaps/js-markerclustererplus). The `MapMarkerClusterer` component displays a cluster of markers that are children of the `<map-marker-clusterer>` tag. Unlike the other Google Maps components, MapMarkerClusterer does not have an `options` input, so any input (listed in the [documentation](https://googlemaps.github.io/js-markerclustererplus/index.html) for the `MarkerClusterer` class) should be set directly.
3+
The `MapMarkerClusterer` component wraps the [`MarkerClusterer` class](https://googlemaps.github.io/js-markerclusterer/classes/MarkerClusterer.html) from the [Google Maps JavaScript MarkerClusterer Library](https://github.com/googlemaps/js-markerclusterer). The `MapMarkerClusterer` component displays a cluster of markers that are children of the `<map-marker-clusterer>` tag. Unlike the other Google Maps components, MapMarkerClusterer does not have an `options` input, so any input (listed in the [documentation](https://googlemaps.github.io/js-markerclusterer/) for the `MarkerClusterer` class) should be set directly.
44

55
## Loading the Library
66

7-
Like the Google Maps JavaScript API, the MarkerClustererPlus library needs to be loaded separately. This can be accomplished by using this script tag:
7+
Like the Google Maps JavaScript API, the MarkerClusterer library needs to be loaded separately. This can be accomplished by using this script tag:
88

99
```html
10-
<script src="https://unpkg.com/@googlemaps/markerclustererplus/dist/index.min.js"></script>
10+
<script src="https://unpkg.com/@googlemaps/markerclusterer/dist/index.min.js"></script>
1111
```
1212

1313
Additional information can be found by looking at [Marker Clustering](https://developers.google.com/maps/documentation/javascript/marker-clustering) in the Google Maps JavaScript API documentation.
@@ -26,8 +26,6 @@ export class GoogleMapDemo {
2626
center: google.maps.LatLngLiteral = {lat: 24, lng: 12};
2727
zoom = 4;
2828
markerPositions: google.maps.LatLngLiteral[] = [];
29-
markerClustererImagePath =
30-
'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m';
3129

3230
addMarker(event: google.maps.MapMouseEvent) {
3331
this.markerPositions.push(event.latLng.toJSON());
@@ -42,7 +40,7 @@ export class GoogleMapDemo {
4240
[center]="center"
4341
[zoom]="zoom"
4442
(mapClick)="addMarker($event)">
45-
<map-marker-clusterer [imagePath]="markerClustererImagePath">
43+
<map-marker-clusterer>
4644
<map-marker *ngFor="let markerPosition of markerPositions"
4745
[position]="markerPosition"></map-marker>
4846
</map-marker-clusterer>

0 commit comments

Comments
 (0)