Oleksii Sytar
Oleksii Sytar

Reputation: 373

How to detect user interaction with google map Google map JavaScript API

I use fitBounds to update the area a map views, based on new GeoJson data. As soon as a user zooms or drags the map I want to disable the automatic "fitBounds" functionality.

Is there general way of detecting that user interaction caused a change in the viewport?

Thanks so much, for the answers.

Upvotes: 2

Views: 1296

Answers (1)

MrUpsidown
MrUpsidown

Reputation: 22488

The only event that will fire "as soon as a user zooms or drags the map" is the bounds_changed event.

You can try all events here: https://developers.google.com/maps/documentation/javascript/events

And you can refer to the documentation here: https://developers.google.com/maps/documentation/javascript/reference#Map

google.maps.event.addListener(map, 'bounds_changed', function() {

    // Do what you want here...
});

Upvotes: 3

Related Questions