com.baidu.mapapi.search.poi.PoiResult Java Examples

The following examples show how to use com.baidu.mapapi.search.poi.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: SearchInteracter.java    From BmapLite with GNU General Public License v3.0 6 votes vote down vote up
private void getPoiDetailsByBaidu(String uid, OnBaseListener listener) {
    mPoiSearchBaidu.setOnGetPoiSearchResultListener(new OnGetPoiSearchResultListener() {
        @Override
        public void onGetPoiResult(PoiResult poiResult) {
        }

        @Override
        public void onGetPoiDetailResult(PoiDetailResult poiDetailResult) {
        }

        @Override
        public void onGetPoiIndoorResult(PoiIndoorResult poiIndoorResult) {

        }
    });
    mPoiSearchBaidu.searchPoiDetail(new PoiDetailSearchOption().poiUid(uid));
}
 
Example #2
Source File: LocationActivity.java    From imsdk-android with MIT License 6 votes vote down vote up
@Override
public void onGetPoiResult(PoiResult poiResult) {
    if (getPoiResultCount<poiNum){
        getPoiResultCount++;
    }else {
        getPoiResultCount=1;
        receiveAll=true;
    }
    if (poiResult == null || poiResult.getAllPoi() == null) {
        return;
    }
    if (poiResult.getAllPoi().size() > 0) {
        List<PoiInfo> info = poiResult.getAllPoi();
        infoss.addAll(info);
        adapter.addPoiInfo(infoss);
        adapter.notifyDataSetChanged();
        infoss.clear();
        list.setSelection(firstVisible);
    }
    if (receiveAll){
        refresh = true;
        receiveAll=false;
    }else {
        refresh=false;
    }
}
 
Example #3
Source File: SearchInteracter.java    From BmapLite with Apache License 2.0 6 votes vote down vote up
private void getPoiDetailsByBaidu(String uid, OnBaseListener listener) {
    mPoiSearchBaidu.setOnGetPoiSearchResultListener(new OnGetPoiSearchResultListener() {
        @Override
        public void onGetPoiResult(PoiResult poiResult) {
        }

        @Override
        public void onGetPoiDetailResult(PoiDetailResult poiDetailResult) {
        }

        @Override
        public void onGetPoiIndoorResult(PoiIndoorResult poiIndoorResult) {

        }
    });
    mPoiSearchBaidu.searchPoiDetail(new PoiDetailSearchOption().poiUid(uid));
}
 
Example #4
Source File: MainActivity.java    From MoveMapLocation with Apache License 2.0 5 votes vote down vote up
/**
 * 输入框监听---输入完毕
 *
 * @param s
 */
@Override
public void afterTextChanged(Editable s) {
    if (s.length() == 0 || "".equals(s.toString())) {
        searchPois.setVisibility(View.GONE);
    } else {
        //创建PoiSearch实例
        PoiSearch poiSearch = PoiSearch.newInstance();
        //城市内检索
        PoiCitySearchOption poiCitySearchOption = new PoiCitySearchOption();
        //关键字
        poiCitySearchOption.keyword(s.toString());
        //城市
        poiCitySearchOption.city(city);
        //设置每页容量,默认为每页10条
        poiCitySearchOption.pageCapacity(10);
        //分页编号
        poiCitySearchOption.pageNum(1);
        poiSearch.searchInCity(poiCitySearchOption);
        //设置poi检索监听者
        poiSearch.setOnGetPoiSearchResultListener(new OnGetPoiSearchResultListener() {
            //poi 查询结果回调
            @Override
            public void onGetPoiResult(PoiResult poiResult) {
                List<PoiInfo> poiInfos = poiResult.getAllPoi();
                PoiSearchAdapter poiSearchAdapter = new PoiSearchAdapter(MainActivity.this, poiInfos, locationLatLng);
                searchPois.setVisibility(View.VISIBLE);
                searchPois.setAdapter(poiSearchAdapter);
            }

            //poi 详情查询结果回调
            @Override
            public void onGetPoiDetailResult(PoiDetailResult poiDetailResult) {
            }
        });
    }
}
 
