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

The following examples show how to use com.baidu.mapapi.search.poi.PoiNearbySearchOption. 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: MainActivity.java    From BaiDuMapSelectDemo with Apache License 2.0 5 votes vote down vote up
/**
 * 周边搜索
 */
private void searchNearbyProcess(LatLng center) {
    //以定位点为中心,搜索半径以内的
    PoiNearbySearchOption nearbySearchOption = new PoiNearbySearchOption()
            .keyword(keyword)
            .sortType(PoiSortType.distance_from_near_to_far)
            .location(center)
            .radius(radius)
            .pageCapacity(pageSize)
            .pageNum(loadIndex);

    mPoiSearch.searchNearby(nearbySearchOption);
}
 
Example #2
Source File: LocationActivity.java    From imsdk-android with MIT License 5 votes vote down vote up
private void searchNearByPoi(PoiInfo info, String keyword,int pageNum) {
    PoiNearbySearchOption option = new PoiNearbySearchOption();
    option.keyword(keyword).
            radius(1000).pageNum(pageNum).pageCapacity(5).
            sortType(PoiSortType.distance_from_near_to_far).
            location(new LatLng(info.location.latitude, info.location.longitude));
    poiSearch.searchNearby(option);
}
 
Example #3
Source File: MapActivity.java    From foodie-app with Apache License 2.0 5 votes vote down vote up
private void search(String query, int count) {
    if (mLocation == null) {
        if (count == 1) {
            Toast.makeText(MapActivity.this, "正在定位到商家地址..", Toast.LENGTH_LONG).show();
        }
        Toast.makeText(MapActivity.this, "正在尝试为你定位..", Toast.LENGTH_LONG).show();
    }
    mPoiSearch.searchNearby((new PoiNearbySearchOption())
            .location(new LatLng(mLocation.getLatitude(), mLocation.getLongitude()))
            .keyword(query)
            .radius(1000)
            .pageCapacity(count)
            .sortType(PoiSortType.distance_from_near_to_far));
}
 
Example #4
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 #5
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 #6
Source File: FakeWeiBoActivity.java    From AndroidAnimationExercise with Apache License 2.0 4 votes vote down vote up
private void initLocationAndSearch() {

        //location
        mLocationClient = new LocationClient(getApplicationContext());     //声明LocationClient类
        mLocationClient.registerLocationListener(this);    //注册监听函数
        LocationClientOption option = new LocationClientOption();
        option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy
        );//可选,默认高精度,设置定位模式,高精度,低功耗,仅设备
        option.setCoorType("bd09ll");//可选,默认gcj02,设置返回的定位结果坐标系
        int span = 1000;
        option.setScanSpan(span);//可选,默认0,即仅定位一次,设置发起定位请求的间隔需要大于等于1000ms才是有效的
        option.setIsNeedAddress(true);//可选,设置是否需要地址信息,默认不需要
        option.setOpenGps(true);//可选,默认false,设置是否使用gps
        option.setLocationNotify(true);//可选,默认false,设置是否当GPS有效时按照1S/1次频率输出GPS结果
        option.setIsNeedLocationDescribe(true);//可选,默认false,设置是否需要位置语义化结果,可以在BDLocation.getLocationDescribe里得到,结果类似于“在北京天安门附近”
        option.setIsNeedLocationPoiList(true);//可选,默认false,设置是否需要POI结果,可以在BDLocation.getPoiList里得到
        option.setIgnoreKillProcess(false);//可选,默认true,定位SDK内部是一个SERVICE,并放到了独立进程,设置是否在stop的时候杀死这个进程,默认不杀死
        option.SetIgnoreCacheException(false);//可选,默认false,设置是否收集CRASH信息,默认收集
        option.setEnableSimulateGps(false);//可选,默认false,设置是否需要过滤GPS仿真结果,默认需要
        mLocationClient.setLocOption(option);
        //search

        mPoiSearch = PoiSearch.newInstance();
        mPoiSearch.setOnGetPoiSearchResultListener(new MyPoiSearchListener());
        mNearbySearchOption = new PoiNearbySearchOption()
                .radius(5000)
                .pageNum(1)
                .pageCapacity(20)
                .sortType(PoiSortType.distance_from_near_to_far);


        ////////////////
        mGeoCoder = GeoCoder.newInstance();
        mGeoCoder.setOnGetGeoCodeResultListener(new OnGetGeoCoderResultListener() {
            @Override
            public void onGetGeoCodeResult(GeoCodeResult geoCodeResult) {
                Log.e(TAG, "onGetGeoCodeResult: " + geoCodeResult.toString());
            }

            @Override
            public void onGetReverseGeoCodeResult(ReverseGeoCodeResult reverseGeoCodeResult) {
                Log.e(TAG, "onGetReverseGeoCodeResult: " + reverseGeoCodeResult.toString());
            }
        });


    }