I’m building a website with ASP.NET MVC where one feature displays some points on a Google map, using the Google Maps Javascript API. As I have a lot of points, I don’t want to fetch them all; rather, I want to get only the ones that are in the current view area that the user is looking at on the map (the bounding box).
To do that, I will make an AJAX request to my C# code that returns all the points inside a certain bounding box. However, I need to somehow create an event handler that catches whenever the map is panned or zoomed by the user.
How can I detect when a map using the Google Maps Javascript API is panned or zoomed and fire an event handler?
UPDATE: I know that I have to implement an event listener. Can someone point me towards a list of events that I can use for the Map object? click is one of those events, but what are the ones that relate to zooming and panning?
It looks like you’re looking for the
idleevent:Example:
In addition, you can find the list of all events exported by the
google.maps.Mapobject from the API Reference: