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