[OpenLayers-Users] Refresh an indepent Layer... every n
seconds...
Arnd Wippermann
arnd.wippermann at web.de
Fri Aug 1 13:16:38 EDT 2008
Sorry, counter has to be in lowercase and I have thought the layer would be
a WMS layer. For Mapserver layers there seems not to exist a redraw
function. Perhaps this will work:
add counter to the params of your Mapserver layer and in your redraw
function use recorridos.params.counter++;
This should change the url for your request, but i don't know, wether this
updates the layer.
Otherwise i have no idea.
Arnd
<html>
<head>
<style type="text/css">
#map {
width: 900px;
height: 600px;
}
</style>
<title>Sistema de Trasporte Urbano - Cuenca Ecuador </title>
<script src="OpenLayers.js"></script>
<script type="text/javascript">
//the global variables
var map;
var recorridos;
var counter=0;
function init()
{
var mapOptions = {
maxExtent: new OpenLayers.Bounds(713620.5057, 9673754.1986,
732936.3635, 9687405.8116),
maxResolution: 'auto',
projection:"EPSG:32717",
units: "m"};
var map = new OpenLayers.Map('map', mapOptions);
map.addControl(new OpenLayers.Control.LayerSwitcher());
var panel = new OpenLayers.Control.NavToolbar();
map.addControl(panel);
map.addControl(new
OpenLayers.Control.MousePosition({'div':OpenLayers.Util.getElement('coords')
}));
var manzanas = new OpenLayers.Layer.MapServer.Untiled( "manzanas",
"../../cgi-bin/mapserv",
{map:'C:/data/publicacion.map',
layers: 'manzanas',map_imagetype: 'png'},
{'displayInLayerSwitcher':false});
var ruta22 = new OpenLayers.Layer.MapServer.Untiled( "Ruta 22",
"../../cgi-bin/mapserv",
{map:'C:/data/publicacion.map', transparent: "true",
layers: 'ruta22_ida',map_imagetype: 'png'},{'isBaseLayer':
false}, {'displayInLayerSwitcher':false});
recorridos = new OpenLayers.Layer.MapServer.Untiled( "Unidad()",
"../../cgi-bin/mapserv",
{map:'C:/data/publicacion.map',
layers: 'recorrido',transparent: "true", map_imagetype: 'png',
'counter':0});
ruta22.setVisibility(false);
map.addLayers([ruta22, manzanas, recorridos]);
if (!map.getCenter()) map.zoomToMaxExtent();
setTimeout("Layer_redraw()",10*1000);
}
function Layer_redraw() {
//this is only for WMS layer
//recorridos.mergeNewParams({ counter : counter++ });
recorridos.params.counter++;
}
</script>
</head>
<body onLoad="init()">
<table>
<tr>
<td align="left"><div id="map"></div></td>
</tr>
</table>
</body>
</html>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20080801/ce420385/attachment.html
More information about the Users
mailing list