Example usage for com.google.gwt.maps.client.services DirectionsStatus value

List of usage examples for com.google.gwt.maps.client.services DirectionsStatus value

Introduction

In this page you can find the example usage for com.google.gwt.maps.client.services DirectionsStatus value.

Prototype

public String value() 

Source Link

Usage

From source file:com.google.gwt.maps.testing.client.maps.TransitDirectionsServiceMapWidget.java

License:Apache License

private void drawRandomDirections() {
    /* Compute a direction with random from, to */
    LatLng origin = LatLng.newInstance(Math.random() * (MAX_LAT - MIN_LAT) + MIN_LAT,
            Math.random() * (MAX_LON - MIN_LON) + MIN_LON);
    LatLng destination = LatLng.newInstance(Math.random() * (MAX_LAT - MIN_LAT) + MIN_LAT,
            Math.random() * (MAX_LON - MIN_LON) + MIN_LON);

    DirectionsRequest request = DirectionsRequest.newInstance();
    request.setOrigin(origin);/*w w  w .  j av  a  2 s  . c o m*/
    request.setDestination(destination);
    request.setTravelMode(TravelMode.TRANSIT);
    TransitOptions transitOptions = TransitOptions.newInstance();
    long departure = System.currentTimeMillis() + Math.round(Math.random() * DELTA_TIME_MS) - DELTA_TIME_MS / 2;
    final Date departureDateTime = new Date(departure);
    transitOptions.setDepartureTime(departureDateTime);
    request.setTransitOptions(transitOptions);
    request.setOptimizeWaypoints(true);

    DirectionsService o = DirectionsService.newInstance();
    o.route(request, new DirectionsResultHandler() {
        public void onCallback(DirectionsResult result, DirectionsStatus status) {
            if (status == DirectionsStatus.OK) {
                directionsDisplay.setDirections(result);
                DirectionsRoute route = result.getRoutes().get(0);
                htmlStatus.setHTML("Request OK");
                updateStatus(route, departureDateTime);
            } else {
                htmlStatus.setHTML("Request error: " + status.value());
            }
        }
    });
}

From source file:eu.vital.maps.client.maps.TransitDirectionsServiceMapWidget.java

License:Apache License

private void drawRandomDirections() {

    /* Compute a direction with random from, to */
    LatLng origin = LatLng.newInstance(Math.random() * (MAX_LAT - MIN_LAT) + MIN_LAT,
            Math.random() * (MAX_LON - MIN_LON) + MIN_LON);
    LatLng destination = LatLng.newInstance(Math.random() * (MAX_LAT - MIN_LAT) + MIN_LAT,
            Math.random() * (MAX_LON - MIN_LON) + MIN_LON);

    DirectionsRequest request = DirectionsRequest.newInstance();
    request.setOrigin(origin);// w  w  w .j  a  v a 2s. c o  m
    request.setDestination(destination);
    request.setTravelMode(TravelMode.TRANSIT);
    TransitOptions transitOptions = TransitOptions.newInstance();
    long departure = System.currentTimeMillis() + Math.round(Math.random() * DELTA_TIME_MS) - DELTA_TIME_MS / 2;
    final Date departureDateTime = new Date(departure);
    transitOptions.setDepartureTime(departureDateTime);
    request.setTransitOptions(transitOptions);
    request.setOptimizeWaypoints(true);

    DirectionsService o = DirectionsService.newInstance();
    o.route(request, new DirectionsResultHandler() {
        public void onCallback(DirectionsResult result, DirectionsStatus status) {
            if (status == DirectionsStatus.OK) {
                directionsDisplay.setDirections(result);
                DirectionsRoute route = result.getRoutes().get(0);
                htmlStatus.setHTML("Request OK");
                updateStatus(route, departureDateTime);
            } else {
                htmlStatus.setHTML("Request error: " + status.value());
            }
        }
    });
}