[OpenLayers-Users] OpenLayers.Map + DOM Object - How to get Map Object from DOM Element

Andreas Hocevar ahocevar at opengeo.org
Tue Jul 31 06:27:46 PDT 2012


If you are referring to an OpenLayers.Map instance with "map object",
you won't find it in the DOM. You need to assign it a global variable
if you want that, e.g.

window.map = new OpenLayers.Map('worldmap');

Andreas.

On Tue, Jul 31, 2012 at 3:15 PM, Jürgen Dankoweit
<Juergen.Dankoweit at t-online.de> wrote:
> Hello to the list,
>
> the following situation: I have a OpenLayers.Map object which is
> "connected" to the DOM element "div" like in the code snippet below:
>
> <div id='worldmap'></div>
>
> map = new OpenLayers.Map(document.getElementById('worldmap'), ... );
>
> An examination with Firebug shows me a lot of OpenLayer objects but no
> map object. I think that the object "map" should be a child of the DOM
> element "div". But how to find out the map object?
>
> The background is that I don't want to declare the map object as a
> global variable - old school :)
>
> Many thanks for the answers.
>
> Best regards
>
> Jürgen
>
> --
> Meine stets unfertige Homepage: www.dankoweit.de
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users



-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.


More information about the Users mailing list