aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/web/client/controller/MapController.java
blob: 5a53cf225a406403c5fa8adfbd49cf641d1a8c74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package org.traccar.web.client.controller;

import org.traccar.web.client.view.MapView;
import org.traccar.web.shared.model.Device;

import com.google.gwt.user.client.Timer;
import com.sencha.gxt.widget.core.client.ContentPanel;

public class MapController implements ContentController {

    private static final int UPDATE_INTERVAL = 10000;

    private MapView mapView;

    public MapController() {
        mapView = new MapView();
    }

    @Override
    public ContentPanel getView() {
        return mapView.getView();
    }

    private Timer updateTimer;

    @Override
    public void run() {
        updateTimer = new Timer() {
            @Override
            public void run() {
                update();
            }
        };
        update();
    }

    public void update() {
        updateTimer.cancel();
        /*Application.getDataService().getLatestPositions(new AsyncCallback<List<Position>>() {
            @Override
            public void onSuccess(List<Position> result) {
                mapView.showPositions(result);
                updateTimer.schedule(UPDATE_INTERVAL);
            }
            @Override
            public void onFailure(Throwable caught) {
                updateTimer.schedule(UPDATE_INTERVAL);
            }
        });*/
    }

    public void select(Device device) {
        mapView.select(device, true);
    }

}