Example #5
Source File: BusActivity.java    From BaiduMap-TrafficAssistant with MIT License 5 votes vote down vote up
/**
 * 以下是执行searchButtonProcess开始按钮后,返回的POI数据。
 * 
 */
@Override
public void onGetPoiResult(PoiResult result) {

	if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
		Toast.makeText(context, "抱歉,未找到结果", Toast.LENGTH_LONG).show();
		return;
	}
	// 遍历所有poi,找到类型为公交线路的poi
	busLineIDList.clear();

	/**
	 * 
	 * 一般以下for循环执行2次,因为同一条公交线路有正反2个方向;
	 */
	for (PoiInfo poi : result.getAllPoi()) {
		if (poi.type == PoiInfo.POITYPE.BUS_LINE
				|| poi.type == PoiInfo.POITYPE.SUBWAY_LINE) {
			busLineIDList.add(poi.uid);// 就把该poi信息存储到公交路线列表中;busLineIDList中存储的是公交线路的ID值;
			Log.i("TAG", "城市:" + poi.city + ";线路:" + poi.name);
			city_return = poi.city;
		}
	}
	// 即要把原来所有的数据清空;
	SearchNextBusline(null);
	route = null;
}
 
Example #6
Source File: FakeWeiBoActivity.java    From AndroidAnimationExercise with Apache License 2.0 5 votes vote down vote up
@Subscribe
public void onPoiResultEvent(PoiResult poiResult) {

    if (poiResult != null && poiResult.getAllPoi() != null && poiResult.getAllPoi().size() > 0) {
        poiInfos = poiResult.getAllPoi();
        name.setText(poiInfos.get(0).name);
        address.setText(poiInfos.get(0).address);
        phoneNum.setText(poiInfos.get(0).phoneNum);

        index = 1;

        if (refreshView.getVisibility() == View.GONE) {
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    radar.stopAnim();
                    radar.setVisibility(View.GONE);
                    refreshView.setVisibility(View.VISIBLE);
                    cardShowAnim.start();
                }
            }, 3000);
        }
    } else {
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                radar.stopAnim();
                radar.setVisibility(View.GONE);
                refreshView.setVisibility(View.VISIBLE);
            }
        }, 2000);

    }


}
 
Example #7
Source File: NaviConfirmPointActivity.java    From AssistantBySDK with Apache License 2.0 5 votes vote down vote up
/**
 * poi搜索结果回调
 **/
@Override
public void onGetPoiResult(PoiResult result) {
    mAncpPoiListBox.setRefreshing(false);
    if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
        //Toast.makeText(this, "搜索发生错误:" + result.error, Toast.LENGTH_LONG).show();
        Snackbar.make(mAncpPoiDetailBox, NaviConfirmPointActivity.this.getResources().getString(R.string.navi_no_result), Snackbar.LENGTH_SHORT).show();

        return;
    }
    if (result.error == SearchResult.ERRORNO.NO_ERROR) {
        //创建PoiOverlay,添加搜索结果地点图层
        if (poiOverlay == null) {
            poiOverlay = new ConfirmPoiOverlay(baiduMap);
            baiduMap.setOnMarkerClickListener(poiOverlay);
        } else {
            poiOverlay.removeFromMap();
        }
        if (poiOverlay instanceof PoiOverlay) {
            ((PoiOverlay) poiOverlay).setData(result);
        }
        poiOverlay.addToMap();

        totalPageNum = result.getTotalPageNum();
        mAncpPoiBox.getLayoutParams().height = ScreenUtil.getInstance().getHeightPixels() / 2;
        list.clear();
        /* 填充数据 */
        list.addAll(result.getAllPoi());
        setAlist(list);
        /* 刷新视图 */
        mListAdapter.notifyDataSetChanged();
        mPagerAdapter.notifyDataSetChanged();
        if (firstPoiSearch) {
            firstPoiSearch = false;
            mAncpPoiBox.setVisibility(View.VISIBLE);
        }
        setPoiPosition();
    }
}
 
