2011-08-23 44 views
0

我只是試着從例如一些簡單的代碼:創建一個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其相當有趣,因爲前一段時間這個代碼工作

回答

3

嘗試添加OpenLayers.Map和OpenLayers.Layer.WMS的'new'關鍵字infront,看看它是否解決了這個問題。