Example usage for com.google.gwt.maps.client.services GeocoderRequest setAddress

List of usage examples for com.google.gwt.maps.client.services GeocoderRequest setAddress

Introduction

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

Prototype

public final native void setAddress(String address) ;

Source Link

Document

Address.

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