Skip to content

Commit

Permalink
feat(google-maps): Add support for mouse events in map-advanced-marker
Browse files Browse the repository at this point in the history
  • Loading branch information
sidhanshamil committed Sep 17, 2024
1 parent 2b972e1 commit 38dd022
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
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

0 comments on commit 38dd022

Please sign in to comment.