[OpenLayers-Users] getDataExtent delay problem
Greg Allensworth
gregor at greeninfo.org
Fri Jul 22 19:13:37 EDT 2011
> to load a base WMS layer and a KML file on it. The problem is that I
> want to display the map just arround the bounding box of the KML file
> but the method getDataExtent only returns something usefull when the
> method has returned. Some ideias ?
Yep. The Vector layer loading is asynchronous; at the time you add the
layer to the map, the data isn't ready. So, have the Layer catch the
"loadend" event, and have it respond to its freshly-loaded data *after*
it has loaded.
vectorlayer.events.register('loadend', vectorlayer, function () {
map.zoomToExtent( this.getDataExtent() );
});
--
Greg Allensworth, Web GIS Developer
BS A+ Network+ Security+ Linux+ Server+
GreenInfo Network - Information and Mapping in the Public Interest
564 Market Street, Suite 510 San Francisco CA 94104
PH: 415-979-0343 x302 FX: 415-979-0371 email: gregor at greeninfo.org
Web: www.GreenInfo.org www.MapsPortal.org
Subscribe to MapLines, our e-enewsletter, at www.GreenInfo.org
More information about the Users
mailing list