[OpenLayers-Users] Callback for after a layer has loaded

Christopher Schmidt crschmidt at metacarta.com
Mon Apr 6 12:31:09 EDT 2009


On Mon, Apr 06, 2009 at 11:46:13AM -0400, Nicholas Bergson-Shilcock wrote:
> I have a GML layer that pulls in a KML file. After the layer has loaded, I'd
> like to run something like:
> 
> map.zoomToExtent(layer.getDataExtent());
> 
> Just running this right after I create and add the layer doesn't work because
> it runs before the layer has fully loaded. Using setTimeout() is hacky and
> unreliable. Is there a callback for doing this?

layer.events.register("loadend", layer, function() {
this.map.zoomToExtent(this.getDataExtent()) } );

> Thanks,
>   -Nick
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users

-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list