[Users] Re-center map via an "outside"-link

Marc Jansen jansen at terrestris.de
Wed Aug 18 08:23:29 CEST 2010


Hi Stefan,


On 17.08.2010 17:04, Stefan Schwarzer wrote:
> as the map only exists as an Javascript variable, right?

yes, with document.getElementById you get the reference to a DOM-object. 
To get the OpenLayers-Map-object, you could declare map as a global 
variable:

<script>
var map;
// initialize OpenLayers-Map
function init() {
     // notice the missing var
     map = new OpenLayers.Map(...)
}
</script>

If you already can access mapPanel, a reference to the 
OpenLayers-Map-object is stored as mapPanel.map.

To check if your variables are global, simply type the variable name in 
Firebugs console window. If you get a clickable object back, you should 
be fine.

Hope this helps,
Marc



More information about the Users mailing list