[OpenLayers-Users] Zooming to an extend via link outside map
viewport
Heidt, Christopher M.
CHRISTOPHER.M.HEIDT at saic.com
Mon Mar 23 08:48:16 EDT 2009
Define map globally outside init, and set its value within.
Var map;
Function init()
{
map = new OpenLayers.......bla bla bla
}
Now you can use map anywhere.
As you get more advanced with js you can learn about closures
and design getter functions, but this should work for now.
-----Original Message-----
From: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] On Behalf Of Max Stephan
Sent: Sunday, March 22, 2009 9:58 AM
To: users at openlayers.org
Subject: [OpenLayers-Users] Zooming to an extend via link outside map viewport
Hey everybody,
I want to place a link outside the map which zooms to a specified extent (something like "javascript: map.zoomToExtent(new OpenLayers.Bounds(1,2,3,4))" as a link in the body). But it´s logically not that easy because I have to get access to the map-variable that is unfortunately in the init-function.
So I tried several things. For example I defined a function named "zoom"
which contains "map.zoomToExtent(1,2,3,4);" in it´s body but that´s not working at all. The only way that worked was to empty the map-div-container via "document.getElementById('map').innerHTML="";" and to run the function init with the new bounds as a parameter afterwards.
Does anyone know a more elegant way than reloading the complete init-function?
Thx in advance
Max Stephan
--
View this message in context: http://n2.nabble.com/Zooming-to-an-extend-via-link-outside-map-viewport-tp2517040p2517040.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users
More information about the Users
mailing list