com.amap.api.services.core.SuggestionCity Java Examples

The following examples show how to use com.amap.api.services.core.SuggestionCity. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PoiKeywordSearchActivity.java    From TraceByAmap with MIT License 5 votes vote down vote up
/**

	 * POI信息查询回调方法
	 */
	@Override
	public void onPoiSearched(PoiResult result, int rCode) {
		dissmissProgressDialog();// 隐藏对话框
		if (rCode == AMapException.CODE_AMAP_SUCCESS) {
			if (result != null && result.getQuery() != null) {// 搜索poi的结果
				if (result.getQuery().equals(query)) {// 是否是同一条
					poiResult = result;
					// 取得搜索到的poiitems有多少页
					List<PoiItem> poiItems = poiResult.getPois();// 取得第一页的poiitem数据,页数从数字0开始
					List<SuggestionCity> suggestionCities = poiResult
							.getSearchSuggestionCitys();// 当搜索不到poiitem数据时,会返回含有搜索关键字的城市信息

					if (poiItems != null && poiItems.size() > 0) {
						aMap.clear();// 清理之前的图标
						PoiOverlay poiOverlay = new PoiOverlay(aMap, poiItems);
						poiOverlay.removeFromMap();
						poiOverlay.addToMap();
						poiOverlay.zoomToSpan();
					} else if (suggestionCities != null
							&& suggestionCities.size() > 0) {
						showSuggestCity(suggestionCities);
					} else {
						ToastUtil.show(PoiKeywordSearchActivity.this,
								R.string.no_result);
					}
				}
			} else {
				ToastUtil.show(PoiKeywordSearchActivity.this,
						R.string.no_result);
			}
		} else {
			ToastUtil.showerror(this, rCode);
		}

	}
 
Example #2
Source File: SearchMapsInteractorImpl.java    From Maps with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onPoiSearched(PoiResult result, int rCode) {
    if (rCode == 0) {
        if (result != null && result.getQuery() != null) {// 搜索poi的结果
            if (result.getQuery().equals(query)) {// 是否是同一条
                // 取得搜索到的poiitems有多少页
                List<PoiItem> poiItems = result.getPois();// 取得第一页的poiitem数据,页数从数字0开始
                List<SuggestionCity> suggestionCities = result
                        .getSearchSuggestionCitys();// 当搜索不到poiitem数据时,会返回含有搜索关键字的城市信息

                if (mOnPoiSearchFinishedListener != null){
                    mOnPoiSearchFinishedListener.onPoiSearchFinished(poiItems);
                }
            }
        } else {
            ToastUtil.show(mContext,
                    R.string.no_result);
        }
    } else if (rCode == 27) {
        ToastUtil.show(mContext,
                R.string.error_network);
    } else if (rCode == 32) {
        ToastUtil.show(mContext, R.string.error_key);
    } else {
        ToastUtil.show(mContext, mContext.getString(R.string.error_other) + rCode);
    }
}
 
Example #3
Source File: SearchActivity.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
@Override
public void onClickCity(SuggestionCity city) {
    mPage = 0;
    mCity = city.getCityName();
    mTextCity.setText(mCity);
    search(city.getCityName(), mEditSearch.getText().toString().trim());
}
 
Example #4
Source File: SearchActivity.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
@Override
public void setSuggestCityList(List<SuggestionCity> cities) {
    mRecycleCity.setVisibility(View.VISIBLE);
    mGridHot.setVisibility(View.GONE);
    if (null == mSearchSuggtionCityAdapter) {
        mSearchSuggtionCityAdapter = new SearchSuggtionCityAdapter(this, cities);
        mSearchSuggtionCityAdapter.setOnClickCityListener(this);
        mRecycleCity.setAdapter(mSearchSuggtionCityAdapter);
    } else {
        mSearchSuggtionCityAdapter.setList(cities);
        mSearchSuggtionCityAdapter.notifyDataSetChanged();
    }

}
 
Example #5
Source File: SearchSuggtionCityAdapter.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
public void setList(List<SuggestionCity> list) {
    if (this.list == null) {
        this.list = list;
    } else {
        this.list.clear();
        if (null != list) {
            this.list.addAll(list);
        }
    }
}
 
Example #6
Source File: SearchActivity.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onClickCity(SuggestionCity city) {
    mPage = 0;
    mCity = city.getCityName();
    mTextCity.setText(mCity);
    search(city.getCityName(), mEditSearch.getText().toString().trim());
}
 
