Example usage for com.google.gwt.maps.client.event TrafficOverlayChangedHandler TrafficOverlayChangedHandler

List of usage examples for com.google.gwt.maps.client.event TrafficOverlayChangedHandler TrafficOverlayChangedHandler

Introduction

In this page you can find the example usage for com.google.gwt.maps.client.event TrafficOverlayChangedHandler TrafficOverlayChangedHandler.

Prototype

TrafficOverlayChangedHandler

Source Link

Usage

From source file:com.google.gwt.maps.sample.hellomaps.client.TrafficOverlayDemo.java

License:Apache License

public TrafficOverlayDemo() {
    Panel panel = new FlowPanel();

    map = new MapWidget(LatLng.newInstance(40.652513, -73.936615), 12);
    map.setSize("640px", "480px");
    panel.add(map);// w  w  w. ja va 2s . com
    Button toggleTraffic = new Button("Toggle Traffic");
    toggleTraffic.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            if (trafficShown) {
                map.removeOverlay(trafficInfo);
            } else {
                map.addOverlay(trafficInfo);
            }
            trafficShown = !trafficShown;
        }
    });
    panel.add(toggleTraffic);
    final Label changeLabel = new Label();
    panel.add(changeLabel);
    initWidget(panel);
    trafficInfo = new TrafficOverlay();
    trafficInfo.addTrafficOverlayChangedHandler(new TrafficOverlayChangedHandler() {

        public void onChanged(TrafficOverlayChangedEvent event) {
            changeLabel.setText("Last Changed: " + new Date());
        }

    });
}