Example #8
Source File: SetFavoriteMapActivity.java    From AssistantBySDK with Apache License 2.0 5 votes vote down vote up
/**
 * Poi检索结果回调
 **/
@Override
public void onGetPoiResult(PoiResult result) {
    mAmosfPoiListBox.setRefreshing(false);
    if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
        // Toast.makeText(this, "搜索发生错误:" + result.error, Toast.LENGTH_LONG).show();
        Snackbar.make(mAmosfPoiList, SetFavoriteMapActivity.this.getResources().getString(R.string.navi_no_result), Snackbar.LENGTH_SHORT).show();
        mAmosfSearchEdit.setSearchCompletedState();
        return;
    }
    if (result.error == SearchResult.ERRORNO.NO_ERROR) {
        if (poiOverlay != null) {
            poiOverlay.removeFromMap();
        }
        if (poiOverlay == null || !(poiOverlay instanceof ConfirmPoiOverlay)) {
            poiOverlay = new ConfirmPoiOverlay(baiduMap);
            baiduMap.setOnMarkerClickListener(poiOverlay);
        }

        ((ConfirmPoiOverlay) poiOverlay).setData(result);
        poiOverlay.addToMap();

        totalPageNum = result.getTotalPageNum();
        /* 设置检索结果列表高度(手机屏幕的一半) */
        mAmosfPoiBox.getLayoutParams().height = ScreenUtil.getInstance().getHeightPixels() / 2;
        list.clear();
        list.addAll(result.getAllPoi());
        setAlist(list);
        mListAdapter.notifyDataSetChanged();
        mPagerAdapter.notifyDataSetChanged();
        mAmosfPoiDetailBox.setVisibility(View.GONE);
        mAmosfSinglePoiDetailBox.setVisibility(View.GONE);
        mAmosfPoiBox.setVisibility(View.VISIBLE);
        setPoiPosition();
        return;
    }
}
 
Example #9
Source File: MainActivity.java    From BaiDuMapSelectDemo with Apache License 2.0 5 votes vote down vote up
/**
 * 获取POI搜索结果,包括searchInCity,searchNearby,searchInBound返回的搜索结果
 *
 * @param poiResult Poi检索结果,包括城市检索,周边检索,区域检索
 */
@Override
public void onGetPoiResult(PoiResult poiResult) {
    if (poiInfoListForSearch != null) {
        poiInfoListForSearch.clear();
    }
    if (poiResult == null || poiResult.error == SearchResult.ERRORNO.RESULT_NOT_FOUND) {
        Toast.makeText(mContext, "未找到结果", Toast.LENGTH_LONG).show();
        initPoiSearchListView();
        return;
    }

    if (poiResult.error == SearchResult.ERRORNO.NO_ERROR) {
        poiInfoListForSearch = poiResult.getAllPoi();
        showSeachView();
        initPoiSearchListView();
        return;
    }

    if (poiResult.error == SearchResult.ERRORNO.AMBIGUOUS_KEYWORD) {
        // 当输入关键字在本市没有找到,但在其他城市找到时,返回包含该关键字信息的城市列表
        String strInfo = "在";

        for (CityInfo cityInfo : poiResult.getSuggestCityList()) {
            strInfo += cityInfo.city;
            strInfo += ",";
        }

        strInfo += "找到结果";
        Toast.makeText(mContext, strInfo, Toast.LENGTH_LONG).show();
    }
}
 