Example #7
Source File: SearchActivity.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setSuggestCityList(List<SuggestionCity> cities) {
    mRecycleCity.setVisibility(View.VISIBLE);
    mGridHot.setVisibility(View.GONE);
    if (null == mSearchSuggtionCityAdapter) {
        mSearchSuggtionCityAdapter = new SearchSuggtionCityAdapter(this, cities);
        mSearchSuggtionCityAdapter.setOnClickCityListener(this);
        mRecycleCity.setAdapter(mSearchSuggtionCityAdapter);
    } else {
        mSearchSuggtionCityAdapter.setList(cities);
        mSearchSuggtionCityAdapter.notifyDataSetChanged();
    }

}
 
Example #8
Source File: SearchSuggtionCityAdapter.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
public void setList(List<SuggestionCity> list) {
    if (this.list == null) {
        this.list = list;
    } else {
        this.list.clear();
        if (null != list) {
            this.list.addAll(list);
        }
    }
}
 
Example #9
Source File: PoiKeywordSearchActivity.java    From TraceByAmap with MIT License 5 votes vote down vote up
/**
 * poi没有搜索到数据,返回一些推荐城市的信息
 */
private void showSuggestCity(List<SuggestionCity> cities) {
	String infomation = "推荐城市\n";
	for (int i = 0; i < cities.size(); i++) {
		infomation += "城市名称:" + cities.get(i).getCityName() + "城市区号:"
				+ cities.get(i).getCityCode() + "城市编码:"
				+ cities.get(i).getAdCode() + "\n";
	}
	ToastUtil.show(PoiKeywordSearchActivity.this, infomation);

}
 
Example #10
Source File: PoiAroundSearchActivity.java    From TraceByAmap with MIT License 5 votes vote down vote up
/**
 * poi没有搜索到数据,返回一些推荐城市的信息
 */
private void showSuggestCity(List<SuggestionCity> cities) {
	String infomation = "推荐城市\n";
	for (int i = 0; i < cities.size(); i++) {
		infomation += "城市名称:" + cities.get(i).getCityName() + "城市区号:"
				+ cities.get(i).getCityCode() + "城市编码:"
				+ cities.get(i).getAdCode() + "\n";
	}
	ToastUtil.show(this, infomation);

}
 
Example #11
Source File: FindMapAroundAty.java    From myapplication with Apache License 2.0 4 votes vote down vote up
@Override
    public void onPoiSearched(PoiResult result, int rcode) {
        if (rcode == 1000) {
            if (result != null && result.getQuery() != null) {// 搜索poi的结果
                if (result.getQuery().equals(query)) {// 是否是同一条
                    poiResult = result;
                    poiItems = poiResult.getPois();// 取得第一页的poiitem数据,页数从数字0开始
                    List<SuggestionCity> suggestionCities = poiResult
                            .getSearchSuggestionCitys();// 当搜索不到poiitem数据时,会返回含有搜索关键字的城市信息
                    if (poiItems != null && poiItems.size() > 0) {
                        //清除POI信息显示
//                        whetherToShowDetailInfo(false);
                        //并还原点击marker样式
                        if (mlastMarker != null) {
                            resetlastmarker();
                        }
                        //清理之前搜索结果的marker
                        if (poiOverlay != null) {
                            poiOverlay.removeFromMap();
                        }
                        aMap.clear();
                        poiOverlay = new MyPoiOverlay(aMap, poiItems);
                        poiOverlay.addToMap();
                        poiOverlay.zoomToSpan();

                        aMap.addMarker(new MarkerOptions()
//                                .anchor(0.5f, 0.5f)
                                .icon(BitmapDescriptorFactory
                                        .fromBitmap(BitmapFactory.decodeResource(
                                                getResources(), R.drawable.point4)))
                                .position(new LatLng(lp.getLatitude(), lp.getLongitude())));

                        aMap.addCircle(new CircleOptions()
                                .center(new LatLng(lp.getLatitude(),
                                        lp.getLongitude())).radius(5000)
                                .strokeColor(Color.BLUE)
                                .fillColor(Color.argb(50, 1, 1, 1))
                                .strokeWidth(2));
//                    } else if (suggestionCities != null
//                            && suggestionCities.size() > 0) {
//                        showSuggestCity(suggestionCities);
                    } else {
                        Toast.makeText(FindMapAroundAty.this,
                                "No Result!", Toast.LENGTH_SHORT).show();
                    }
                }
            } else {
                Toast.makeText(FindMapAroundAty.this,
                        "No Result!", Toast.LENGTH_SHORT).show();
            }
        }

    }
 
Example #12
Source File: SearchSuggtionCityAdapter.java    From BmapLite with GNU General Public License v3.0 4 votes vote down vote up
public List<SuggestionCity> getList() {
    return list;
}
 
