The following code works for me too:
.
.
var boundsChangedListener;
.
.
// using bounds_changed to advise can get_bounds
boundsChangedListener = google.maps.event.addListener(map,
'bounds_changed', function() {
if (window.console) { console.log("bounds_changed"); }
download(); // <- function where I need map bounds
});
.
.
function download() {
// Remove the listener after map ready.
google.maps.event.removeListener(boundsChangedListener);
//boundsChangedListener = null;
.
// then do map stuff...
.
If I actually set the boundsChangedListener to null, the google code
fails at: main.js line 23 with an "a is null" error. Unsure why..maybe
there is some Google code that is still referring to my listener..