This example demonstrates the use of event listeners. It
- listens for the
click
event on a marker to zoom the map when the marker is clicked. - listens for the
center_changed
event to pan the map back to the marker after 3 seconds.
Read the documentation.
Try Sample
Clone Sample
Git and Node.js are required to run this sample locally. Follow these instructions to install Node.js and NPM. The following commands clone, install dependencies and start the sample application.
git clone -b sample-event-simple https://github.com/googlemaps/js-samples.git
cd js-samples
npm i
npm start
Other samples can be tried by switching to any branch beginning with sample-SAMPLE_NAME
.
git checkout sample-SAMPLE_NAME
npm i
npm start