[OpenLayers-Users] Openlayers.map is not a construcor

Moser Adrian Adrian.Moser at bs.ch
Mon Oct 30 09:00:24 EST 2006


I tried the single file version of Openlayers and the error I got before didn't occour. Instead I got the follwing error: maxExtent has no properties. I tried to set the maxExtent but it didn't work:

map = new OpenLayers.Map('map', { projection: 21781, maxExtent: new OpenLayers.Bounds(606800,262500,619100,272400) });

I still can't understand why it doesn't work with the other version. I load the OpenLayers.js file when the website is loaded. On this site I got a link which onclick loads the map container (div) asynchronously. After that I try initialize the map. The OpenLayers.js should be loaded then.

Regards,
Adrian Moser



-----Ursprüngliche Nachricht-----
Von: Christopher Schmidt [mailto:crschmidt at metacarta.com] 
Gesendet: Montag, 30. Oktober 2006 13:39
An: Moser Adrian
Cc: users at openlayers.org
Betreff: Re: [OpenLayers-Users] Openlayers.map is not a construcor


On Mon, Oct 30, 2006 at 12:15:44PM +0100, Moser Adrian wrote:
> Hi,
>
> I'm trying to use Openlayers for an application I'm developping. When 
> I try to initialize the map I get the following error message: 
> Openlayers.map is not a construcor I can't figuere out why this error 
> occurs, since it works on a similar example. The only reason that 
> could be is that I'm loading the map container (div) with ajax. So 
> it's not on the website when i first load it but it is there when I 
> try to initialize the map.

I think that the latter part of your statement is probably not true. That error message indicates that you are attempting to create the OpenLayers javascript before the OpenLayers Map code is added to the document.

Note that the default in OpenLayers is to load the Javascript files asynchronously. If you're not building a single file, and you're adding the javascript asyncrhonously, there is no way to ensure that you are loading the Map object after the Map file is loaded, since the onload for the main OpenLayers.js will fire before the rest of the Javascript is loaded. To test if this is the case, you can use a single file version of OpenLayers. One is hosted on OpenLayers.org:

  http://openlayers.org/api/2/OpenLayers.js

or, to use the latest RC:
  http://openlayers.org/api/2.2-rc2/OpenLayers.js

If this doesn't work, example HTML which is causing the error would be helpful in further debugging.

Regards,
--
Christopher Schmidt
MetaCarta



More information about the Users mailing list