Search in sources :

Example 1 with SuggestionCity

use of com.amap.api.services.core.SuggestionCity in project ride-read-android by Ride-Read.

the class MapFragment method onPoiSearched.

@Override
public void onPoiSearched(PoiResult poiResult, int i) {
    if (null == poiResult)
        return;
    List<PoiItem> poiList = poiResult.getPois();
    if (!ListUtils.isEmpty(poiList)) {
        PoiItem firstResult = poiList.get(0);
        LatLonPoint resultPoint = firstResult.getLatLonPoint();
        LatLng resultLatLng = new LatLng(resultPoint.getLatitude(), resultPoint.getLongitude());
        mAMap.moveCamera(CameraUpdateFactory.changeLatLng(resultLatLng));
        ToastUtils.show("搜索结果为:" + firstResult.getAdName());
    } else {
        List<SuggestionCity> suggestionCitys = poiResult.getSearchSuggestionCitys();
        if (!ListUtils.isEmpty(suggestionCitys)) {
            ToastUtils.show("搜索失败,建议搜索填写:" + suggestionCitys.get(0).getCityName());
        }
    }
}
Also used : SuggestionCity(com.amap.api.services.core.SuggestionCity) PoiItem(com.amap.api.services.core.PoiItem) LatLng(com.amap.api.maps.model.LatLng) LatLonPoint(com.amap.api.services.core.LatLonPoint)

Aggregations

LatLng (com.amap.api.maps.model.LatLng)1 LatLonPoint (com.amap.api.services.core.LatLonPoint)1 PoiItem (com.amap.api.services.core.PoiItem)1 SuggestionCity (com.amap.api.services.core.SuggestionCity)1