Example usage for com.google.gwt.maps.client.geocoder HasGeocoderResult getGeometry

List of usage examples for com.google.gwt.maps.client.geocoder HasGeocoderResult getGeometry

Introduction

In this page you can find the example usage for com.google.gwt.maps.client.geocoder HasGeocoderResult getGeometry.

Prototype

public HasGeocoderGeometry getGeometry();

Source Link

Document

A GeocoderGeometry object

Usage

From source file:com.google.mobile.trippy.web.client.presenter.CreateNewTripPresenter.java

License:Apache License

/**
 * Registering the pop up click handlers.
 *//* ww  w .ja  v a 2 s . c o  m*/
@SuppressWarnings("deprecation")
boolean registerSuggestedHandlers(final List<HasGeocoderResult> responses) {
    final List<HasGeocoderResult> validLocations = new ArrayList<HasGeocoderResult>();
    for (final HasGeocoderResult suggestedTrip : responses) {
        final HasLatLngBounds bounds = suggestedTrip.getGeometry().getBounds();
        final String address = suggestedTrip.getAddressComponents().get(0).getLongName();
        if (bounds != null && address != null) {
            validLocations.add(suggestedTrip);
        }
    }

    final List<String> suggestedTripList = new ArrayList<String>();
    for (HasGeocoderResult suggestedTrip : validLocations) {
        suggestedTripList.add(suggestedTrip.getFormattedAddress());
    }
    if (!suggestedTripList.isEmpty()) {
        display.addSuggestedTripList(suggestedTripList);
        List<HasClickHandlers> suggestedHandlers = display.getSuggestedTripList();
        for (int i = 0; i < validLocations.size(); i++) {
            final HasGeocoderResult suggestedTrip = validLocations.get(i);
            final HasLatLngBounds bounds = suggestedTrip.getGeometry().getBounds();
            final String address = suggestedTrip.getAddressComponents().get(0).getLongName();
            final String location = suggestedTrip.getFormattedAddress();
            suggestedHandlers.get(i).addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    addTripToDb(location, address, bounds);
                }
            });
        }
        return true;
    }
    return false;
}