Skip to content

Commit

Permalink
feat(SebmGoogleMap): support double-click event
Browse files Browse the repository at this point in the history
Now, you can subscribe to double-click events:

```
<sebm-google-map
  [latitude]="lat"
  [longitude]="lng"
  (mapDblClick)="mapClicked($event)">
</sebm-google-map>
```

The $event is a `MapMouseEvent` type that contains
the coords of the double-click.

```
import {MapMouseEvent} from 'angular2-google-maps/core';

class App {
  mapClicked(event: MapMouseEvent) {
    console.log(event.coords.lat, event.coords.lng);
  }
}
```
  • Loading branch information
sebholstein committed Dec 27, 2015
1 parent eab715e commit 5f1ae68
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 5 additions & 4 deletions docs/api/components_directives/sebmGoogleMap.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ import {SebmGoogleMap} from 'angular2-google-maps/core';

### Events

| Event name | Arguments | Description |
|---------------|---------------------------------|----------------------------------------------------------|
| mapClick | [MapMouseEvent](#MapMouseEvent) | Gets emitted when the user clicks on the map |
| mapRightClick | [MapMouseEvent](#MapMouseEvent) | Get emitted when the user uses a right click on the map. |
| Event name | Arguments | Description |
|---------------|---------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|
| mapClick | [MapMouseEvent](#MapMouseEvent) | Gets emitted when the user clicks on the map |
| mapRightClick | [MapMouseEvent](#MapMouseEvent) | Gets emitted when the user uses a right click on the map. |
| mapDblClick | [MapMouseEvent](#MapMouseEvent) | Gets emitted when the user double-clicks on the map. Note that the `mapClick` event emitter will also fire, right before this one. |

### Event Interfaces

Expand Down
4 changes: 3 additions & 1 deletion src/directives/google-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class SebmGoogleMap {

@Output() mapClick: EventEmitter<MapMouseEvent> = new EventEmitter<MapMouseEvent>();
@Output() mapRightClick: EventEmitter<MapMouseEvent> = new EventEmitter<MapMouseEvent>();
@Output() mapDblClick: EventEmitter<MapMouseEvent> = new EventEmitter<MapMouseEvent>();

constructor(elem: ElementRef, _mapsWrapper: GoogleMapsAPIWrapper, renderer: Renderer) {
this._mapsWrapper = _mapsWrapper;
Expand Down Expand Up @@ -106,7 +107,8 @@ export class SebmGoogleMap {

const events: Event[] = [
{name: 'click', emitter: this.mapClick},
{name: 'rightclick', emitter: this.mapRightClick}
{name: 'rightclick', emitter: this.mapRightClick},
{name: 'dblclick', emitter: this.mapDblClick}
];

events.forEach((e: Event) => {
Expand Down

0 comments on commit 5f1ae68

Please sign in to comment.