com.baidu.mapapi.search.geocode.OnGetGeoCoderResultListener Java Examples
The following examples show how to use
com.baidu.mapapi.search.geocode.OnGetGeoCoderResultListener.
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: AddressEditDelegate.java From FastWaiMai with MIT License | 5 votes |
private void initGeoCoder() { mGeoCoder = GeoCoder.newInstance(); mGeoCoder.setOnGetGeoCodeResultListener(new OnGetGeoCoderResultListener() { @Override public void onGetGeoCodeResult(GeoCodeResult geoCodeResult) { } @Override public void onGetReverseGeoCodeResult(ReverseGeoCodeResult reverseGeoCodeResult) { if (poiInfoListForGeoCoder != null) { poiInfoListForGeoCoder.clear(); } if (reverseGeoCodeResult.error.equals(SearchResult.ERRORNO.NO_ERROR)) { //获取城市 ReverseGeoCodeResult.AddressComponent addressComponent = reverseGeoCodeResult.getAddressDetail(); cityName = addressComponent.city; mTvCurrrentCity.setText(cityName); //获取poi列表 if (reverseGeoCodeResult.getPoiList() != null) { poiInfoListForGeoCoder = reverseGeoCodeResult.getPoiList(); } } else { Toast.makeText(getContext(), "该位置范围内无信息", Toast.LENGTH_SHORT).show(); } initGeoCoderListView(); } }); }
Example #2
Source File: LocationDelegate.java From FastWaiMai with MIT License | 5 votes |
private void initGeoCoder() { mGeoCoder = GeoCoder.newInstance(); mGeoCoder.setOnGetGeoCodeResultListener(new OnGetGeoCoderResultListener() { //地理编码检索监听器 @Override public void onGetGeoCodeResult(GeoCodeResult geoCodeResult) { } //逆地理编码检索监听器 @Override public void onGetReverseGeoCodeResult(ReverseGeoCodeResult reverseGeoCodeResult) { if (poiInfoListForGeoCoder != null) { poiInfoListForGeoCoder.clear(); } if (reverseGeoCodeResult.error.equals(SearchResult.ERRORNO.NO_ERROR)) { //获取城市 ReverseGeoCodeResult.AddressComponent addressComponent = reverseGeoCodeResult.getAddressDetail(); cityName = addressComponent.city; //获取poi列表 if (reverseGeoCodeResult.getPoiList() != null) { poiInfoListForGeoCoder = reverseGeoCodeResult.getPoiList(); } } initGeoCoderListView(); } }); }
Example #3
Source File: MainActivity.java From BaiDuMapSelectDemo with Apache License 2.0 | 5 votes |
/** * 反向地理解析,结果中含有poi信息,用于刚进入地图和移动地图时使用 */ private void initGeoCoder() { mGeoCoder = GeoCoder.newInstance(); mGeoCoder.setOnGetGeoCodeResultListener(new OnGetGeoCoderResultListener() { @Override public void onGetGeoCodeResult(GeoCodeResult geoCodeResult) { } @Override public void onGetReverseGeoCodeResult(ReverseGeoCodeResult reverseGeoCodeResult) { if (poiInfoListForGeoCoder != null) { poiInfoListForGeoCoder.clear(); } if (reverseGeoCodeResult.error.equals(SearchResult.ERRORNO.NO_ERROR)) { //获取城市 ReverseGeoCodeResult.AddressComponent addressComponent = reverseGeoCodeResult.getAddressDetail(); cityName = addressComponent.city; tv_city.setText(cityName); //获取poi列表 if (reverseGeoCodeResult.getPoiList() != null) { poiInfoListForGeoCoder = reverseGeoCodeResult.getPoiList(); } } else { Toast.makeText(mContext, "该位置范围内无信息", Toast.LENGTH_SHORT); } initGeoCoderListView(); } }); }
Example #4
Source File: NaviSetPointPresenter.java From AssistantBySDK with Apache License 2.0 | 4 votes |
@Override public void initStartAddress() { BDLocation location = new BDLocation(); location.setLatitude(address.getLatitude()); location.setLongitude(address.getLongitude()); location.setRadius(address.getRadius()); location.setSpeed(address.getSpeed()); location.setSatelliteNumber(address.getSatelliteNumber()); // location = LocationClient.getBDLocationInCoorType(location, BDLocation.BDLOCATION_GCJ02_TO_BD09LL); //更新家和公司视图 updateCompany(); updateHome(); final GeoCoder geoCoder = GeoCoder.newInstance(); /* 设置地理编码查询监听者 */ final BDLocation finalLocation = location; geoCoder.setOnGetGeoCodeResultListener(new OnGetGeoCoderResultListener() { @Override public void onGetGeoCodeResult(GeoCodeResult geoCodeResult) { } @Override public void onGetReverseGeoCodeResult(ReverseGeoCodeResult r) { List<PoiInfo> ls = r.getPoiList(); if (ls != null && ls.size() > 0) { initAddress = new BaiduAddress(); // String myLocation; setBaiduAddressFromPoiInfo(initAddress, ls.get(0)); // myLocation = initAddress.getName(); initAddress.setAddress(address.getAddressDetail()); initAddress.setLatitude(finalLocation.getLatitude()); initAddress.setLongitude(finalLocation.getLongitude()); if (TextUtils.isEmpty(initAddress.getCity())) initAddress.setCity(address.getCity()); BaiduAddress myStartAddr = new BaiduAddress(); myStartAddr.setLatitude(initAddress.getLatitude()); myStartAddr.setLongitude(initAddress.getLongitude()); myStartAddr.setName("我的位置" + "(" + initAddress.getName() + ")" + "附近"); if (mSetPointView.getStartAddrText().startsWith("我的位置")) { myStartAddr.setRemark("出发地"); myStartAddr.setId(null); myStartAddr.setFavoritedTime(null); mAppConfig.startAddress = myStartAddr; } //设置默认回家和去公司的出发地址 // mAppConfig.myAddress = myLocation; // updateCompany(); // updateHome(); //由init进入该方法时不触发导航 updateStart(false); updateEnd(false); updateHistoryList(); geoCoder.destroy(); } } }); geoCoder.reverseGeoCode(new ReverseGeoCodeOption(). location(new LatLng(location.getLatitude(), location.getLongitude()))); }
Example #5
Source File: FakeWeiBoActivity.java From AndroidAnimationExercise with Apache License 2.0 | 4 votes |
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()); } }); }