How do we know programatically what portion of the map is visible at any given time? For example:
When I load a map I set the center so I know which point I am on and will know what properties to load. However, when a user drags the map along or zooms into a smaller section of the map. How do I know which properties to plot at that point? How will know what exactly the user is looking at?
Thanks.
You can use the method
bounds = map.getBounds()(assuming thatmapis the variable where you store the Google map) and this will return the bounds of the current viewport.Then, with
bounds.getSouthWest()andbounds.getNorthEast()you will obtain the Latitude and Longitude of both corners so you have all you need to know what the user is seeing.https://developers.google.com/maps/documentation/javascript/reference#Map