Hi List,
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 ?
Browser: Google Chrome,
OpenLayers: From SVN on 23-07-2011
Here is the code I am using:
function init() {
document.namespaces;
wms = new OpenLayers.Layer.WMS(
"OpenLayers WMS",
"http://vmap0.tiles.osgeo.org/wms/vmap0",
{ layers: 'basic'},
{ 'maxExtent': new OpenLayers.Bounds(-180,-90,180,90), 'maxResolution': "auto" }
);
var http = new OpenLayers.Protocol.HTTP({
url: "file.kml",
format: new OpenLayers.Format.KML({ extractStyles: false })
});
var sta = [new OpenLayers.Strategy.Fixed({ preload: true } )];
station = new OpenLayers.Layer.Vector("Stations", { strategies: sta, protocol:
http })
map = new OpenLayers.Map('map');
map.addLayers([wms, station]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.zoomToMaxExtent();
map.zoomToExtent(station.getDataExtent());
}
and the error i am getting on the console:
OpenLayers.js:526Uncaught TypeError: Cannot call method 'getCenterLonLat' of
null
cheers,
Marcelo_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users