سؤال

I am trying to track a position of a device running the mapmytracks.com app. The website allows users to export GPS tracks as KML files, including ongoing activities. In my GWT app, I crate a network link using URL to the KML file from mapmytracks.com.

The link is set to refresh every 1 second interval. Each time the refresh occurs, plugin pulls new data and I see that reflected in the time slider - there is more room to move it forward.

However, in order to see the current position I have to manually move the slider to the right-most position. I know how to set the time in the plugin to the current time, but how can I tell the plugin to do it each time the network link is refreshed? Is it possible to add some kind of a handler to the network link?

هل كانت مفيدة؟

المحلول

You can't add a handler to the network link as there are no exposed events.

However you could simply set the time slider to the current system time every second to keep up with your Kml data.

// sets the current slider position to the current system time
function updateTime() {
  ge.getTime().setTimePrimitive(ge.getTime().getSystemTime().getWhen().get());
}

var timer = setInterval(updateTime, 1000); //update the slider every second.

Obviously you could add other checks, to see if a particular element is present or if the slider is visible, etc.

If you need to stop the timer you would simply call

clearInterval(timer);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top