Example #10
Source File: LocationDelegate.java    From FastWaiMai with MIT License 5 votes vote down vote up
@Override
public void onGetPoiResult(PoiResult poiResult) {
	if (poiInfoListForSearch != null) {
		poiInfoListForSearch.clear();
	}
	if (poiResult == null || poiResult.error == SearchResult.ERRORNO.RESULT_NOT_FOUND) {
		Toast.makeText(getContext(), "未找到结果", Toast.LENGTH_LONG).show();
		//initPoiSearchListView();
		return;
	}

	if (poiResult.error == SearchResult.ERRORNO.NO_ERROR) {
		poiInfoListForSearch = poiResult.getAllPoi();
		//showSeachView();
		initPoiSearchListView();
		return;
	}

	if (poiResult.error == SearchResult.ERRORNO.AMBIGUOUS_KEYWORD) {
		// 当输入关键字在本市没有找到,但在其他城市找到时,返回包含该关键字信息的城市列表
		String strInfo = "在";

		for (CityInfo cityInfo : poiResult.getSuggestCityList()) {
			strInfo += cityInfo.city;
			strInfo += ",";
		}

		strInfo += "找到结果";
		Toast.makeText(getContext(), strInfo, Toast.LENGTH_LONG).show();
	}
}
 
Example #11
Source File: AddressEditDelegate.java    From FastWaiMai with MIT License 5 votes vote down vote up
/**
 * 获取POI搜索结果,包括searchInCity,searchNearby,searchInBound返回的搜索结果
 *
 * @param poiResult Poi检索结果,包括城市检索,周边检索,区域检索
 */
@Override
public void onGetPoiResult(PoiResult poiResult) {
	if (poiInfoListForSearch != null) {
		poiInfoListForSearch.clear();
	}
	if (poiResult == null || poiResult.error == SearchResult.ERRORNO.RESULT_NOT_FOUND) {
		Toast.makeText(getContext(), "未找到结果", Toast.LENGTH_LONG).show();
		initPoiSearchListView();
		return;
	}

	if (poiResult.error == SearchResult.ERRORNO.NO_ERROR) {
		poiInfoListForSearch = poiResult.getAllPoi();
		showSeachView();
		initPoiSearchListView();
		return;
	}

	if (poiResult.error == SearchResult.ERRORNO.AMBIGUOUS_KEYWORD) {
		// 当输入关键字在本市没有找到,但在其他城市找到时,返回包含该关键字信息的城市列表
		String strInfo = "在";

		for (CityInfo cityInfo : poiResult.getSuggestCityList()) {
			strInfo += cityInfo.city;
			strInfo += ",";
		}

		strInfo += "找到结果";
		Toast.makeText(getContext(), strInfo, Toast.LENGTH_LONG).show();
	}
}
 
Example #12
Source File: SearchInteracter.java    From BmapLite with Apache License 2.0 4 votes vote down vote up
private void searchPoiNearbyByBaidu(MyPoiModel nearby, String keyword, int page, final OnSearchResultListener listener) {
    mPoiSearchBaidu.setOnGetPoiSearchResultListener(new OnGetPoiSearchResultListener() {
        @Override
        public void onGetPoiResult(PoiResult poiResult) {
            if (null != poiResult && null != poiResult.getAllPoi() && !poiResult.getAllPoi().isEmpty()) {
                List<MyPoiModel> list = new ArrayList<>();

                for (PoiInfo poi : poiResult.getAllPoi()) {
                    MyPoiModel myPoi = new MyPoiModel(mType);
                    myPoi.setCity(poi.city);
                    myPoi.setUid(poi.uid);
                    myPoi.setAddress(poi.address);
                    myPoi.setName(poi.name);
                    myPoi.setInfo(poi.phoneNum);
                    if (null != poi.location) {
                        myPoi.setLatitude(poi.location.latitude);
                        myPoi.setLongitude(poi.location.longitude);
                    }
                    if (poi.type == PoiInfo.POITYPE.BUS_LINE) {
                        myPoi.setTypePoi(TypePoi.BUS_LINE);
                    } else if (poi.type == PoiInfo.POITYPE.SUBWAY_LINE) {
                        myPoi.setTypePoi(TypePoi.SUBWAY_LINE);
                    } else if (poi.type == PoiInfo.POITYPE.BUS_STATION) {
                        myPoi.setTypePoi(TypePoi.BUS_STATION);
                    } else if (poi.type == PoiInfo.POITYPE.SUBWAY_STATION) {
                        myPoi.setTypePoi(TypePoi.SUBWAY_STATION);
                    } else if (poi.type == PoiInfo.POITYPE.POINT) {
                        myPoi.setTypePoi(TypePoi.POINT);
                    }

                    list.add(myPoi);
                }
                listener.setSearchResult(list);
                listener.onShowData("search");
            } else {
                listener.onNoData("search");
            }
        }

        @Override
        public void onGetPoiDetailResult(PoiDetailResult poiDetailResult) {

        }

        @Override
        public void onGetPoiIndoorResult(PoiIndoorResult poiIndoorResult) {

        }
    });

    mPoiSearchBaidu.searchNearby(new PoiNearbySearchOption().location(new LatLng(nearby.getLatitude(), nearby.getLongitude())).keyword(keyword).radius(20000).sortType(PoiSortType.distance_from_near_to_far).pageNum(page).pageCapacity(20));
}
 
