<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;"><DIV><BR>Dear Andreas,</DIV>
<DIV>&nbsp;</DIV>
<DIV>I have removed "var" from:</DIV>
<DIV>&nbsp;</DIV>
<DIV>&gt; var map = new OpenLayers.Map('map', options );<BR></DIV>
<DIV>it stilt&nbsp;&nbsp;doesn't work, firebug give 2 error messages:</DIV>
<DIV>&nbsp;</DIV>
<DIV>1) header is null -</DIV>
<DIV>header.style.width=(getWindowWidth()-20) + "px";\r\n</DIV>
<DIV>&nbsp;</DIV>
<DIV>(I think this error is not critical, it is from resize() function of TMS)</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>2) map is undefined in go() function</DIV>
<DIV>&nbsp;</DIV>
<DIV>map.setCenter(new OpenLayers.Lonlat(longitude, latitude),5)\r\n</DIV>
<DIV>&nbsp;</DIV>
<DIV>( I have fixed zoom value to 5)</DIV>
<DIV>&nbsp;</DIV>
<DIV>could you please give me further suggestion,</DIV>
<DIV>&nbsp;</DIV>
<DIV>kind regards,</DIV>
<DIV>&nbsp;</DIV>
<DIV>surya</DIV>
<DIV><BR>--- On <B>Tue, 9/8/09, Andreas Hocevar <I>&lt;ahocevar@opengeo.org&gt;</I></B> wrote:<BR></DIV>
<BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: rgb(16,16,255) 2px solid"><BR>From: Andreas Hocevar &lt;ahocevar@opengeo.org&gt;<BR>Subject: Re: [OpenLayers-Users] Ovewriting previous map<BR>To: "Surya Tarigan" &lt;surya.tarigan@yahoo.com&gt;<BR>Cc: users@openlayers.org<BR>Date: Tuesday, September 8, 2009, 10:00 AM<BR><BR>
<DIV class=plainMail>Hi,<BR><BR>see my comments inline, and use a javascript debugger like Firebug for<BR>Firefox to see what is going on.<BR><BR>Surya Tarigan wrote:<BR>&gt;<BR>&gt; Formerly,&nbsp; I call go() function (see snippet below) which handles the<BR>&gt; map.setCenter, it seems that this function doesn't react to the change<BR>&gt; of lonlat value in drop down list. I have two layers, my base layer is<BR>&gt; a big quickbird image tiled into 6 zoom levels and other layer is WMS<BR>&gt; layer with hundreds of river names. Drop down list should help user to<BR>&gt; pin point selected river in the quickbird image.<BR>&gt;&nbsp; <BR>&gt; When I call init() function it doeas react, but create a series of map<BR>&gt; which doesn't overwrite each other. I certainly do not want to create<BR>&gt; new map every time I change lonlat value, it will double/tripple<BR>&gt; processing&nbsp; time.<BR>&gt;&nbsp; <BR>&gt;&nbsp; <BR>&gt;&nbsp; <BR>&gt;&nbsp;
 <BR>&gt; -----------------<BR>&gt;&nbsp; <BR>&gt; function init(){<BR>&gt;&nbsp; <BR>&gt; var options = {<BR>&gt; theme: null,<BR>&gt; maxExtent: new OpenLayers.Bounds(225389.527874, 9627709.46055,<BR>&gt; 244613.714826, 9639853.34683 ),<BR>&gt; maxResolution: 103.338482,<BR>&gt; projection: 'EPSG:4326',<BR>&gt; units: 'm',<BR>&gt; controls: [<BR>&gt; new OpenLayers.Control.LayerSwitcher(),<BR>&gt; new OpenLayers.Control.MousePosition(),<BR>&gt; new OpenLayers.Control.PanZoom(),<BR>&gt; new OpenLayers.Control.ScaleLine()<BR>&gt; ]<BR>&gt; }; //option<BR>&gt;&nbsp; <BR>&gt; var mapBounds = new OpenLayers.Bounds( 225389.527874, 9627709.46055,<BR>&gt; 244613.714826, 9639853.34683 );<BR>&gt;&nbsp; <BR>&gt; var map = new OpenLayers.Map('map', options );<BR>&gt;<BR><BR>map is local to the init function here, so it won't be available in the<BR>go() function. Remove "var" to make it global.<BR><BR>&gt;&nbsp; <BR>&gt; var layer = new OpenLayers.Layer.TMS( "TMS
 Layer","",<BR>&gt; { url: '', serviceVersion: '.', layername: '.', alpha: true,<BR>&gt; type: 'png', getURL: overlay_getTileURL });<BR>&gt;&nbsp; <BR>&gt; var river = new OpenLayers.Layer.WMS(<BR>&gt; "topp:sungai_nr - river", "<A href="http://localhost:8080/geoserver/wms" target=_blank>http://localhost:8080/geoserver/wms</A>",<BR>&gt; {layers: 'topp:sungai_nr',<BR>&gt; format: 'image/png',transparent:'true'},{'opacity': 0.2});<BR>&gt;&nbsp; <BR>&gt; map.addLayers([layer, river]);<BR>&gt;&nbsp; <BR>&gt; map.addControl(new OpenLayers.Control.Scale($('scale')));<BR>&gt; map.setCenter(new OpenLayers.LonLat(231064.944,9631783.43),4);<BR>&gt; } //function init<BR>&gt;&nbsp; <BR>&gt; function go() {<BR>&gt; //Get the selected value for lonlat<BR>&gt; var lonlat = document.getElementById('lonlat').options[document.getElementById('lonlat').selectedIndex].value;<BR>&gt; // Parse the lonlat to get the longitude<BR>&gt; var longitude =
 lonlat.substring(0,lonlat.indexOf(','));<BR>&gt; // Parse the lonlat to get the latitude<BR>&gt; var latitude = lonlat.substring(lonlat.indexOf(',')+1,lonlat.length);<BR>&gt; // set Center<BR>&gt; map.setCenter(new OpenLayers.LonLat(longitude,latitude),zoom);<BR>&gt;<BR><BR>The above will fail because your map is not known to the go() function.<BR>See my comment above in the init function.<BR><BR>Also, save yourself some lines of code: instead of calculating longitude<BR>and latitude like above, use<BR><BR>map.setCenter(OpenLayers.LonLat.fromString(lonlat);<BR><BR>Regards,<BR>Andreas.<BR><BR>-- <BR>Andreas Hocevar<BR>OpenGeo - <A href="http://opengeo.org/" target=_blank>http://opengeo.org/</A><BR>Expert service straight from the developers.<BR><BR></DIV></BLOCKQUOTE></td></tr></table><br>