我将 OpenLayers 用于地图,当我加载它时,无论我将 setCenter 更改为什么,它总是以 0,0 为中心。
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());
}
我不确定它为什么这样做。谁能发现我遗漏的东西?