我有一个非常基本的地图设置,带有 openlayers,只有 3 个控件,内置在 MVC 项目中。但是,出于某些原因,导航控件和 panzoombar 不显示(尽管 mouseposition 之一显示)。我在地图加载时看到它们片刻,但随后它们消失了。下面是我用来实现这一点的代码。谁能告诉我我做错了什么?
function initNormMap() {
var map;
OpenLayers.DOTS_PER_INCH = 72;
map = new OpenLayers.Map('divmap', {
controls: [
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.PanZoomBar(),
new OpenLayers.Control.MousePosition()
], units: 'm',
projection: new OpenLayers.Projection("EPSG:900913"),
displayProjection: new OpenLayers.Projection("EPSG:4326")
});
//http://trac.osgeo.org/openlayers/wiki/AvailableWMSServices
var ol_wms = new OpenLayers.Layer.WMS("OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0",
{ layers: 'basic' });
var osm_wms = new OpenLayers.Layer.OSM();
map.addLayers([osm_wms]);
var fromProjection = new OpenLayers.Projection("EPSG:4326"); // Transform from WGS 1984
var toProjection = new OpenLayers.Projection("EPSG:900913"); // to Spherical Mercator Projection
var position = new OpenLayers.LonLat(-98, 39).transform(fromProjection, toProjection);
var zoom = 4;
map.setCenter(position, zoom);
}