I am using OpenLayers for a map and when I load it, it always centres on 0,0 no matter what I change the setCenter to.
var map, baseLayer;
var options = {numZoomLevels: 7, isBaseLayer: true,};
function collegeLaneInit()
{
map = new OpenLayers.Map('map');
baseLayer = new OpenLayers.Layer.Image("College Lane","college-lane-large.png",
new OpenLayers.Bounds(-1000, -1000, 1000, 1000),
new OpenLayers.Size(2000,2000), options);
map.addLayer(baseLayer);
var center = new OpenLayers.LonLat(500,500);
map.setCenter(center ,1);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.zoomToMaxExtent();
map.addControl(new OpenLayers.Control.MousePosition());
}
I'm not really sure why it's doing this. Can anyone spot something that I'm missing?
map.zoomToMaxExtent();
Is your offending line, comment it out, if you zoom out far enough you will always end up in the centre