<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">Hi List,&nbsp;</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">I am having a problem that i just cannot find the solution. I want just 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 ?</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">Browser:
 Google Chrome,&nbsp;</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">OpenLayers: From SVN on 23-07-2011</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">&nbsp;Here is the code I am using:</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">function init() {<br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">&nbsp; &nbsp; &nbsp; &nbsp; document.namespaces;</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>wms = new OpenLayers.Layer.WMS(</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span
 class="Apple-tab-span" style="white-space:pre">                </span>"OpenLayers WMS",</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">                </span>"http://vmap0.tiles.osgeo.org/wms/vmap0",</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">                </span>{ layers: 'basic'},</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">                </span>{ 'maxExtent': new OpenLayers.Bounds(-180,-90,180,90), 'maxResolution': "auto" }</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>);</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times,
 serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>var http = new OpenLayers.Protocol.HTTP({</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;url: "file.kml",</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; format: new OpenLayers.Format.KML({ extractStyles: false })</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;});</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span"
 style="white-space:pre">        </span>var sta = [new OpenLayers.Strategy.Fixed({ preload: true } )];</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>station = new OpenLayers.Layer.Vector("Stations", { strategies: sta, protocol: http })</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>map = new OpenLayers.Map('map');</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>map.addLayers([wms, station]);</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span"
 style="white-space:pre">        </span>map.addControl(new OpenLayers.Control.LayerSwitcher());</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">        </span>map.zoomToMaxExtent();</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space: pre; ">        </span>map.zoomToExtent(station.getDataExtent());</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">}</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif">and the error i am getting on the console:</font></div><div><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div><font
 class="Apple-style-span" face="'times new roman', 'new york', times, serif"><div>OpenLayers.js:526Uncaught TypeError: Cannot call method 'getCenterLonLat' of null</div><div><br></div><div>cheers,&nbsp;</div><div><br></div><div>Marcelo</div></font></div></div></div></body></html>