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

Christopher Schmidt crschmidt at metacarta.com
Mon Oct 30 07:39:20 EST 2006


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