[OpenLayers-Users] Refresh marker without refreshing whole map

Nathan Gerber ngerber999 at gmail.com
Mon Jan 25 17:48:56 EST 2010


Your coordinates appear to be hardcoded into the HTML. If you want the
location to change you will need to pull the coordinates in through the
server itself through a WFS or some other server based layer.
--
Nathan Gerber


On Mon, Jan 25, 2010 at 5:05 PM, <jbloc1878 at googlemail.com> wrote:

> Hi,   i am currently using OS Open Space which i believe is similer to Open
> Layers.
>
> I am currenty displaying a map with a marker. However my marker coordinates
> can change whilst the user is viewing the map so i would like the Marker
> code to refresh and re-plot the marker every 10 seconds however i cannot
> work out how to do this. I have tried adding aHTML refresh command <meta
> http-equiv="refresh" content="10"> causes the whole map to refresh.
>
> I tried creating a refresh function that calls the marker function i
> created that plots the marker as shown below. however the marker looks like
> it refreshes as the marker flashes every 10 seconds however it does not
> replot if the coordinates if they have changed. Does anyone have any
> suggestions for refreshing a function within javascript?
>
> Thanks for any help in advance my code is below
>
>
> <script type="text/javascript">
>
> var osMap;
>
> function init()
> {
> osMap = new OpenSpace.Map('map');
>
> osMap.setCenter(new OpenSpace.MapPoint(439300, 114760), 8);
>
> }
>
> function refresh()
>
> {
>
> setInterval('marker()', 10000);
>
> }
>
> function marker()
> {
>
> var markers = new OpenLayers.Layer.Markers("Markers");
> osMap.addLayer(markers);
>
> // Default icon
> var pos = new OpenSpace.MapPoint(438760, 114760);
> var marker = new OpenLayers.Marker(pos);
>
> markers.addMarker(marker);
> }
>
> </script>
> </head>
> <body onload="init(); refresh()">
>
> Thanks for any help in advance
>
>
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100125/e5c06c2e/attachment.html


More information about the Users mailing list