[OpenLayers-Users] Callback for after a layer has loaded
Nicholas Bergson-Shilcock
nicholasbs at openplans.org
Mon Apr 6 12:52:00 EDT 2009
Excerpts from Christopher Schmidt's message of Mon Apr 06 12:31:09 -0400 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, guys. Worked like a charm!
-Nick
> > Thanks,
> > -Nick
> > _______________________________________________
> > Users mailing list
> > Users at openlayers.org
> > http://openlayers.org/mailman/listinfo/users
>
More information about the Users
mailing list