aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/web/client/controller/MapController.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2013-01-02 23:55:50 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2013-01-02 23:55:50 +1300
commita7c6a5f03c0ac94603b5238c59a275a239d16b73 (patch)
tree02460edcd1e7fb0101d46ef4e690eb3cbd7cc71d /src/main/java/org/traccar/web/client/controller/MapController.java
parent7032c42fb017582f1343128466b8df51c155f78d (diff)
downloadetbsa-traccar-web-a7c6a5f03c0ac94603b5238c59a275a239d16b73.tar.gz
etbsa-traccar-web-a7c6a5f03c0ac94603b5238c59a275a239d16b73.tar.bz2
etbsa-traccar-web-a7c6a5f03c0ac94603b5238c59a275a239d16b73.zip
Added markers to map panel
Diffstat (limited to 'src/main/java/org/traccar/web/client/controller/MapController.java')
-rw-r--r--src/main/java/org/traccar/web/client/controller/MapController.java45
1 files changed, 44 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/web/client/controller/MapController.java b/src/main/java/org/traccar/web/client/controller/MapController.java
index 6493883..8932050 100644
--- a/src/main/java/org/traccar/web/client/controller/MapController.java
+++ b/src/main/java/org/traccar/web/client/controller/MapController.java
@@ -1,14 +1,57 @@
package org.traccar.web.client.controller;
+import java.util.List;
+
+import org.traccar.web.client.Traccar;
import org.traccar.web.client.view.MapPanel;
+import org.traccar.web.shared.model.Device;
+import org.traccar.web.shared.model.Position;
+import com.google.gwt.user.client.Timer;
+import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.widgets.Canvas;
public class MapController implements PanelController {
+ private static final int UPDATE_INTERVAL = 10000;
+
+ private final MapPanel mapPanel;
+
+ private final Timer updateTimer;
+
+ public MapController() {
+ mapPanel = new MapPanel();
+ updateTimer = new Timer() {
+ @Override
+ public void run() {
+ update();
+ }
+ };
+ update();
+ }
+
@Override
public Canvas getView() {
- return new MapPanel();
+ return mapPanel;
+ }
+
+ public void select(Device device) {
+ mapPanel.select(device, true);
+ }
+
+ public void update() {
+ updateTimer.cancel();
+ Traccar.getDatabaseService().getLatestPositions(new AsyncCallback<List<Position>>() {
+ @Override
+ public void onSuccess(List<Position> result) {
+ mapPanel.showPositions(result);
+ updateTimer.schedule(UPDATE_INTERVAL);
+ }
+ @Override
+ public void onFailure(Throwable caught) {
+ updateTimer.schedule(UPDATE_INTERVAL);
+ }
+ });
}
}