Can someone explain if I am doing this correctly please?
I've added some vectors to my map, now wish to zoom and centre the map based on the extends of those vectors.
I'm using the following code:
var dataExtent = borders.getDataExtent();
which, when examined in FireBug does return the following values:
CLASS_NAME "OpenLayers.Bounds" bottom 4187116.4740651 centerLonLat null left -20037508.34 right 20037508.34 top 16852219.924326
And then I'm executing the following:
(if it helps to determine if I'm indeed returning the correct values from the getDataExtend() function, the region should be Russia)
Do I need to convert those figures from the getDataExtent() to a different format?
I've also tried the following, which again didn't do anything:
var dataExtent = borders.getDataExtent(); console.log(dataExtent); var tl = new OpenLayers.Geometry.Point(dataExtent.top, dataExtent.left); tl = tl.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913")); var br = new OpenLayers.Geometry.Point(dataExtent.bottom, dataExtent.right); br = br.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913")); var bounds = new OpenLayers.Bounds(tl.x, tl.y, br.x, br.y); map.zoomToExtent(bounds, true);