Example usage for com.google.gwt.maps.client.geocode DirectionQueryOptions DirectionQueryOptions

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

Introduction

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

Prototype

public DirectionQueryOptions(MapWidget map, DirectionsPanel panel) 

Source Link

Document

Create an options object with default parameters associated with a particular map and a panel to put the textual directions in.

Usage

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

License:Apache License

public RoutedDirectionsDemo() {
    final Grid grid = new Grid(1, 2);
    grid.setWidth("100%");
    grid.getCellFormatter().setWidth(0, 0, "64%");
    grid.getCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_TOP);
    grid.getCellFormatter().setWidth(0, 1, "34%");
    grid.getCellFormatter().setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_TOP);

    map = new MapWidget(ATLANTA, 15);
    map.setHeight("480px");
    map.addControl(new LargeMapControl());
    grid.setWidget(0, 0, map);//from   www.  j ava  2 s. c o  m
    DirectionsPanel directionsPanel = new DirectionsPanel();
    grid.setWidget(0, 1, directionsPanel);
    directionsPanel.setSize("100%", "100%");

    initWidget(grid);

    DirectionQueryOptions opts = new DirectionQueryOptions(map, directionsPanel);

    // Create directions from Midtown Atlanta to the Airport with a *few*
    // stops along the way.    
    Directions.loadFromWaypoints(waypoints, 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);

            // A little exercise of the route API
            List<Route> routes = result.getRoutes();
            for (Route r : routes) {
                Placemark start = r.getStartGeocode();
                GWT.log("start of route: " + start.getAddress(), null);
                Placemark end = r.getEndGeocode();
                GWT.log("end of route: " + end.getAddress(), null);
            }
        }
    });
}

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.  ja  v  a  2  s .  c  o  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);
        }
    });
}