Example #13
Source File: SearchInteracter.java    From BmapLite with Apache License 2.0 4 votes vote down vote up
private void searchPoiInCityByAmap(String keyword, String city, int page, final OnSearchResultListener listener) {
    PoiSearch.Query query = new PoiSearch.Query(keyword, null, city);
    query.setPageSize(20);
    query.setPageNum(page);

    PoiSearch poiSearchAmap = new PoiSearch(mContext, query);
    poiSearchAmap.setOnPoiSearchListener(new PoiSearch.OnPoiSearchListener() {
        @Override
        public void onPoiSearched(com.amap.api.services.poisearch.PoiResult poiResult, int code) {
            if (null != poiResult && null != poiResult.getPois() && !poiResult.getPois().isEmpty()) {
                List<MyPoiModel> list = new ArrayList<>();

                for (PoiItem poi : poiResult.getPois()) {
                    MyPoiModel myPoi = new MyPoiModel(mType);
                    myPoi.setCity(poi.getCityName());
                    myPoi.setUid(poi.getPoiId());
                    myPoi.setName(poi.getTitle());
                    myPoi.setAddress(poi.getSnippet());
                    myPoi.setInfo(poi.getTel());
                    myPoi.setLatitude(poi.getLatLonPoint().getLatitude());
                    myPoi.setLongitude(poi.getLatLonPoint().getLongitude());
                    myPoi.setTypePoi(TypePoi.POINT);
                    list.add(myPoi);
                }
                listener.setSearchResult(list);
                listener.onShowData("search");
            } else {
                listener.onNoData("search");
            }
            if (null != poiResult && null != poiResult.getSearchSuggestionCitys() && !poiResult.getSearchSuggestionCitys().isEmpty()) {
                listener.setSuggestCityList(poiResult.getSearchSuggestionCitys());
            }else {
                listener.onNoData("city");
            }
        }

        @Override
        public void onPoiItemSearched(PoiItem poiItem, int i) {

        }
    });
    poiSearchAmap.searchPOIAsyn();
}
 
