<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;"><DIV>Dear Andreas,</DIV>
<DIV>&nbsp;</DIV>
<DIV>Formerly, &nbsp;I call go() function (see snippet below) which handles the map.setCenter, it seems that this function doesn't react to the change of lonlat value in drop down list. I have two layers, my base layer is a big quickbird image tiled into 6 zoom levels and other layer is WMS layer with hundreds of river names. Drop down list should help user to pin point selected river in the quickbird image.</DIV>
<DIV>&nbsp;</DIV>
<DIV>When I call init() function it doeas react, but create a series of map which doesn't overwrite each other. I certainly do not want to create new map every time I change lonlat value, it will double/tripple processing &nbsp;time.</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>-----------------</DIV>
<DIV>&nbsp;</DIV>
<DIV>function init(){ </DIV>
<DIV>&nbsp;</DIV>
<DIV>var options = { </DIV>
<DIV>theme: null, </DIV>
<DIV>maxExtent: new OpenLayers.Bounds(225389.527874, 9627709.46055, 244613.714826, 9639853.34683 ),</DIV>
<DIV>maxResolution: 103.338482,</DIV>
<DIV>projection: 'EPSG:4326',</DIV>
<DIV>units: 'm',</DIV>
<DIV>controls: [ </DIV>
<DIV>new OpenLayers.Control.LayerSwitcher(), </DIV>
<DIV>new OpenLayers.Control.MousePosition(), </DIV>
<DIV>new OpenLayers.Control.PanZoom(), </DIV>
<DIV>new OpenLayers.Control.ScaleLine() </DIV>
<DIV>] </DIV>
<DIV>}; //option</DIV>
<DIV>&nbsp;</DIV>
<DIV>var mapBounds = new OpenLayers.Bounds( 225389.527874, 9627709.46055, 244613.714826, 9639853.34683 );</DIV>
<DIV>&nbsp;</DIV>
<DIV>var map = new OpenLayers.Map('map', options ); </DIV>
<DIV>&nbsp;</DIV>
<DIV>var layer = new OpenLayers.Layer.TMS( "TMS Layer","",</DIV>
<DIV>{ url: '', serviceVersion: '.', layername: '.', alpha: true,</DIV>
<DIV>type: 'png', getURL: overlay_getTileURL });</DIV>
<DIV>&nbsp;</DIV>
<DIV></DIV>
<DIV>var river = new OpenLayers.Layer.WMS(</DIV>
<DIV>"topp:sungai_nr - river", "http://localhost:8080/geoserver/wms", {layers: 'topp:sungai_nr',</DIV>
<DIV>format: 'image/png',transparent:'true'},{'opacity': 0.2}); </DIV>
<DIV>&nbsp;</DIV>
<DIV></DIV>
<DIV>map.addLayers([layer, river]); </DIV>
<DIV>&nbsp;</DIV>
<DIV>map.addControl(new OpenLayers.Control.Scale($('scale')));</DIV>
<DIV>map.setCenter(new OpenLayers.LonLat(231064.944,9631783.43),4);</DIV>
<DIV>} //function init</DIV>
<DIV>&nbsp;</DIV>
<DIV>function&nbsp;go()&nbsp;{</DIV>
<DIV>//Get the selected value for lonlat</DIV>
<DIV>var&nbsp;lonlat&nbsp;=&nbsp;document.getElementById('lonlat').options[document.getElementById('lonlat').selectedIndex].value;</DIV>
<DIV>// Parse the lonlat to get the longitude</DIV>
<DIV>var&nbsp;longitude&nbsp;=&nbsp;lonlat.substring(0,lonlat.indexOf(','));</DIV>
<DIV>// Parse the lonlat to get the latitude</DIV>
<DIV>var&nbsp;latitude&nbsp;=&nbsp;lonlat.substring(lonlat.indexOf(',')+1,lonlat.length);</DIV>
<DIV>// set Center</DIV>
<DIV>map.setCenter(new&nbsp;OpenLayers.LonLat(longitude,latitude),zoom); </DIV>
<DIV>}</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>function overlay_getTileURL(bounds) {</DIV>
<DIV>var res = this.map.getResolution();</DIV>
<DIV>var x = Math.round((bounds.left - this.maxExtent.left) / (res * this...tileSize.w));</DIV>
<DIV>var y = Math.round((bounds.bottom - this.maxExtent.bottom) / (res * this.tileSize.h));</DIV>
<DIV>var z = this.map.getZoom();</DIV>
<DIV>if (x &gt;= 0 &amp;&amp; y &gt;= 0) {</DIV>
<DIV>return this.url + z + "/" + x + "/" + y + "." + this.type; </DIV>
<DIV>} else {</DIV>
<DIV>return <A href="http://www.maptiler.org/img/none.png" target=_blank rel=nofollow><SPAN class=yshortcuts id=lw_1252067997_0>http://www.maptiler.org/img/none.png</SPAN></A>;</DIV>
<DIV>}</DIV>
<DIV>}</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV></DIV>
<DIV>function getWindowHeight() {</DIV>
<DIV>if (self.innerHeight) return self.innerHeight;</DIV>
<DIV>if (document.documentElement &amp;&amp; document.documentElement.clientHeight)</DIV>
<DIV>return document.documentElement.clientHeight;</DIV>
<DIV>if (document.body) return document.body.clientHeight;</DIV>
<DIV>return 0;</DIV>
<DIV>}</DIV>
<DIV>function getWindowWidth() {</DIV>
<DIV>if (self.innerWidth) return self.innerWidth;</DIV>
<DIV>if (document.documentElement &amp;&amp; document.documentElement.clientWidth)</DIV>
<DIV>return document.documentElement.clientWidth;</DIV>
<DIV>if (document.body) return document.body.clientWidth;</DIV>
<DIV>return 0;</DIV>
<DIV>}</DIV>
<DIV>&nbsp;</DIV>
<DIV>function resize() { </DIV>
<DIV>var map = document.getElementById("map"); </DIV>
<DIV>var header = document.getElementById("header"); </DIV>
<DIV>var subheader = document.getElementById("subheader"); </DIV>
<DIV>map.style.height = (getWindowHeight()-80) + "px";</DIV>
<DIV>map.style.width = (getWindowWidth()-20) + "px";</DIV>
<DIV>header.style.width = (getWindowWidth()-20) + "px";</DIV>
<DIV>subheader.style.width = (getWindowWidth()-20) + "px";</DIV>
<DIV>if (map.updateSize) { map.updateSize(); };</DIV>
<DIV>} </DIV>
<DIV>&nbsp;</DIV>
<DIV>onresize=function(){ resize(); };</DIV>
<DIV>&lt;/script&gt; </DIV>
<DIV>&lt;/head&gt; </DIV>
<DIV>&nbsp;</DIV>
<DIV>&lt;body onload="init()"&gt;</DIV>
<DIV>&lt;p&gt;River Name:</DIV>
<DIV>&lt;select id="lonlat" onchange="go()"&gt;</DIV>
<DIV>&lt;option value="232064.944, 9631783.43"&gt;River A&lt;/option&gt;</DIV>
<DIV>&lt;option value="231064.944, 9631783.43"&gt;River B&lt;/option&gt;</DIV>
<DIV>&lt;option value="230064.944, 9631783.43"&gt;River C&lt;/option&gt;</DIV>
<DIV>&lt;option value="229064.944, 9631783.43"&gt;River D&lt;/option&gt;</DIV>
<DIV>&lt;option value="228064.944, 9631783.43"&gt;River E&lt;/option&gt;</DIV>
<DIV>&lt;/select&gt;</DIV>
<DIV>&lt;/p&gt;</DIV>
<DIV>&lt;/body&gt;</DIV>
<DIV>&lt;/html&gt; </DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>Kind regards,</DIV>
<DIV>&nbsp;</DIV>
<DIV>surya<BR><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, 8:54 AM<BR><BR>
<DIV class=plainMail>What do you do with the lonlat values in your init function? I assume<BR>you just center the map there.<BR><BR>If that is the case, change the onchange handler of your dropdown to do<BR>something like<BR><BR>map.setCenter(&lt;lon, lat from your selected option here&gt;);<BR><BR>If you have something like map = new OpenLayers.Map(...); in your init<BR>function, you will create a new map instance every time you run it,<BR>which you obviously do not want.<BR><BR>Regards,<BR>Andreas.<BR><BR>Surya Tarigan wrote:<BR>&gt; Dear List,<BR>&gt;&nbsp; <BR>&gt; I need help, when I,m passing lonlat value to init() function from<BR>&gt; html drop downlist see snippet below), the next map will be displayed<BR>&gt; beneath previous map whithout overwriting it.&nbsp; What statement do I <BR>&gt; have to ad to the script to overwite previous map every time I' select<BR>&gt; new latlon value from dropdownlist?<BR>&gt;&nbsp; <BR>&gt;
 sincerely<BR>&gt;&nbsp; <BR>&gt; surya<BR>&gt;</DIV></BLOCKQUOTE></td></tr></table><br>