Register event “loadend” on layer

Register event “loadend” on layer

I'm trying to register a listener event on "loadend" for my google maps layer on OpenLayers. But for some reason it's not firing. There must be something small i'm overlooking. What is wrong with my code?


      OpenLayers Google (v3) Layer Example       

OftenThe Google layers work differently from other layer types as they are loaded through the Google API rather than OpenLayers code.

The loadend issue is logged as a bug in the OpenLayers bug tracker, but its status has since been changed to a (non-completed) feature.

Instead you could try capturing the tilesloaded event from the Google API, and put your custom function when this event is called.

If you have a Google map layer, then you also have the Google API loaded, and access to the Google map object so you should be able to use something like:

GEvent.addListener(gmaplayer.mapObject, "tilesloaded", function() { console.log("Tiles loaded"); });

it also works without needing GEvent

google.maps.event.addListenerOnce(openlayersMap.baseLayer.mapObject, 'tilesloaded', function(){ alert("Map Loaded!"); } );