创建一个OpenLayers地图 - 我做错了什么?

时间:2011-08-23 18:04:23

标签: openlayers

我刚从示例中尝试了一些简单的代码:

$(document).ready(function() {

   var map = OpenLayers.Map('map-content', {});
   var wms_serever_map = OpenLayers.Layer.WMS('Base l', 'http://vmap0.tiles.osgeo.org/wms/vmap0', {layer:basic},
       {});
   map.addLayer(wms_serever_map);
   if(!map.getCenter()){
      map.zoomToMaxExtent();
   }
});

但chrome和firefox没有向我显示地图并抛出错误:uncaught type error: Cannot call method 'apply' of undefined Openlayers.js:127它相当有趣,因为前段时间此代码有效

1 个答案:

答案 0 :(得分:3)

尝试在OpenLayers.Map和OpenLayers.Layer.WMS的前面添加'new'关键字,看看它是否解决了问题。

相关问题