Example usage for com.google.gwt.maps.client.geocode Directions load

List of usage examples for com.google.gwt.maps.client.geocode Directions load

Introduction

In this page you can find the example usage for com.google.gwt.maps.client.geocode Directions load.

Prototype

public static void load(String query, DirectionQueryOptions options, DirectionsCallback callback) 

Source Link

Document

Load a new Directions query.

Usage

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

License:Apache License

public SimpleDirectionsDemo() {
    final Grid grid = new Grid(1, 2);
    grid.setWidth("100%");
    grid.getCellFormatter().setWidth(0, 0, "74%");
    grid.getCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_TOP);
    grid.getCellFormatter().setWidth(0, 1, "24%");
    grid.getCellFormatter().setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_TOP);
    map = new MapWidget(LatLng.newInstance(42.351505, -71.094455), 15);
    map.setHeight("480px");
    grid.setWidget(0, 0, map);//from w ww  .j  a v  a2 s. co  m
    DirectionsPanel directionsPanel = new DirectionsPanel();
    grid.setWidget(0, 1, directionsPanel);
    directionsPanel.setSize("100%", "100%");

    initWidget(grid);

    DirectionQueryOptions opts = new DirectionQueryOptions(map, directionsPanel);
    String query = "from: 500 Memorial Dr, Cambridge, MA to: 4 Yawkey Way, Boston, MA";
    Directions.load(query, opts, new DirectionsCallback() {

        public void onFailure(int statusCode) {
            Window.alert(
                    "Failed to load directions: Status " + StatusCodes.getName(statusCode) + " " + statusCode);
        }

        public void onSuccess(DirectionResults result) {
            GWT.log("Successfully loaded directions.", null);
        }
    });
}