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

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

Introduction

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

Prototype

public static final GeocoderRequest newInstance() 

Source Link

Document

The specification for a geocoding request to be sent to the Geocoder.

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. j av a  2s.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.// ww 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);
                setValue(location.getGeometry().getLocation());
            } else {
                addMessage(Level.ERROR, "Geocode failed: " + status.toString(), null);
            }
        }
    });
}

From source file:org.rebioma.client.maps.GeocoderControl.java

License:Apache License

public GeocoderControl(GeocoderRequestHandler requestHandler) {
    super();//from w w  w .java2  s . c om
    this.geocoderRequestHandler = requestHandler;
    this.geocoderRequest = GeocoderRequest.newInstance();
    this.geocoder = Geocoder.newInstance();
    final FormPanel form = new FormPanel();
    form.setAction("#");
    Panel formElements = new FlowPanel();
    addressBox.setVisibleLength(26);
    addressBox.selectAll();
    formElements.add(addressBox);
    submit = new Button("Find place");
    formElements.add(submit);

    submit.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            String address = getAddress();
            if (address == null || address.trim().length() == 0) {
                Window.alert("Please enter an address.");
                return;
            }
            form.submit();
        }
    });
    //      formElements.add(new HTML("&nbsp;"));
    form.add(formElements);
    form.addSubmitHandler(new SubmitHandler() {
        public void onSubmit(SubmitEvent event) {
            lookupAddress(addressBox.getText());
            event.cancel();
        }
    });
    add(form);
}