com.amap.api.services.poisearch.PoiResult Java Examples

The following examples show how to use com.amap.api.services.poisearch.PoiResult. 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: LocationActivity.java    From xmpp with Apache License 2.0 6 votes vote down vote up
@Override
public void onPoiSearched(PoiResult poiResult, int i) {

    list = poiResult.getPois();

    if(adapter==null){
        adapter= new MyAdapter(list);
        mlist.setAdapter(adapter);
    }else{
        adapter.setList(list);
    }


   // Log.i("xxxxxxxxxx", list.toString());

    //  mlist.setAdapter(new MyAdapter(list));
}
 
Example #2
Source File: PoiSearchTask.java    From Android_UsingCar_Example with Apache License 2.0 6 votes vote down vote up
@Override
public void onPoiSearched(PoiResult poiResult, int resultCode) {
	if (resultCode == 0 && poiResult != null) {
		ArrayList<PoiItem> pois=poiResult.getPois();
		if(pois==null){
			return;
		}
		List<PositionEntity>entities=new ArrayList<PositionEntity>();
		for(PoiItem poiItem:pois){
			PositionEntity entity=new PositionEntity(poiItem.getLatLonPoint().getLatitude(),
					poiItem.getLatLonPoint().getLongitude(),poiItem.getTitle()
					,poiItem.getCityName());
			entities.add(entity);
		}
		mRecommandAdapter.setPositionEntities(entities);
		mRecommandAdapter.notifyDataSetChanged();
	}
	//TODO 可以根据app自身需求对查询错误情况进行相应的提示或者逻辑处理
}
 
Example #3
Source File: MapActivity.java    From xposed-rimet with Apache License 2.0 5 votes vote down vote up
@Override
public void onPoiSearched(PoiResult poiResult, int resultCode) {

    if (resultCode != AMapException.CODE_AMAP_SUCCESS) {
        Alog.e("搜索出错了");
        return;
    }

    if (poiResult == null || poiResult.getQuery() == null) {
        Alog.e("没有搜索到结果");
        ToastUtil.show("没有搜索结果!");
        return;
    }

    // 获取搜索的结果
    List<PoiItem> poiItems = poiResult.getPois();

    ViewUtil.setVisibility(mTvPrompt,
            CollectionUtil.isEmpty(poiItems) ? View.VISIBLE : View.GONE);

    mSearchResultAdapter.setSelectedPosition(0);
    mSearchResultAdapter.setItems(poiItems);
    mSearchResultAdapter.setBeginAddress(null);
    mSearchResultAdapter.notifyDataSetChanged();

    if (CollectionUtil.isNotEmpty(poiItems)) {
        // 移动到第一个位置
        PoiItem poiItem = mSearchResultAdapter.getItem(0);
        LatLng latLng = MapUtil.newLatLng(poiItem.getLatLonPoint());
        isItemClickAction = true;
        mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 16f));
    }
}
 
Example #4
Source File: SubPoiSearchActivity.java    From TraceByAmap with MIT License 5 votes vote down vote up
@Override
  public void onPoiSearched(PoiResult result, int rCode) {
      if (rCode == AMapException.CODE_AMAP_SUCCESS) {
          if (result != null ) {
              List<PoiItem> poiItems = result.getPois();
              mpoiadapter=new PoiListAdapter(this, poiItems);
              mPoiSearchList.setAdapter(mpoiadapter);                    
          }                      
      } else {
      	ToastUtil.showerror(this, rCode);
}       
  }
 
Example #5
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 #6
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 #7
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 #8
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 #9
Source File: PoiIDSearchActivity.java    From TraceByAmap with MIT License 2 votes vote down vote up
@Override
public void onPoiSearched(PoiResult result, int rcode) {
	
}