Periodic Actualisation of Trafficinfos

This forum deals with any kind of web based client technology, whether it is the well known java script based Ajax servlet or the upcoming approaches such as Leaflet, OpenLayers and so on.
Post Reply
hubere
Posts: 1
Joined: Wed Aug 27, 2014 8:56 am

Periodic Actualisation of Trafficinfos

Post by hubere »

Hello,

collecting first experiences with the traffic info service configured in xMap-Server, I was wondering how to get our JAVA-AJAX-Client to update traffic info (do a poiRequest) periodicall without user interaction.
The straight forward way would be to ask the the AJAX-Client periodically for the same map section. However the AJAX-Client is smart enough to tell us immediately the we have that exact map section already and would not think that the POIs could have changed meanwhile.

How can I get around that?

Kind Regards
Edwin Huber
AndreasJunghans
Posts: 13
Joined: Tue May 13, 2014 3:28 pm

Re: Periodic Actualisation of Trafficinfos

Post by AndreasJunghans »

Hello Mr Huber,

in the current implementation, there is no explicit refresh method. And you are right that setting the same center again is optimized away, so no new request is made.

The easiest solution for now is to set a new center with a tiny change along one axis:

Code: Select all

private int counter = 0;

...

public void refresh() {
  ++counter;
  if (counter > 1000) counter = 1;
  Point center = map.getCenter();
  map.setCenter(new Point(center.getX() + counter*0.000001, center.getY()));
}
The change isn't noticeable, but it's enough to force a refresh.

Regards,

Andreas Junghans
Post Reply