Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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();
   }
});

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

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

You trying to use OpenLayers before the document is loaded. $(document).ready(function() {}) is too early. Use<body onload='init()'>.

UPD.: I've found some errors in your script:

1) You should use 'new' keyword while creating new object (var map = new OpenLayers.Map('map-content', {}), var wms_serever_map = new OpenLayers.Layer.WMS());

2) Modify {layer:basic} to {layers:'basic'}

share|improve this answer
    
problem is not here. I've just used jquery instead of usual javascript. But if I write what you said, the error will remain –  HacketyHack Aug 24 '11 at 4:15
    
thank you guy, Im so blind)) u are my savior) –  HacketyHack Aug 24 '11 at 10:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.