开发者

Creating an OpenLayers map - what am I doing wrong?

开发者 https://www.devze.com 2023-03-29 23:11 出处:网络
I\'ve just tried some simple code from example: $(document).ready(function() { var map = OpenLayers.Map(\'map-content\', {});

I've just tried some simple code from example:

$(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();开发者_JAVA技巧
   }
});

but chrome and firefox don't show me the map and throws error: uncaught type error: Cannot call method 'apply' of undefined Openlayers.js:127 Its rather interesting, because some time ago this code worked


Try adding 'new' keyword infront of OpenLayers.Map and OpenLayers.Layer.WMS and see if it solves the problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消