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},

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

1 Answer 1


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'}

  • problem is not here. I've just used jquery instead of usual javascript. But if I write what you said, the error will remain Commented Aug 24, 2011 at 4:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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