Example usage for com.google.gwt.maps.client.services DirectionsLeg getEnd_Address

List of usage examples for com.google.gwt.maps.client.services DirectionsLeg getEnd_Address

Introduction

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

Prototype

public final native String getEnd_Address() ;

Source Link

Document

The address of the destination of this leg.

Usage

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

License:Apache License

private void updateStatus(DirectionsRoute route, Date departureDateTime) {
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < route.getLegs().length(); i++) {
        DirectionsLeg leg = route.getLegs().get(i);
        sb.append(leg.getStart_Address()).append(" &rarr; ").append(leg.getEnd_Address());
        sb.append("<br/>");
        Date arrivalDate = null;//from  ww w .  j  av a 2s  . c om
        if (leg.getDuration() != null) {
            sb.append(leg.getDuration().getText()).append(" / ");
            arrivalDate = new Date(departureDateTime.getTime() + leg.getDuration().getValue() * 1000);
        }
        sb.append(leg.getDistance().getText());
        sb.append(" (");
        sb.append(departureDateTime.toString());
        if (arrivalDate != null)
            sb.append(" &rarr; ").append(arrivalDate.toString());
        sb.append(")<br/>");
    }
    htmlSummary.setHTML(sb.toString());
}

From source file:net.cbtltd.client.field.RouteField.java

public String getValue() {
    StringBuilder sb = new StringBuilder();
    JsArray<DirectionsRoute> routes = result.getRoutes();
    if (routes == null) {
        sb.append("No directions available");
    } else {/* w w w  .j  ava  2s .c o  m*/
        sb.append("Route\n");
        for (int i = 0; i < routes.length(); i++) {
            DirectionsRoute route = routes.get(i);
            sb.append(route.getWarnings());
            JsArray<DirectionsLeg> legs = route.getLegs();
            for (int j = 0; j < routes.length(); j++) {
                DirectionsLeg leg = legs.get(j);
                sb.append(leg.getStart_Address());
                sb.append(" to ");
                sb.append(leg.getEnd_Address());
                sb.append(" ");
                sb.append(leg.getDistance().getText());
                sb.append(" (");
                sb.append(leg.getDuration().getText());
                sb.append(")\n\n");
            }
        }
    }
    return Text.stripHTML(sb.toString());
}

From source file:net.cbtltd.client.field.RouteField.java

/**
 * Gets the HTML table of the route directions.
 * /*w w w .  j  a  va2s .  c om*/
 * @param all is true if the <pre><html><body>...</body></html></pre> tags are to be included. 
 * @return the HTML table of the route directions.
 */
public String getHTML(boolean all) {
    StringBuilder sb = new StringBuilder();
    if (all) {
        sb.append("<html><body>");
    }
    JsArray<DirectionsRoute> routes = result.getRoutes();
    if (routes == null) {
        sb.append("No directions available");
    }
    for (int i = 0; i < routes.length(); i++) {
        DirectionsRoute route = routes.get(i);
        sb.append(route.getWarnings());
        JsArray<DirectionsLeg> legs = route.getLegs();
        for (int j = 0; j < routes.length(); j++) {
            DirectionsLeg leg = legs.get(j);
            sb.append("<tr>");
            sb.append("<td>");
            sb.append(leg.getStart_Address() + " to " + leg.getEnd_Address());
            sb.append("</td>");
            sb.append("<td>");
            sb.append(leg.getDistance().getText());
            sb.append("</td>");
            sb.append("<td>(");
            sb.append(leg.getDuration().getText());
            sb.append(")</td>");
            sb.append("</tr>");
        }
        sb.append("</table>");
    }
    if (all) {
        sb.append("</body></html>");
    }
    return sb.toString();
}