I need to set pointers to a map a) when the map is initialized and b) when the map is moved. To get the markers, I make a call to my API like this:
var bounds = map.getBounds();
and then take the bounds to get the correct markers.
The problem is, that when I put that API-call inside
google.maps.event.addListener(map, "bounds_changed", function(){})
it gets called way too often while dragging the map, but if I use
google.maps.event.addListener(map, "idle", function(){})
map.getBounds is null upon initializing.
edit: More code
$(document).ready(function(){ initialize(); });
function initialize() { mapOptions = {
zoom : 13,
minZoom : minimumZoomLevel,
scrollwheel : false,
panControl : false }; map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
google.maps.event.addListener(map, "idle", function() {
myfunction(); }); });
function myfunction(){ var bounds = map.getBounds(); }
bounds is null!