我正在使用图像来显示OpenLayers的地图.我的JS代码如下所示:
map = new OpenLayers.Map('map'); var options = {numZoomLevels: 7,isBaseLayer: true,}; var globe = new OpenLayers.Layer.Image( 'Globe ESA','http://upload.wikimedia.org/wikipedia/commons/0/07/World_map_blank_black_lines_4500px.gif',new OpenLayers.Bounds(-180,-90,180,90),new OpenLayers.Size(4500,2234),options); map.addLayers(globe); markers = new OpenLayers.Layer.Markers("markers"); map.addLayer(markers); map.addControl(new OpenLayers.Control.LayerSwitcher()); map.zoomToMaxExtent(); map.addControl(new OpenLayers.Control.MousePosition());
我的CSS是:
#map { width: 640px; height: 480px; border: 1px solid black; }
解决方法
您需要设置完全缩小时应显示的图像大小.
var globe = new OpenLayers.Layer.Image( 'Globe ESA','http://upload.wikimedia.org/wikipedia/commonS/0/07/World_map_blank_black_lines_4500px.gif',new OpenLayers.Size(1125,558),options);
我将尺寸改为原尺寸的四分之一.如果你想让它更加缩小,你可以把它做得更小.