Example #13
Source File: PoiAroundSearchActivity.java    From TraceByAmap with MIT License 4 votes vote down vote up
@Override
public void onPoiSearched(PoiResult result, int rcode) {
	if (rcode == AMapException.CODE_AMAP_SUCCESS) {
		if (result != null && result.getQuery() != null) {// 搜索poi的结果
			if (result.getQuery().equals(query)) {// 是否是同一条
				poiResult = result;
				poiItems = poiResult.getPois();// 取得第一页的poiitem数据,页数从数字0开始
				List<SuggestionCity> suggestionCities = poiResult
						.getSearchSuggestionCitys();// 当搜索不到poiitem数据时,会返回含有搜索关键字的城市信息
				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(5000)
					.strokeColor(Color.BLUE)
					.fillColor(Color.argb(50, 1, 1, 1))
					.strokeWidth(2));

				} else if (suggestionCities != null
						&& suggestionCities.size() > 0) {
					showSuggestCity(suggestionCities);
				} else {
					ToastUtil.show(PoiAroundSearchActivity.this,
							R.string.no_result);
				}
			}
		} else {
			ToastUtil
					.show(PoiAroundSearchActivity.this, R.string.no_result);
		}
	} else  {
		ToastUtil.showerror(this.getApplicationContext(), rcode);
	}
}
 
Example #14
Source File: SearchSuggtionCityAdapter.java    From BmapLite with GNU General Public License v3.0 4 votes vote down vote up
public SearchSuggtionCityAdapter(Context context, List<SuggestionCity> list) {
    this.context = context;
    this.list = list;
}
 
Example #15
Source File: SearchSuggtionCityAdapter.java    From BmapLite with Apache License 2.0 4 votes vote down vote up
public SearchSuggtionCityAdapter(Context context, List<SuggestionCity> list) {
    this.context = context;
    this.list = list;
}
 
Example #16
Source File: SearchSuggtionCityAdapter.java    From BmapLite with Apache License 2.0 4 votes vote down vote up
public List<SuggestionCity> getList() {
    return list;
}
 
Example #17
Source File: BaiduMapFragment.java    From BmapLite with Apache License 2.0 2 votes vote down vote up
@Override
public void setSuggestCityList(List<SuggestionCity> cities) {

}
 
Example #18
Source File: RouteBaiduBusActivity.java    From BmapLite with Apache License 2.0 2 votes vote down vote up
@Override
public void setSuggestCityList(List<SuggestionCity> cities) {

}
 
Example #19
Source File: RouteAmapBusActivity.java    From BmapLite with Apache License 2.0 2 votes vote down vote up
@Override
public void setSuggestCityList(List<SuggestionCity> cities) {

}
 
Example #20
Source File: AmapSelectPoiFragment.java    From BmapLite with GNU General Public License v3.0 2 votes vote down vote up
@Override
public void setSuggestCityList(List<SuggestionCity> cities) {

}
 
Example #21
Source File: AmapFragment.java    From BmapLite with Apache License 2.0 2 votes vote down vote up
@Override
public void setSuggestCityList(List<SuggestionCity> cities) {

}
 
Example #22
Source File: AmapRouteFragment.java    From BmapLite with Apache License 2.0 2 votes vote down vote up
@Override
public void setSuggestCityList(List<SuggestionCity> cities) {

}
 
Example #23
Source File: BaiduMapSelectPoiFragment.java    From BmapLite with Apache License 2.0 2 votes vote down vote up
@Override
public void setSuggestCityList(List<SuggestionCity> cities) {

}
 
Example #24
Source File: BaiduMapSelectPoiFragment.java    From BmapLite with GNU General Public License v3.0 2 votes vote down vote up
@Override
public void setSuggestCityList(List<SuggestionCity> cities) {

}
 
Example #25
Source File: BaiduMapRouteFragment.java    From BmapLite with Apache License 2.0 2 votes vote down vote up
@Override
public void setSuggestCityList(List<SuggestionCity> cities) {

}
 
Example #26
Source File: AmapBusFragment.java    From BmapLite with Apache License 2.0 2 votes vote down vote up
@Override
public void setSuggestCityList(List<SuggestionCity> cities) {

}
 
Example #27
Source File: AmapSelectPoiFragment.java    From BmapLite with Apache License 2.0 2 votes vote down vote up
@Override
public void setSuggestCityList(List<SuggestionCity> cities) {

}
 
Example #28
Source File: RouteBaiduBusActivity.java    From BmapLite with GNU General Public License v3.0 2 votes vote down vote up
@Override
public void setSuggestCityList(List<SuggestionCity> cities) {

}
 
Example #29
Source File: AmapBusFragment.java    From BmapLite with GNU General Public License v3.0 2 votes vote down vote up
@Override
public void setSuggestCityList(List<SuggestionCity> cities) {

}
 
Example #30
Source File: BaiduMapRouteFragment.java    From BmapLite with GNU General Public License v3.0 2 votes vote down vote up
@Override
public void setSuggestCityList(List<SuggestionCity> cities) {

}