Example #14
Source File: SearchInteracter.java    From BmapLite with Apache License 2.0 4 votes vote down vote up
private void searchPoiNearbyByAmap(MyPoiModel nearby, String keyword, int page, final OnSearchResultListener listener) {
    PoiSearch.Query query = new PoiSearch.Query(keyword, "", nearby.getCity());
    query.setPageSize(20);
    query.setPageNum(page);

    PoiSearch.SearchBound bound = new PoiSearch.SearchBound(new LatLonPoint(nearby.getLatitude(),
            nearby.getLongitude()), 20000);

    PoiSearch poiSearchAmap = new PoiSearch(mContext, query);
    poiSearchAmap.setBound(bound);
    poiSearchAmap.setOnPoiSearchListener(new PoiSearch.OnPoiSearchListener() {
        @Override
        public void onPoiSearched(com.amap.api.services.poisearch.PoiResult poiResult, int code) {
            if (1000 == code) {
                if (null != poiResult && null != poiResult.getPois() && !poiResult.getPois().isEmpty()) {
                    List<MyPoiModel> list = new ArrayList<>();

                    for (PoiItem poi : poiResult.getPois()) {
                        MyPoiModel myPoi = new MyPoiModel(mType);
                        myPoi.setCity(poi.getCityName());
                        myPoi.setUid(poi.getPoiId());
                        myPoi.setName(poi.getTitle());
                        myPoi.setInfo(poi.getTel());
                        myPoi.setAddress(poi.getSnippet());
                        myPoi.setLatitude(poi.getLatLonPoint().getLatitude());
                        myPoi.setLongitude(poi.getLatLonPoint().getLongitude());
                        myPoi.setTypePoi(TypePoi.POINT);
                        list.add(myPoi);
                    }
                    listener.setSearchResult(list);
                    listener.onShowData("search");
                } else {
                    listener.onNoData("search");
                }
            } else {
                listener.onNoData("search");
            }
        }

        @Override
        public void onPoiItemSearched(PoiItem poiItem, int i) {

        }
    });
    poiSearchAmap.searchPOIAsyn();
}
 
Example #15
Source File: TrafficShowPresenter.java    From AssistantBySDK with Apache License 2.0 4 votes vote down vote up
@Override
public void onGetPoiResult(PoiResult result) {
    Log.e(TAG, "onGetPoiResult>>" + result.error);
    mTrafficShowView.setRefreshLayout(false);
    if (result == null || result.error == SearchResult.ERRORNO.RESULT_NOT_FOUND) {
        //Toast.makeText(mContext, "搜索发生错误:" + result.error, Toast.LENGTH_LONG).show();
        mTrafficShowView.showSnackBar(mContext.getResources().getString(R.string.navi_no_result));
        mTrafficShowView.getedit().setSearchCompletedState();
        return;
    }
    if (result.error == SearchResult.ERRORNO.NO_ERROR) {
        //baiduMap.clear();
        if (poiOverlay != null) {
            /* 在地图上清楚覆盖物 */
            poiOverlay.removeFromMap();
        }
        if (poiOverlay == null || !(poiOverlay instanceof ConfirmPoiOverlay)) {
            poiOverlay = new ConfirmPoiOverlay(baiduMap);
            /* 设置覆盖物被点击事件 */
            baiduMap.setOnMarkerClickListener(poiOverlay);
        }

        ((ConfirmPoiOverlay) poiOverlay).setData(result);
        /* 将覆盖物添加到地图中 */
        poiOverlay.addToMap();
        setPoiPosition();

        totalPageNum = result.getTotalPageNum();
        mTrafficShowView.getPoiListBox().getLayoutParams().height = ScreenUtil.getInstance().getHeightPixels() / 2;
        poiInfoList.clear();
        poiInfoList.addAll(result.getAllPoi());
        setAlist();
        mListAdapter.notifyDataSetChanged();
        pagerAdapter.notifyDataSetChanged();
        mTrafficShowView.getPoiDetialBox().setVisibility(View.GONE);
        mTrafficShowView.getPoiListBox().setVisibility(View.VISIBLE);
        /*MapStatus.Builder builder=new MapStatus.Builder();
        builder.target(list.get(0).location)
                .targetScreen(new Point(ScreenUtil.getInstance().getWidthPixels()/2,ScreenUtil.getInstance().getHeightPixels()/4))
                .zoom(15F);
        baiduMap.setMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));*/
        return;
    }

}
 
