Example usage for com.google.gwt.maps.client.services GeocoderStatus OK

List of usage examples for com.google.gwt.maps.client.services GeocoderStatus OK

Introduction

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

Prototype

GeocoderStatus OK

To view the source code for com.google.gwt.maps.client.services GeocoderStatus OK.

Click Source Link

Document

The response contains a valid GeocoderResponse.

Usage

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

/**
 * Sets the location name and invokes the geocoder to get its position.
 *
 * @param name the new location name./*from   ww  w .ja va2s.  com*/
 */
public void setName(String name) {
    if (name == null || name.isEmpty()) {
        return;
    }
    GeocoderRequest rq = GeocoderRequest.newInstance();
    rq.setAddress(name);
    Geocoder geocoder = Geocoder.newInstance();
    geocoder.geocode(rq, new GeocoderRequestHandler() {

        @Override
        public void onCallback(JsArray<GeocoderResult> rs, GeocoderStatus status) {
            if (status == GeocoderStatus.OK) {
                GeocoderResult location = rs.get(0);
                setValueAndFireChange(location.getGeometry().getLocation());
            } else {
                addMessage(Level.ERROR, "Geocode failed: " + status.toString(), null);
            }
        }
    });
}

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

/**
 * Sets the location name and invokes the geocoder to get its position.
 *
 * @param name the new location name.//from ww w . ja v a2s .co m
 */
public void setName(String name) {
    if (name == null || name.isEmpty()) {
        return;
    }
    GeocoderRequest rq = GeocoderRequest.newInstance();
    rq.setAddress(name);
    Geocoder geocoder = Geocoder.newInstance();
    geocoder.geocode(rq, new GeocoderRequestHandler() {

        @Override
        public void onCallback(JsArray<GeocoderResult> rs, GeocoderStatus status) {
            if (status == GeocoderStatus.OK) {
                GeocoderResult location = rs.get(0);
                setValue(location.getGeometry().getLocation());
            } else {
                addMessage(Level.ERROR, "Geocode failed: " + status.toString(), null);
            }
        }
    });
}

From source file:org.rebioma.client.MapView.java

License:Apache License

@Override
public void onCallback(JsArray<com.google.gwt.maps.client.services.GeocoderResult> results,
        GeocoderStatus status) {/* www .j a  v a 2s  .c om*/
    if (GeocoderStatus.OK.equals(status)) {
        mapGeocoderResult(results);
        handleHistoryEvent();
    } else if (GeocoderStatus.ZERO_RESULTS.equals(status)) {
        Window.confirm("Address not found. Add to the Madagascar Gazeteer?");
    } else { //failure
        for (Marker marker : geocoderMarkers) {
            marker.setMap((MapWidget) null);
        }
    }
}