[OpenLayers-Users] Ovewriting previous map

Andreas Hocevar ahocevar at opengeo.org
Tue Sep 8 04:54:26 EDT 2009


What do you do with the lonlat values in your init function? I assume
you just center the map there.

If that is the case, change the onchange handler of your dropdown to do
something like

map.setCenter(<lon, lat from your selected option here>);

If you have something like map = new OpenLayers.Map(...); in your init
function, you will create a new map instance every time you run it,
which you obviously do not want.

Regards,
Andreas.

Surya Tarigan wrote:
> Dear List,
>  
> I need help, when I,m passing lonlat value to init() function from
> html drop downlist see snippet below), the next map will be displayed
> beneath previous map whithout overwriting it.  What statement do I 
> have to ad to the script to overwite previous map every time I' select
> new latlon value from dropdownlist?
>  
> sincerely
>  
> surya
>  
> <body>
> <style type="text/css"> #map { width: 350px; height: 350px; border:
> 1px solid black; target="_blank" } </style>
> <div id="map" </div>
> <select id="lonlat" onchange="init()">
> <option value="232064.944, 9631783.43">River A</option>
> <option value="231064.944, 9631783.43">River B</option>
> <option value="230064.944, 9631783.43">River C</option>
> <option value="229064.944, 9631783.43">River D</option>
> <option value="228064.944, 9631783.43">River E</option>
> </select>
> </body>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>   


-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.




More information about the Users mailing list