Example #16
Source File: SearchInteracter.java    From BmapLite with GNU General Public License v3.0 4 votes vote down vote up
private void searchPoiInCityByAmap(String keyword, String city, int page, final OnSearchResultListener listener) {
    PoiSearch.Query query = new PoiSearch.Query(keyword, null, city);
    query.setPageSize(20);
    query.setPageNum(page);

    PoiSearch poiSearchAmap = new PoiSearch(mContext, query);
    poiSearchAmap.setOnPoiSearchListener(new PoiSearch.OnPoiSearchListener() {
        @Override
        public void onPoiSearched(com.amap.api.services.poisearch.PoiResult poiResult, int code) {
            if (null != poiResult && null != poiResult.getPois() && !poiResult.getPois().isEmpty()) {
                List<MyPoiModel> list = new ArrayList<>();

                for (PoiItem poi : poiResult.getPois()) {
                    MyPoiModel myPoi = new MyPoiModel(mType);
                    myPoi.setCity(poi.getCityName());
                    myPoi.setUid(poi.getPoiId());
                    myPoi.setName(poi.getTitle());
                    myPoi.setAddress(poi.getSnippet());
                    myPoi.setInfo(poi.getTel());
                    myPoi.setLatitude(poi.getLatLonPoint().getLatitude());
                    myPoi.setLongitude(poi.getLatLonPoint().getLongitude());
                    myPoi.setTypePoi(TypePoi.POINT);
                    list.add(myPoi);
                }
                listener.setSearchResult(list);
                listener.onShowData("search");
            } else {
                listener.onNoData("search");
            }
            if (null != poiResult && null != poiResult.getSearchSuggestionCitys() && !poiResult.getSearchSuggestionCitys().isEmpty()) {
                listener.setSuggestCityList(poiResult.getSearchSuggestionCitys());
            }else {
                listener.onNoData("city");
            }
        }

        @Override
        public void onPoiItemSearched(PoiItem poiItem, int i) {

        }
    });
    poiSearchAmap.searchPOIAsyn();
}
 
Example #17
Source File: MyPoiSearchListener.java    From AndroidAnimationExercise with Apache License 2.0 4 votes vote down vote up
@Override
public void onGetPoiResult(PoiResult poiResult) {
    Log.e("onGetPoiResult", "the poiResult " + poiResult.describeContents());
    EventBus.getDefault().post(poiResult);
}
 
Example #18
Source File: SearchInteracter.java    From BmapLite with GNU General Public License v3.0 4 votes vote down vote up
private void searchPoiNearbyByBaidu(MyPoiModel nearby, String keyword, int page, final OnSearchResultListener listener) {
    mPoiSearchBaidu.setOnGetPoiSearchResultListener(new OnGetPoiSearchResultListener() {
        @Override
        public void onGetPoiResult(PoiResult poiResult) {
            if (null != poiResult && null != poiResult.getAllPoi() && !poiResult.getAllPoi().isEmpty()) {
                List<MyPoiModel> list = new ArrayList<>();

                for (PoiInfo poi : poiResult.getAllPoi()) {
                    MyPoiModel myPoi = new MyPoiModel(mType);
                    myPoi.setCity(poi.city);
                    myPoi.setUid(poi.uid);
                    myPoi.setAddress(poi.address);
                    myPoi.setName(poi.name);
                    myPoi.setInfo(poi.phoneNum);
                    if (null != poi.location) {
                        myPoi.setLatitude(poi.location.latitude);
                        myPoi.setLongitude(poi.location.longitude);
                    }
                    if (poi.type == PoiInfo.POITYPE.BUS_LINE) {
                        myPoi.setTypePoi(TypePoi.BUS_LINE);
                    } else if (poi.type == PoiInfo.POITYPE.SUBWAY_LINE) {
                        myPoi.setTypePoi(TypePoi.SUBWAY_LINE);
                    } else if (poi.type == PoiInfo.POITYPE.BUS_STATION) {
                        myPoi.setTypePoi(TypePoi.BUS_STATION);
                    } else if (poi.type == PoiInfo.POITYPE.SUBWAY_STATION) {
                        myPoi.setTypePoi(TypePoi.SUBWAY_STATION);
                    } else if (poi.type == PoiInfo.POITYPE.POINT) {
                        myPoi.setTypePoi(TypePoi.POINT);
                    }

                    list.add(myPoi);
                }
                listener.setSearchResult(list);
                listener.onShowData("search");
            } else {
                listener.onNoData("search");
            }
        }

        @Override
        public void onGetPoiDetailResult(PoiDetailResult poiDetailResult) {

        }

        @Override
        public void onGetPoiIndoorResult(PoiIndoorResult poiIndoorResult) {

        }
    });

    mPoiSearchBaidu.searchNearby(new PoiNearbySearchOption().location(new LatLng(nearby.getLatitude(), nearby.getLongitude())).keyword(keyword).radius(20000).sortType(PoiSortType.distance_from_near_to_far).pageNum(page).pageCapacity(20));
}
 
