[OpenLayers-Users] ZoomToExtent of KML File
Christopher Schmidt
crschmidt at metacarta.com
Thu Dec 11 07:48:45 EST 2008
On Thu, Dec 11, 2008 at 10:27:07AM +0000, Peter Robins wrote:
> On Mon, Sep 15, 2008, Christopher Schmidt-2 wrote:
> > I assume you create your layer, and then immediately call getDataExtent
> > on it, before the KML has loaded. Listen to the layer's loadend event,
> > and then call getDataExtent when it has loaded.
>
> I've been experimenting with this, and it looks to me like 'loadend' won't
> fire until the map has been centered. If I adapt one of the OL example files
> to look something like:
That's correct. Specifically, this is because we can't be sure that the
layer will need to be loaded until moveTo is called.
You can call the non-API "loadGML()" function to force a load of the
layer instead of letting it wait.
http://dev.openlayers.org/docs/files/OpenLayers/Layer/GML-js.html#OpenLayers.Layer.GML.loadGML
Regards,
--
Christopher Schmidt
MetaCarta
More information about the Users
mailing list