Example usage for com.google.gwt.maps.client.services GeocoderResult getGeometry

List of usage examples for com.google.gwt.maps.client.services GeocoderResult getGeometry

Introduction

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

Prototype

public final native GeocoderGeometry getGeometry() ;

Source Link

Document

A GeocoderGeometry object

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

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

License:Apache License

protected void mapGeocoderResult(JsArray<com.google.gwt.maps.client.services.GeocoderResult> results) {
    String address = geocoder.getAddress();
    StringBuilder sb = new StringBuilder();
    LatLng point = null;//from w ww  .  j a va2 s  . c  om
    for (int i = 0; i < results.length(); i++) {
        com.google.gwt.maps.client.services.GeocoderResult geoResult = results.get(i);
        point = geoResult.getGeometry().getLocation();
        MapGeocoderResult result = new MapGeocoderResult(point, address);
        sb.append(result);
        InfoWindowOptions contentOptions = InfoWindowOptions.newInstance();
        contentOptions.setContent(result);
        contentOptions.setPosition(point);
        final InfoWindow content = InfoWindow.newInstance(contentOptions);
        if (geocoderMarkers != null) {
            for (Marker marker : geocoderMarkers) {
                marker.setMap((MapWidget) null);
            }
        }
        Marker geocoderMarker = GeocoderControl.createMarker(point, address);
        geocoderMarker.setMap(map);
        geocoderMarker.addClickHandler(new ClickMapHandler() {
            @Override
            public void onEvent(ClickMapEvent event) {
                closeInfoWindows();
                content.open(map);
                infoWindows.add(content);
            }
        });
        geocoderMarkers.add(geocoderMarker);
    }
    if (results.length() == 1 && point != null) {
        map.setCenter(point);
    }
}