com.baidu.mapapi.search.geocode.GeoCoder Java Examples
The following examples show how to use
com.baidu.mapapi.search.geocode.GeoCoder.
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 imsdk-android with MIT License | 6 votes |
private void initLocationClient() { geoCoder = GeoCoder.newInstance(); poiSearch = PoiSearch.newInstance(); poiSearch.setOnGetPoiSearchResultListener(this); locationClient = new LocationClient(getApplication()); LocationClientOption option = new LocationClientOption(); option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy); option.setCoorType(CoordinateType.BD09LL); // option.setScanSpan(5000);// option.setIsNeedAddress(true); option.setOpenGps(true); option.setLocationNotify(true); option.setIsNeedLocationDescribe(true); option.setIsNeedLocationPoiList(true); option.setIgnoreKillProcess(true); option.SetIgnoreCacheException(true); option.setEnableSimulateGps(true); locationClient.setLocOption(option); locationClient.registerLocationListener(this); locationClient.start(); }
Example #2
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 #3
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 #4
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 #5
Source File: MapPickerActivity.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
private void initMap() { //ricky init baidumap begin mMapView = (MapView) findViewById(R.id.bmapView); mBaiduMap = mMapView.getMap(); mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL); mMapView.showZoomControls(false); MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(17.0f); mBaiduMap.setMapStatus(msu); mBaiduMap.setOnMapTouchListener(touchListener); // 初始化POI信息列表 mInfoList = new ArrayList<PoiInfo>(); // 初始化当前MapView中心屏幕坐标,初始化当前地理坐标 mCenterPoint = mBaiduMap.getMapStatus().targetScreen; mLoactionLatLng = mBaiduMap.getMapStatus().target; // 定位 mBaiduMap.setMyLocationEnabled(true); // 隐藏百度logo ZoomControl int count = mMapView.getChildCount(); for (int i = 0; i < count; i++) { View child = mMapView.getChildAt(i); if (child instanceof ImageView || child instanceof ZoomControls) { child.setVisibility(View.INVISIBLE); } } // 隐藏比例尺 //mMapView.showScaleControl(false); // 地理编码 mGeoCoder = GeoCoder.newInstance(); mGeoCoder.setOnGetGeoCodeResultListener(GeoListener); list = (ListView) findViewById(R.id.list); list.setOnItemClickListener(this); list.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE); loading = (ProgressBar) findViewById(R.id.loading); status = (TextView) findViewById(R.id.status); mAdapter = new MapPickerAdapter(MapPickerActivity.this, mInfoList); list.setAdapter(mAdapter); }
Example #6
Source File: MapFragment.java From MapForTour with MIT License | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); application = (DeviceMessageApplication) getActivity().getApplication(); //地图覆盖物初始化 bitmapDescriptorMan = BitmapDescriptorFactory.fromResource(R.mipmap.map_portrait_mark_man_circle); bitmapDescriptorWoman = BitmapDescriptorFactory.fromResource(R.mipmap.map_portrait_mark_woman_circle); bmStart = BitmapDescriptorFactory.fromResource(R.mipmap.icon_start); bmEnd = BitmapDescriptorFactory.fromResource(R.mipmap.icon_end); option = new MarkerOptions(); geoCoder = GeoCoder.newInstance(); geoCoder.setOnGetGeoCodeResultListener(this); reverseGeoCodeOption = new ReverseGeoCodeOption(); //管理员权限用户信息弹窗初始化 viewOverlayItem = View.inflate(getContext(), R.layout.item_map_addoverlay_radarnearby_admin, null); tvAddOverlayItemUserID = (TextView) viewOverlayItem.findViewById(R.id.tvAddOverlayItemUserID); imageViewAddOverlayItem = (ImageView) viewOverlayItem.findViewById(R.id.imageViewAddOverlayItem); tvAddOverlayGeoCoder = (TextView) viewOverlayItem.findViewById(R.id.tvAddOverlayGeoCoder); tvAddOverlayItemDistance = (TextView) viewOverlayItem.findViewById(R.id.tvAddOverlayItemDistance); tvAddOverlayItemLatlng = (TextView) viewOverlayItem.findViewById(R.id.tvAddOverlayItemLatlng); layoutAddOverlayRadarNearbyItem = (LinearLayout) viewOverlayItem.findViewById(R.id.layoutAddOverlayRadarNearbyItem); btnAddOverlayItemTrackQuery = (Button) viewOverlayItem.findViewById(R.id.btnAddOverlayItemTrackQuery); btnAddOverlayItemGeoFencePlace = (Button) viewOverlayItem.findViewById(R.id.btnAddOverlayItemGeoFencePlace); btnAddOverlayItemTrackQuery.setOnClickListener(this); btnAddOverlayItemGeoFencePlace.setOnClickListener(this); }
Example #7
Source File: GeolocationModule.java From react-native-baidu-map with MIT License | 5 votes |
/** * * @return */ protected GeoCoder getGeoCoder() { if(geoCoder != null) { geoCoder.destroy(); } geoCoder = GeoCoder.newInstance(); geoCoder.setOnGetGeoCodeResultListener(this); return geoCoder; }
Example #8
Source File: NavigationActivity.java From BaiduMap-TrafficAssistant with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SDKInitializer.initialize(getApplicationContext()); this.context = this; setContentView(R.layout.activity_navigation); initView(); // 初始化搜索模块,注册事件监听 mSearch = GeoCoder.newInstance(); mSearch.setOnGetGeoCodeResultListener(this); }
Example #9
Source File: LocationActivity.java From Conquer with Apache License 2.0 | 5 votes |
private void initBaiduMap() { // 地图初始化 mMapView = (MapView) findViewById(R.id.bmapView); mBaiduMap = mMapView.getMap(); // 设置缩放级别 mBaiduMap.setMaxAndMinZoomLevel(18, 13); // 注册 SDK 广播监听者 IntentFilter iFilter = new IntentFilter(); iFilter.addAction(SDKInitializer.SDK_BROADTCAST_ACTION_STRING_PERMISSION_CHECK_ERROR); iFilter.addAction(SDKInitializer.SDK_BROADCAST_ACTION_STRING_NETWORK_ERROR); mReceiver = new BaiduReceiver(); registerReceiver(mReceiver, iFilter); Intent intent = getIntent(); String type = intent.getStringExtra("type"); if (type.equals("select")) {// 选择发送位置 // initTopBarForBoth("位置", R.drawable.btn_login_selector, "发送", new // onRightImageButtonClickListener() { // @Override // public void onClick() { // // TODO Auto-generated method stub // gotoChatPage(); // } // }); // mHeaderLayout.getRightImageButton().setEnabled(false); initLocClient(); } else {// 查看当前位置 // initTopBarForLeft("位置"); Bundle b = intent.getExtras(); LatLng latlng = new LatLng(b.getDouble("latitude"), b.getDouble("longtitude"));// 维度在前,经度在后 mBaiduMap.setMapStatus(MapStatusUpdateFactory.newLatLng(latlng)); // 显示当前位置图标 OverlayOptions ooA = new MarkerOptions().position(latlng).icon(bdgeo).zIndex(9); mBaiduMap.addOverlay(ooA); } mSearch = GeoCoder.newInstance(); mSearch.setOnGetGeoCodeResultListener(this); }
Example #10
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 #11
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()); } }); }
Example #12
Source File: MainActivity.java From MoveMapLocation with Apache License 2.0 | 4 votes |
/** * 定位监听 * * @param bdLocation */ @Override public void onReceiveLocation(BDLocation bdLocation) { //如果bdLocation为空或mapView销毁后不再处理新数据接收的位置 if (bdLocation == null || mBaiduMap == null) { return; } //定位数据 MyLocationData data = new MyLocationData.Builder() //定位精度bdLocation.getRadius() .accuracy(bdLocation.getRadius()) //此处设置开发者获取到的方向信息,顺时针0-360 .direction(bdLocation.getDirection()) //经度 .latitude(bdLocation.getLatitude()) //纬度 .longitude(bdLocation.getLongitude()) //构建 .build(); //设置定位数据 mBaiduMap.setMyLocationData(data); //是否是第一次定位 if (isFirstLoc) { isFirstLoc = false; LatLng ll = new LatLng(bdLocation.getLatitude(), bdLocation.getLongitude()); MapStatusUpdate msu = MapStatusUpdateFactory.newLatLngZoom(ll, 18); mBaiduMap.animateMapStatus(msu); } //获取坐标,待会用于POI信息点与定位的距离 locationLatLng = new LatLng(bdLocation.getLatitude(), bdLocation.getLongitude()); //获取城市,待会用于POISearch city = bdLocation.getCity(); //文本输入框改变监听,必须在定位完成之后 searchAddress.addTextChangedListener(this); //创建GeoCoder实例对象 geoCoder = GeoCoder.newInstance(); //发起反地理编码请求(经纬度->地址信息) ReverseGeoCodeOption reverseGeoCodeOption = new ReverseGeoCodeOption(); //设置反地理编码位置坐标 reverseGeoCodeOption.location(new LatLng(bdLocation.getLatitude(), bdLocation.getLongitude())); geoCoder.reverseGeoCode(reverseGeoCodeOption); //设置查询结果监听者 geoCoder.setOnGetGeoCodeResultListener(this); }