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/map-advanced-marker): Add support for some mouse events #29741 #29747

Merged
merged 1 commit into from
Sep 18, 2024
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
15 changes: 15 additions & 0 deletions src/google-maps/map-advanced-marker/map-advanced-marker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ describe('MapAdvancedMarker', () => {
flush();

expect(addSpy).toHaveBeenCalledWith('click', jasmine.any(Function));
expect(addSpy).toHaveBeenCalledWith('dblclick', jasmine.any(Function));
expect(addSpy).toHaveBeenCalledWith('mouseout', jasmine.any(Function));
expect(addSpy).toHaveBeenCalledWith('mouseover', jasmine.any(Function));
expect(addSpy).toHaveBeenCalledWith('mouseup', jasmine.any(Function));
expect(addSpy).toHaveBeenCalledWith('rightclick', jasmine.any(Function));
expect(addSpy).not.toHaveBeenCalledWith('drag', jasmine.any(Function));
expect(addSpy).not.toHaveBeenCalledWith('dragend', jasmine.any(Function));
expect(addSpy).not.toHaveBeenCalledWith('dragstart', jasmine.any(Function));
Expand Down Expand Up @@ -163,6 +168,11 @@ describe('MapAdvancedMarker', () => {
[gmpDraggable]="gmpDraggable"
[zIndex]="zIndex"
(mapClick)="handleClick()"
(mapDblclick)="handleDblclick()"
(mapMouseout)="handleMouseout()"
(mapMouseover)="handleMouseover()"
(mapMouseup)="handleMouseup()"
(mapRightclick)="handleRightclick()"
[options]="options" />
</google-map>
`,
Expand All @@ -179,4 +189,9 @@ class TestApp {
options: google.maps.marker.AdvancedMarkerElementOptions;

handleClick() {}
handleDblclick() {}
handleMouseout() {}
handleMouseover() {}
handleMouseup() {}
handleRightclick() {}
}
30 changes: 30 additions & 0 deletions src/google-maps/map-advanced-marker/map-advanced-marker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,36 @@ export class MapAdvancedMarker implements OnInit, OnChanges, OnDestroy, MapAncho
@Output() readonly mapClick: Observable<google.maps.MapMouseEvent> =
this._eventManager.getLazyEmitter<google.maps.MapMouseEvent>('click');

/**
* This event is fired when the AdvancedMarkerElement is double-clicked.
*/
@Output() readonly mapDblclick: Observable<google.maps.MapMouseEvent> =
this._eventManager.getLazyEmitter<google.maps.MapMouseEvent>('dblclick');

/**
* This event is fired when the mouse moves out of the AdvancedMarkerElement.
*/
@Output() readonly mapMouseout: Observable<google.maps.MapMouseEvent> =
this._eventManager.getLazyEmitter<google.maps.MapMouseEvent>('mouseout');

/**
* This event is fired when the mouse moves over the AdvancedMarkerElement.
*/
@Output() readonly mapMouseover: Observable<google.maps.MapMouseEvent> =
this._eventManager.getLazyEmitter<google.maps.MapMouseEvent>('mouseover');

/**
* This event is fired when the mouse button is released over the AdvancedMarkerElement.
*/
@Output() readonly mapMouseup: Observable<google.maps.MapMouseEvent> =
this._eventManager.getLazyEmitter<google.maps.MapMouseEvent>('mouseup');

/**
* This event is fired when the AdvancedMarkerElement is right-clicked.
*/
@Output() readonly mapRightclick: Observable<google.maps.MapMouseEvent> =
this._eventManager.getLazyEmitter<google.maps.MapMouseEvent>('rightclick');

/**
* This event is repeatedly fired while the user drags the AdvancedMarkerElement.
* https://developers.google.com/maps/documentation/javascript/reference/advanced-markers#AdvancedMarkerElement.drag
Expand Down
7 changes: 6 additions & 1 deletion tools/public_api_guard/google-maps/google-maps.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,14 @@ export class MapAdvancedMarker implements OnInit, OnChanges, OnDestroy, MapAncho
getAnchor(): google.maps.marker.AdvancedMarkerElement;
set gmpDraggable(draggable: boolean);
readonly mapClick: Observable<google.maps.MapMouseEvent>;
readonly mapDblclick: Observable<google.maps.MapMouseEvent>;
readonly mapDrag: Observable<google.maps.MapMouseEvent>;
readonly mapDragend: Observable<google.maps.MapMouseEvent>;
readonly mapDragstart: Observable<google.maps.MapMouseEvent>;
readonly mapMouseout: Observable<google.maps.MapMouseEvent>;
readonly mapMouseover: Observable<google.maps.MapMouseEvent>;
readonly mapMouseup: Observable<google.maps.MapMouseEvent>;
readonly mapRightclick: Observable<google.maps.MapMouseEvent>;
readonly markerInitialized: EventEmitter<google.maps.marker.AdvancedMarkerElement>;
// (undocumented)
ngOnChanges(changes: SimpleChanges): void;
Expand All @@ -158,7 +163,7 @@ export class MapAdvancedMarker implements OnInit, OnChanges, OnDestroy, MapAncho
set title(title: string);
set zIndex(zIndex: number);
// (undocumented)
static ɵdir: i0.ɵɵDirectiveDeclaration<MapAdvancedMarker, "map-advanced-marker", ["mapAdvancedMarker"], { "title": { "alias": "title"; "required": false; }; "position": { "alias": "position"; "required": false; }; "content": { "alias": "content"; "required": false; }; "gmpDraggable": { "alias": "gmpDraggable"; "required": false; }; "options": { "alias": "options"; "required": false; }; "zIndex": { "alias": "zIndex"; "required": false; }; }, { "mapClick": "mapClick"; "mapDrag": "mapDrag"; "mapDragend": "mapDragend"; "mapDragstart": "mapDragstart"; "markerInitialized": "markerInitialized"; }, never, never, true, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<MapAdvancedMarker, "map-advanced-marker", ["mapAdvancedMarker"], { "title": { "alias": "title"; "required": false; }; "position": { "alias": "position"; "required": false; }; "content": { "alias": "content"; "required": false; }; "gmpDraggable": { "alias": "gmpDraggable"; "required": false; }; "options": { "alias": "options"; "required": false; }; "zIndex": { "alias": "zIndex"; "required": false; }; }, { "mapClick": "mapClick"; "mapDblclick": "mapDblclick"; "mapMouseout": "mapMouseout"; "mapMouseover": "mapMouseover"; "mapMouseup": "mapMouseup"; "mapRightclick": "mapRightclick"; "mapDrag": "mapDrag"; "mapDragend": "mapDragend"; "mapDragstart": "mapDragstart"; "markerInitialized": "markerInitialized"; }, never, never, true, never>;
// (undocumented)
static ɵfac: i0.ɵɵFactoryDeclaration<MapAdvancedMarker, never>;
}
Expand Down
Loading