Search in sources :

Example 1 with GeocodeResult

use of com.here.android.mpa.search.GeocodeResult in project here-android-sdk-examples by heremaps.

the class MainView method triggerGeocodeRequest.

private void triggerGeocodeRequest() {
    m_resultTextView.setText("");
    /*
         * Create a GeocodeRequest object with the desired query string, then set the search area by
         * providing a GeoCoordinate and radius before executing the request.
         */
    String query = "4350 Still Creek Dr,Burnaby";
    GeocodeRequest geocodeRequest = new GeocodeRequest(query);
    GeoCoordinate coordinate = new GeoCoordinate(49.266787, -123.056640);
    geocodeRequest.setSearchArea(coordinate, 5000);
    geocodeRequest.execute(new ResultListener<List<GeocodeResult>>() {

        @Override
        public void onCompleted(List<GeocodeResult> results, ErrorCode errorCode) {
            if (errorCode == ErrorCode.NONE) {
                /*
                     * From the result object, we retrieve the location and its coordinate and
                     * display to the screen. Please refer to HERE Android SDK doc for other
                     * supported APIs.
                     */
                StringBuilder sb = new StringBuilder();
                for (GeocodeResult result : results) {
                    sb.append(result.getLocation().getCoordinate().toString());
                    sb.append("\n");
                }
                updateTextView(sb.toString());
            } else {
                updateTextView("ERROR:Geocode Request returned error code:" + errorCode);
            }
        }
    });
}
Also used : GeoCoordinate(com.here.android.mpa.common.GeoCoordinate) List(java.util.List) ErrorCode(com.here.android.mpa.search.ErrorCode) GeocodeRequest(com.here.android.mpa.search.GeocodeRequest) ReverseGeocodeRequest(com.here.android.mpa.search.ReverseGeocodeRequest) GeocodeResult(com.here.android.mpa.search.GeocodeResult)

Aggregations

GeoCoordinate (com.here.android.mpa.common.GeoCoordinate)1 ErrorCode (com.here.android.mpa.search.ErrorCode)1 GeocodeRequest (com.here.android.mpa.search.GeocodeRequest)1 GeocodeResult (com.here.android.mpa.search.GeocodeResult)1 ReverseGeocodeRequest (com.here.android.mpa.search.ReverseGeocodeRequest)1 List (java.util.List)1