Hi all, I want to have a button. And after you press the butten the map should move to the new Center. But I geta error in Firebug: "map is undefined", after I pressed the button. I tried different strategies but nothing worked. When I do the same thing with a variable like var a=3 it works.... please help me.
The Code is like this: <html> <head> <title>Test</title> <style type="text/css"> #map{ width:100%; height:600px; border:1px solid; } </style> <script src="http://openlayers.org/api/OpenLayers.js"></script> <script defer="defer" type="text/javascript"> function load(mode){ if (mode=="start"){ ... . . var map = new OpenLayers.Map('map',options); var wms = new OpenLayers.Layer.WMS(... . . . map.addLayer(wms); map.zoomToMaxExtent(); //map.setCenter(new OpenLayers.LonLat(145,-40),8);//here would be know error! } else if (mode=="newPos"){ map.setCenter(new OpenLayers.LonLat(145,-40),8);//-->error: map is undefined! } } </script> </head> <body onload="load('start')"> <table width="100%" border="0"> <tr> <td colspan="2" height="100">TITEL</td> </tr> <tr> <td width="20%"> <input type="button" value="Go" onClick="load('newPos')"> </td> <td><div id="map"></div></td> </tr> </table> </body> </html> -- View this message in context: http://n2.nabble.com/problem-with-map-setCenter-tp4779851p4779851.html Sent from the OpenLayers Users mailing list archive at Nabble.com. _______________________________________________ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users