Introducing Places UI Kit: A ready-to-use, low-cost component library that lets you bring the familiar Google Maps UI for Places to any map of your choice. Try it out, andshare your input to help shape the future of GMP!

Event system

eventclass

google.maps.eventclass

Namespace for all public event functions

Access by callingconst {event} = await google.maps.importLibrary("core").
SeeLibraries in the Maps JavaScript API.

Static Methods

addListener
addListener(instance, eventName, handler)
Parameters: 
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: 
Return Value: MapsEventListener
Like addListener, but the handler removes itself after handling the first event.
clearInstanceListeners
clearInstanceListeners(instance)
Parameters: 
Return Value: void
Removes all listeners for all events for the given instance.
clearListeners
clearListeners(instance, eventName)
Parameters: 
  • instanceObject
  • eventNamestring
Return Value: void
Removes all listeners for the given event for the given instance.
hasListeners
hasListeners(instance, eventName)
Parameters: 
  • instanceObject
  • eventNamestring
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: 
Return Value: void
Removes the given listener, which should have been returned by addListener above. Equivalent to callinglistener.remove().
trigger
trigger(instance, eventName, eventArgs)
Parameters: 
  • instanceObject
  • eventNamestring
  • eventArgs...?
Return Value: void
Triggers the given event. All arguments after eventName are passed as arguments to the listeners.
addDomListener

Deprecated:google.maps.event.addDomListener() is deprecated, use the standardaddEventListener() method instead. The feature will continue to work and there is no plan to decommission it.

addDomListener(instance, eventName, handler[, capture])
Parameters: 
  • instanceObject
  • eventNamestring
  • handlerFunction
  • capturebooleanoptional
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

Deprecated:google.maps.event.addDomListenerOnce() is deprecated, use the standardaddEventListener() method instead. The feature will continue to work and there is no plan to decommission it.

addDomListenerOnce(instance, eventName, handler[, capture])
Parameters: 
  • instanceObject
  • eventNamestring
  • handlerFunction
  • capturebooleanoptional
Return Value: MapsEventListener
Wrapper around addDomListener that removes the listener after the first event.

MapsEventListenerinterface

google.maps.MapsEventListenerinterface

An event listener, created bygoogle.maps.event.addListener() and friends.

Methods

remove
remove()
Parameters:  None
Return Value: void
Removes the listener.

Callinglistener.remove() is equivalent togoogle.maps.event.removeListener(listener).

MVCObjectclass

google.maps.MVCObjectclass

Base class implementing KVO.

TheMVCObject constructor is guaranteed to be an empty function, and so you may inherit fromMVCObject by writingMySubclass.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 callingconst {MVCObject} = await google.maps.importLibrary("core").
SeeLibraries in the Maps JavaScript API.

Constructor

MVCObject
MVCObject()
Parameters:  None
Creates anMVCObject.

Methods

addListener
addListener(eventName, handler)
Parameters: 
Return Value: MapsEventListener
Adds the given listener function to the given event name. Returns an identifier for this listener that can be used withgoogle.maps.event.removeListener.
bindTo
bindTo(key, target[, targetKey, noNotify])
Parameters: 
  • keystring
  • targetMVCObject
  • targetKeystringoptional
  • noNotifybooleanoptional
Return Value:  None
Binds a View to a Model.
get
get(key)
Parameters: 
  • keystring
Return Value: ?
Gets a value.
notify
notify(key)
Parameters: 
  • keystring
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: 
  • keystring
  • value*
Return Value:  None
Sets a value.
setValues
setValues([values])
Parameters: 
Return Value:  None
Sets a collection of key-value pairs.
unbind
unbind(key)
Parameters: 
  • keystring
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.

MVCArrayclass

google.maps.MVCArray<T>class

This class extendsMVCObject.

Access by callingconst {MVCArray} = await google.maps.importLibrary("core").
SeeLibraries in the Maps JavaScript API.

Constructor

MVCArray
MVCArray([array])
Parameters: 
A mutable MVC Array.

Methods

clear
clear()
Parameters:  None
Return Value:  None
Removes all elements from the array.
forEach
forEach(callback)
Parameters: 
  • callbackfunction(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: 
  • inumber
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: 
  • inumber
  • elemT
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: 
  • elemT
Return Value: number
Adds one element to the end of the array and returns the new length of the array.
removeAt
removeAt(i)
Parameters: 
  • inumber
Return Value: T
Removes an element from the specified index.
setAt
setAt(i, elem)
Parameters: 
  • inumber
  • elemT
Return Value:  None
Sets an element at the specified index.
Inherited:addListener,bindTo,get,notify,set,setValues,unbind,unbindAll

Events

insert_at
function(index)
Arguments: 
  • indexnumber
This event is fired wheninsertAt() is called. The event passes the index that was passed toinsertAt().
remove_at
function(index, removed)
Arguments: 
  • indexnumber
  • removedT The element removed from the array atindex.
This event is fired whenremoveAt() is called. The event passes the index that was passed toremoveAt() and the element that was removed from the array.
set_at
function(index, previous)
Arguments: 
  • indexnumber
  • previousT The element that was previously in the array atindex.
This event is fired whensetAt() is called. The event passes the index that was passed tosetAt() and the element that was previously in the array at that index.

ErrorEventinterface

google.maps.ErrorEventinterface

An event with an associated Error.

Properties

error
Type: Error
The Error related to the event.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-07-18 UTC.