<iframe src="https://developers.devsite.google/frame/maps/documentation/javascript/reference/3.63/event_f02165cc61efc71a4bd7a508d68121c16c0c701413cfde7a6167b17aabe146b5.frame" class="framebox inherit-locale redirect-iframe" allow="clipboard-write https://developers.devsite.google" allowfullscreen is-upgraded></iframe>

## [event](https://developers.google.com/maps/documentation/javascript/reference/3.63/event.md.txt#event)
class


`google.maps.event`
class

Namespace for all public event functions

Access by calling `const {event} = await google.maps.importLibrary("core")`.   
See [Libraries in the Maps JavaScript API](https://developers.google.com/maps/documentation/javascript/libraries.md.txt).

| ### Static Methods ||
|---|---|
| `addListener` | `addListener(instance, eventName, handler)` **Parameters:** - `instance`: `Object` - `eventName`: `string` - `handler`: `Function` **Return Value:** `MapsEventListener` Adds the given listener function to the given event name for the given object instance. Returns an identifier for this listener that can be used with removeListener(). |
| `addListenerOnce` | `addListenerOnce(instance, eventName, handler)` **Parameters:** - `instance`: `Object` - `eventName`: `string` - `handler`: `Function` **Return Value:** `MapsEventListener` Like addListener, but the handler removes itself after handling the first event. |
| `clearInstanceListeners` | `clearInstanceListeners(instance)` **Parameters:** - `instance`: `Object` **Return Value:** `void` Removes all listeners for all events for the given instance. |
| `clearListeners` | `clearListeners(instance, eventName)` **Parameters:** - `instance`: `Object` - `eventName`: `string` **Return Value:** `void` Removes all listeners for the given event for the given instance. |
| `hasListeners` | `hasListeners(instance, eventName)` **Parameters:** - `instance`: `Object` - `eventName`: `string` **Return Value:** `boolean` Returns if there are listeners for the given event on the given instance. Can be used to save the computation of expensive event details. |
| `removeListener` | `removeListener(listener)` **Parameters:** - `listener`: `MapsEventListener` **Return Value:** `void` Removes the given listener, which should have been returned by addListener above. Equivalent to calling `listener.remove()`. |
| `trigger` | `trigger(instance, eventName, eventArgs)` **Parameters:** - `instance`: `Object` - `eventName`: `string` - `eventArgs`: `...?` **Return Value:** `void` Triggers the given event. All arguments after eventName are passed as arguments to the listeners. |
| `[addDomListener](https://developers.google.com/maps/documentation/javascript/reference/3.63/event#event.addDomListener)` | > [!WARNING] > **[Deprecated:](https://developers.google.com/maps/deprecations.md.txt)** `google.maps.event.addDomListener()` is deprecated, use the standard [addEventListener()](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener) method instead. The feature will continue to work and there is no plan to decommission it. `addDomListener(instance, eventName, handler[, capture])` **Parameters:** - `instance`: `Object` - `eventName`: `string` - `handler`: `Function` - `capture`: `boolean optional` **Return Value:** `MapsEventListener` Cross browser event handler registration. This listener is removed by calling removeListener(handle) for the handle that is returned by this function. |
| `[addDomListenerOnce](https://developers.google.com/maps/documentation/javascript/reference/3.63/event#event.addDomListenerOnce)` | > [!WARNING] > **[Deprecated:](https://developers.google.com/maps/deprecations.md.txt)** `google.maps.event.addDomListenerOnce()` is deprecated, use the standard [addEventListener()](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener) method instead. The feature will continue to work and there is no plan to decommission it. `addDomListenerOnce(instance, eventName, handler[, capture])` **Parameters:** - `instance`: `Object` - `eventName`: `string` - `handler`: `Function` - `capture`: `boolean optional` **Return Value:** `MapsEventListener` Wrapper around addDomListener that removes the listener after the first event. |

## [MapsEventListener](https://developers.google.com/maps/documentation/javascript/reference/3.63/event.md.txt#MapsEventListener)
interface


`google.maps.MapsEventListener`
interface

An event listener, created by `google.maps.event.addListener()` and friends.

| ### Methods ||
|---|---|
| `remove` | `remove()` **Parameters:** None **Return Value:** `void` Removes the listener. Calling `listener.remove()` is equivalent to `google.maps.event.removeListener(listener)`. |

## [MVCObject](https://developers.google.com/maps/documentation/javascript/reference/3.63/event.md.txt#MVCObject)
class


`google.maps.MVCObject`
class

Base class implementing KVO.   

The `MVCObject` constructor is guaranteed to be an empty function, and so you may inherit from `MVCObject` by writing `MySubclass.prototype = new google.maps.MVCObject();`. Unless otherwise noted, this is not true of other classes in the API, and inheriting from other classes in the API is not supported.

Access by calling `const {MVCObject} = await google.maps.importLibrary("core")`.   
See [Libraries in the Maps JavaScript API](https://developers.google.com/maps/documentation/javascript/libraries.md.txt).

| ### Constructor ||
|---|---|
| `MVCObject` | `MVCObject()` **Parameters:** None Creates an `MVCObject`. |

| ### Methods ||
|---|---|
| `addListener` | `addListener(eventName, handler)` **Parameters:** - `eventName`: `string` - `handler`: `Function` **Return Value:** `MapsEventListener` Adds the given listener function to the given event name. Returns an identifier for this listener that can be used with `google.maps.event.removeListener`. |
| `bindTo` | `bindTo(key, target[, targetKey, noNotify])` **Parameters:** - `key`: `string` - `target`: `MVCObject` - `targetKey`: `string optional` - `noNotify`: `boolean optional` **Return Value:** None Binds a View to a Model. |
| `get` | `get(key)` **Parameters:** - `key`: `string` **Return Value:** `?` Gets a value. |
| `notify` | `notify(key)` **Parameters:** - `key`: `string` **Return Value:** None Notify all observers of a change on this property. This notifies both objects that are bound to the object's property as well as the object that it is bound to. |
| `set` | `set(key, value)` **Parameters:** - `key`: `string` - `value`: `*` **Return Value:** None Sets a value. |
| `setValues` | `setValues([values])` **Parameters:** - `values`: `Object optional` **Return Value:** None Sets a collection of key-value pairs. |
| `unbind` | `unbind(key)` **Parameters:** - `key`: `string` **Return Value:** None Removes a binding. Unbinding will set the unbound property to the current value. The object will not be notified, as the value has not changed. |
| `unbindAll` | `unbindAll()` **Parameters:** None **Return Value:** None Removes all bindings. |

## [MVCArray](https://developers.google.com/maps/documentation/javascript/reference/3.63/event.md.txt#MVCArray)
class


`google.maps.MVCArray<T>`
class

This class extends
`MVCObject`.

Access by calling `const {MVCArray} = await google.maps.importLibrary("core")`.   
See [Libraries in the Maps JavaScript API](https://developers.google.com/maps/documentation/javascript/libraries.md.txt).

| ### Constructor ||
|---|---|
| `MVCArray` | `MVCArray([array])` **Parameters:** - `array`: `Array<T> optional` A mutable MVC Array. |

| ### Methods ||
|---|---|
| `clear` | `clear()` **Parameters:** None **Return Value:** None Removes all elements from the array. |
| `forEach` | `forEach(callback)` **Parameters:** - `callback`: `function(T, number): void` **Return Value:** None Iterate over each element, calling the provided callback. The callback is called for each element like: callback(element, index). |
| `getArray` | `getArray()` **Parameters:** None **Return Value:** `Array<T>` Returns a reference to the underlying Array. Warning: if the Array is mutated, no events will be fired by this object. |
| `getAt` | `getAt(i)` **Parameters:** - `i`: `number` **Return Value:** `T` Returns the element at the specified index. |
| `getLength` | `getLength()` **Parameters:** None **Return Value:** `number` Returns the number of elements in this array. |
| `insertAt` | `insertAt(i, elem)` **Parameters:** - `i`: `number` - `elem`: `T` **Return Value:** None Inserts an element at the specified index. |
| `pop` | `pop()` **Parameters:** None **Return Value:** `T` Removes the last element of the array and returns that element. |
| `push` | `push(elem)` **Parameters:** - `elem`: `T` **Return Value:** `number` Adds one element to the end of the array and returns the new length of the array. |
| `removeAt` | `removeAt(i)` **Parameters:** - `i`: `number` **Return Value:** `T` Removes an element from the specified index. |
| `setAt` | `setAt(i, elem)` **Parameters:** - `i`: `number` - `elem`: `T` **Return Value:** None Sets an element at the specified index. |

| ### Events ||
|---|---|
| `insert_at` | `function(index)` **Arguments:** - `index`: `number` This event is fired when `insertAt()` is called. The event passes the index that was passed to `insertAt()`. |
| `remove_at` | `function(index, removed)` **Arguments:** - `index`: `number` - `removed`: `T` The element removed from the array at `index`. This event is fired when `removeAt()` is called. The event passes the index that was passed to `removeAt()` and the element that was removed from the array. |
| `set_at` | `function(index, previous)` **Arguments:** - `index`: `number` - `previous`: `T` The element that was previously in the array at `index`. This event is fired when `setAt()` is called. The event passes the index that was passed to `setAt()` and the element that was previously in the array at that index. |

## [ErrorEvent](https://developers.google.com/maps/documentation/javascript/reference/3.63/event.md.txt#ErrorEvent)
interface


`google.maps.ErrorEvent`
interface

An event with an associated Error.

| ### Properties ||
|---|---|
| `error` | **Type:** `Error` The Error related to the event. |