From 1f9ce7b467e353c9c3c8417e06e279874320b590 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Thu, 25 Mar 2021 21:24:50 +0100 Subject: [PATCH] feat(google-maps): add clusterer click event Adds an event that emits when a cluster has been clicked. Fixes #22020. --- .../map-marker-clusterer/map-marker-clusterer.spec.ts | 6 +++++- .../map-marker-clusterer/map-marker-clusterer.ts | 4 ++++ tools/public_api_guard/google-maps/google-maps.d.ts | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/google-maps/map-marker-clusterer/map-marker-clusterer.spec.ts b/src/google-maps/map-marker-clusterer/map-marker-clusterer.spec.ts index 2a5ef6934385..d6deced3df6c 100644 --- a/src/google-maps/map-marker-clusterer/map-marker-clusterer.spec.ts +++ b/src/google-maps/map-marker-clusterer/map-marker-clusterer.spec.ts @@ -260,6 +260,8 @@ describe('MapMarkerClusterer', () => { .toHaveBeenCalledWith('clusteringbegin', jasmine.any(Function)); expect(markerClustererSpy.addListener) .not.toHaveBeenCalledWith('clusteringend', jasmine.any(Function)); + expect(markerClustererSpy.addListener) + .toHaveBeenCalledWith('click', jasmine.any(Function)); }); }); @@ -285,7 +287,8 @@ describe('MapMarkerClusterer', () => { [zIndex]="zIndex" [zoomOnClick]="zoomOnClick" [options]="options" - (clusteringbegin)="onClusteringBegin()"> + (clusteringbegin)="onClusteringBegin()" + (clusterClick)="onClusterClick()"> @@ -318,4 +321,5 @@ class TestApp { state = 'state1'; onClusteringBegin() {} + onClusterClick() {} } diff --git a/src/google-maps/map-marker-clusterer/map-marker-clusterer.ts b/src/google-maps/map-marker-clusterer/map-marker-clusterer.ts index cb5778093d91..98498bec79dd 100644 --- a/src/google-maps/map-marker-clusterer/map-marker-clusterer.ts +++ b/src/google-maps/map-marker-clusterer/map-marker-clusterer.ts @@ -177,6 +177,10 @@ export class MapMarkerClusterer implements OnInit, AfterContentInit, OnChanges, @Output() clusteringend: Observable = this._eventManager.getLazyEmitter('clusteringend'); + /** Emits when a cluster has been clicked. */ + @Output() + clusterClick: Observable = this._eventManager.getLazyEmitter('click'); + @ContentChildren(MapMarker, {descendants: true}) _markers: QueryList; /** diff --git a/tools/public_api_guard/google-maps/google-maps.d.ts b/tools/public_api_guard/google-maps/google-maps.d.ts index b08f944bbf75..7236566281c9 100644 --- a/tools/public_api_guard/google-maps/google-maps.d.ts +++ b/tools/public_api_guard/google-maps/google-maps.d.ts @@ -284,6 +284,7 @@ export declare class MapMarkerClusterer implements OnInit, AfterContentInit, OnC set batchSizeIE(batchSizeIE: number); set calculator(calculator: Calculator); set clusterClass(clusterClass: string); + clusterClick: Observable; clusteringbegin: Observable; clusteringend: Observable; set enableRetinaIcons(enableRetinaIcons: boolean); @@ -325,7 +326,7 @@ export declare class MapMarkerClusterer implements OnInit, AfterContentInit, OnC ngOnChanges(changes: SimpleChanges): void; ngOnDestroy(): void; ngOnInit(): void; - static ɵcmp: i0.ɵɵComponentDefWithMeta; + static ɵcmp: i0.ɵɵComponentDefWithMeta; static ɵfac: i0.ɵɵFactoryDef; }