Search in sources :

Example 1 with CircleOptions

use of com.amap.api.maps.model.CircleOptions in project LivingInCampus by DulCoder.

the class PoiAroundSearchActivity method onPoiSearched.

@Override
public void onPoiSearched(PoiResult result, int rcode) {
    /**
     * 点击隐藏软键盘
     */
    InputMethodManager mInputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
    mInputMethodManager.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), 0);
    if (rcode == 1000) {
        if (result != null && result.getQuery() != null) {
            // 搜索poi的结果
            if (result.getQuery().equals(query)) {
                // 是否是同一条
                poiResult = result;
                // 取得第一页的poiitem数据,页数从数字0开始
                poiItems = poiResult.getPois();
                List<SuggestionCity> suggestionCities = poiResult.getSearchSuggestionCitys();
                if (poiItems != null && poiItems.size() > 0) {
                    // 清除POI信息显示
                    whetherToShowDetailInfo(false);
                    // 并还原点击marker样式
                    if (mLastMarker != null) {
                        resetLastMarker();
                    }
                    // 清理之前搜索结果的marker
                    if (poiOverlay != null) {
                        poiOverlay.removeFromMap();
                    }
                    mAMap.clear();
                    poiOverlay = new myPoiOverlay(mAMap, poiItems);
                    poiOverlay.addToMap();
                    poiOverlay.zoomToSpan();
                    mAMap.addMarker(new MarkerOptions().anchor(0.5f, 0.5f).icon(BitmapDescriptorFactory.fromBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.point4))).position(new LatLng(lp.getLatitude(), lp.getLongitude())));
                    mAMap.addCircle(new CircleOptions().center(new LatLng(lp.getLatitude(), lp.getLongitude())).radius(10000).strokeColor(Color.BLUE).fillColor(Color.argb(50, 1, 1, 1)).strokeWidth(2));
                } else if (suggestionCities != null && suggestionCities.size() > 0) {
                    showSuggestCity(suggestionCities);
                } else {
                    Utils.toast(PoiAroundSearchActivity.this, R.string.no_result);
                }
            }
        } else {
            Utils.toast(PoiAroundSearchActivity.this, R.string.no_result);
        }
    }
}
Also used : SuggestionCity(com.amap.api.services.core.SuggestionCity) MarkerOptions(com.amap.api.maps.model.MarkerOptions) CircleOptions(com.amap.api.maps.model.CircleOptions) InputMethodManager(android.view.inputmethod.InputMethodManager) LatLng(com.amap.api.maps.model.LatLng)

Aggregations

InputMethodManager (android.view.inputmethod.InputMethodManager)1 CircleOptions (com.amap.api.maps.model.CircleOptions)1 LatLng (com.amap.api.maps.model.LatLng)1 MarkerOptions (com.amap.api.maps.model.MarkerOptions)1 SuggestionCity (com.amap.api.services.core.SuggestionCity)1