Example #19
Source File: SearchInteracter.java    From BmapLite with GNU General Public License v3.0 4 votes vote down vote up
private void searchPoiNearbyByAmap(MyPoiModel nearby, String keyword, int page, final OnSearchResultListener listener) {
    PoiSearch.Query query = new PoiSearch.Query(keyword, "", nearby.getCity());
    query.setPageSize(20);
    query.setPageNum(page);

    PoiSearch.SearchBound bound = new PoiSearch.SearchBound(new LatLonPoint(nearby.getLatitude(),
            nearby.getLongitude()), 20000);

    PoiSearch poiSearchAmap = new PoiSearch(mContext, query);
    poiSearchAmap.setBound(bound);
    poiSearchAmap.setOnPoiSearchListener(new PoiSearch.OnPoiSearchListener() {
        @Override
        public void onPoiSearched(com.amap.api.services.poisearch.PoiResult poiResult, int code) {
            if (1000 == code) {
                if (null != poiResult && null != poiResult.getPois() && !poiResult.getPois().isEmpty()) {
                    List<MyPoiModel> list = new ArrayList<>();

                    for (PoiItem poi : poiResult.getPois()) {
                        MyPoiModel myPoi = new MyPoiModel(mType);
                        myPoi.setCity(poi.getCityName());
                        myPoi.setUid(poi.getPoiId());
                        myPoi.setName(poi.getTitle());
                        myPoi.setInfo(poi.getTel());
                        myPoi.setAddress(poi.getSnippet());
                        myPoi.setLatitude(poi.getLatLonPoint().getLatitude());
                        myPoi.setLongitude(poi.getLatLonPoint().getLongitude());
                        myPoi.setTypePoi(TypePoi.POINT);
                        list.add(myPoi);
                    }
                    listener.setSearchResult(list);
                    listener.onShowData("search");
                } else {
                    listener.onNoData("search");
                }
            } else {
                listener.onNoData("search");
            }
        }

        @Override
        public void onPoiItemSearched(PoiItem poiItem, int i) {

        }
    });
    poiSearchAmap.searchPOIAsyn();
}
 
Example #20
Source File: PoiOverlay.java    From Mobike with Apache License 2.0 2 votes vote down vote up
/**
 * 设置POI数据
 * 
 * @param poiResult
 *            设置POI数据
 */
public void setData(PoiResult poiResult) {
    this.mPoiResult = poiResult;
}
 
Example #21
Source File: PoiOverlay.java    From Mobike with Apache License 2.0 2 votes vote down vote up
/**
 * 获取该 PoiOverlay 的 poi数据
 * 
 * @return
 */
public PoiResult getPoiResult() {
    return mPoiResult;
}
 
Example #22
Source File: PoiOverlay.java    From react-native-baidu-map with MIT License 2 votes vote down vote up
/**
 * 设置POI数据
 * 
 * @param poiResult    设置POI数据
 */
public void setData(PoiResult poiResult) {
    this.mPoiResult = poiResult;
}
 
Example #23
Source File: PoiOverlay.java    From react-native-baidu-map with MIT License 2 votes vote down vote up
/**
 * 获取该PoiOverlay的poi数据
 * 
 * @return     POI数据
 */
public PoiResult getPoiResult() {
    return mPoiResult;
}