Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(google-maps): add clusterer click event #22345

Merged
merged 1 commit into from
Mar 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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));
});
});

Expand All @@ -285,7 +287,8 @@ describe('MapMarkerClusterer', () => {
[zIndex]="zIndex"
[zoomOnClick]="zoomOnClick"
[options]="options"
(clusteringbegin)="onClusteringBegin()">
(clusteringbegin)="onClusteringBegin()"
(clusterClick)="onClusterClick()">
<map-marker *ngIf="state === 'state1'"></map-marker>
<map-marker *ngIf="state === 'state1' || state === 'state2'"></map-marker>
<map-marker *ngIf="state === 'state2'"></map-marker>
Expand Down Expand Up @@ -318,4 +321,5 @@ class TestApp {
state = 'state1';

onClusteringBegin() {}
onClusterClick() {}
}
4 changes: 4 additions & 0 deletions src/google-maps/map-marker-clusterer/map-marker-clusterer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ export class MapMarkerClusterer implements OnInit, AfterContentInit, OnChanges,
@Output()
clusteringend: Observable<void> = this._eventManager.getLazyEmitter<void>('clusteringend');

/** Emits when a cluster has been clicked. */
@Output()
clusterClick: Observable<Cluster> = this._eventManager.getLazyEmitter<Cluster>('click');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not totally sure about the correct name here. In other places we've been using the map prefix (e.g. mapClick on the marker), but in this case the user is clicking a cluster within the clusterer, not the map. I'm open to changing the name.


@ContentChildren(MapMarker, {descendants: true}) _markers: QueryList<MapMarker>;

/**
Expand Down
3 changes: 2 additions & 1 deletion tools/public_api_guard/google-maps/google-maps.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Cluster>;
clusteringbegin: Observable<void>;
clusteringend: Observable<void>;
set enableRetinaIcons(enableRetinaIcons: boolean);
Expand Down Expand Up @@ -325,7 +326,7 @@ export declare class MapMarkerClusterer implements OnInit, AfterContentInit, OnC
ngOnChanges(changes: SimpleChanges): void;
ngOnDestroy(): void;
ngOnInit(): void;
static ɵcmp: i0.ɵɵComponentDefWithMeta<MapMarkerClusterer, "map-marker-clusterer", ["mapMarkerClusterer"], { "ariaLabelFn": "ariaLabelFn"; "averageCenter": "averageCenter"; "batchSize": "batchSize"; "batchSizeIE": "batchSizeIE"; "calculator": "calculator"; "clusterClass": "clusterClass"; "enableRetinaIcons": "enableRetinaIcons"; "gridSize": "gridSize"; "ignoreHidden": "ignoreHidden"; "imageExtension": "imageExtension"; "imagePath": "imagePath"; "imageSizes": "imageSizes"; "maxZoom": "maxZoom"; "minimumClusterSize": "minimumClusterSize"; "styles": "styles"; "title": "title"; "zIndex": "zIndex"; "zoomOnClick": "zoomOnClick"; "options": "options"; }, { "clusteringbegin": "clusteringbegin"; "clusteringend": "clusteringend"; }, ["_markers"], ["*"]>;
static ɵcmp: i0.ɵɵComponentDefWithMeta<MapMarkerClusterer, "map-marker-clusterer", ["mapMarkerClusterer"], { "ariaLabelFn": "ariaLabelFn"; "averageCenter": "averageCenter"; "batchSize": "batchSize"; "batchSizeIE": "batchSizeIE"; "calculator": "calculator"; "clusterClass": "clusterClass"; "enableRetinaIcons": "enableRetinaIcons"; "gridSize": "gridSize"; "ignoreHidden": "ignoreHidden"; "imageExtension": "imageExtension"; "imagePath": "imagePath"; "imageSizes": "imageSizes"; "maxZoom": "maxZoom"; "minimumClusterSize": "minimumClusterSize"; "styles": "styles"; "title": "title"; "zIndex": "zIndex"; "zoomOnClick": "zoomOnClick"; "options": "options"; }, { "clusteringbegin": "clusteringbegin"; "clusteringend": "clusteringend"; "clusterClick": "clusterClick"; }, ["_markers"], ["*"]>;
static ɵfac: i0.ɵɵFactoryDef<MapMarkerClusterer, never>;
}

Expand Down