Jump to content

Is it possible to refresh a function without refreshing a whole page ?


UG1234

Recommended Posts

Hi,

 

I am using Javascript to displayi a map with a marker (Using OS OpenSpace). 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. Adding HTML refresh command <meta http-equiv="refresh" content="10"> obviously 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. Is it possible to refresh a function within a webpage?

 

Thanks for any help in advance

 

 

<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

   

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.