Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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', '', {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

share|improve this question
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

Your Answer


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.