com.baidu.mapapi.search.geocode.ReverseGeoCodeOption Java Examples
The following examples show how to use
com.baidu.mapapi.search.geocode.ReverseGeoCodeOption.
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 | 6 votes |
/** * 根据收货地址的位置在地图上移动"我"的位置 */ private void navigateTo(double longitude, double latitude) { if (isFirstLocation) { currentLatLng = new LatLng(latitude, longitude); MapStatus.Builder builder = new MapStatus.Builder(); MapStatus mapStatus = builder.target(currentLatLng).zoom(17.0f).build(); mBaiduMap.animateMapStatus(MapStatusUpdateFactory .newMapStatus(mapStatus)); isFirstLocation = false; //反向地理解析(含有poi列表) mGeoCoder.reverseGeoCode(new ReverseGeoCodeOption() .location(currentLatLng)); } MyLocationData.Builder locationBuilder = new MyLocationData.Builder(); locationBuilder.latitude(latitude); locationBuilder.longitude(longitude); MyLocationData locationData = locationBuilder.build(); mBaiduMap.setMyLocationData(locationData); }
Example #2
Source File: MapPickerActivity.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
@Override public void onTouch(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { if (mCenterPoint == null) { return; } // 获取当前MapView中心屏幕坐标对应的地理坐标(不重新设置的话中心点在左上角) mCenterPoint = mBaiduMap.getMapStatus().targetScreen; LatLng currentLatLng = mBaiduMap.getProjection().fromScreenLocation(mCenterPoint); // 发起反地理编码检索 mGeoCoder.reverseGeoCode((new ReverseGeoCodeOption()) .location(currentLatLng)); loading.setVisibility(View.VISIBLE); } }
Example #3
Source File: MainActivity.java From BaiDuMapSelectDemo with Apache License 2.0 | 6 votes |
/** * 根据获取到的位置在地图上移动“我”的位置 * * @param location */ private void navigateTo(BDLocation location) { double longitude = location.getLongitude(); double latitude = location.getLatitude(); String address = location.getAddrStr(); if (isFirstLocation) { currentLatLng = new LatLng(latitude, longitude); MapStatus.Builder builder = new MapStatus.Builder(); MapStatus mapStatus = builder.target(currentLatLng).zoom(17.0f).build(); mBaiduMap.animateMapStatus(MapStatusUpdateFactory .newMapStatus(mapStatus)); isFirstLocation = false; //反向地理解析(含有poi列表) mGeoCoder.reverseGeoCode(new ReverseGeoCodeOption() .location(currentLatLng)); } MyLocationData.Builder locationBuilder = new MyLocationData.Builder(); locationBuilder.latitude(location.getLatitude()); locationBuilder.longitude(location.getLongitude()); MyLocationData locationData = locationBuilder.build(); mBaiduMap.setMyLocationData(locationData); }
Example #4
Source File: LocationDelegate.java From FastWaiMai with MIT License | 6 votes |
@Override public void onReceiveLocation(BDLocation location) { if (location == null){ return; } if (location.getLocType() == BDLocation.TypeGpsLocation || location.getLocType() == BDLocation.TypeNetWorkLocation) { currentAddr = location.getAddrStr(); //当前所在位置 LatLng currentLatLng = new LatLng(location.getLatitude(), location.getLongitude()); mGeoCoder.reverseGeoCode(new ReverseGeoCodeOption() .location(currentLatLng) .radius(radius)); } }
Example #5
Source File: AddressEditDelegate.java From FastWaiMai with MIT License | 6 votes |
/** * 根据获取到的位置在地图上移动"我"的位置 * * @param location */ private void navigateTo(BDLocation location) { double longitude = location.getLongitude(); double latitude = location.getLatitude(); String address = location.getAddrStr(); if (isFirstLocation) { currentLatLng = new LatLng(latitude, longitude); MapStatus.Builder builder = new MapStatus.Builder(); MapStatus mapStatus = builder.target(currentLatLng).zoom(17.0f).build(); mBaiduMap.animateMapStatus(MapStatusUpdateFactory .newMapStatus(mapStatus)); isFirstLocation = false; //反向地理解析(含有poi列表) mGeoCoder.reverseGeoCode(new ReverseGeoCodeOption() .location(currentLatLng) .radius(radius)); } MyLocationData.Builder locationBuilder = new MyLocationData.Builder(); locationBuilder.latitude(location.getLatitude()); locationBuilder.longitude(location.getLongitude()); MyLocationData locationData = locationBuilder.build(); mBaiduMap.setMyLocationData(locationData); }
Example #6
Source File: LocationActivity.java From imsdk-android with MIT License | 5 votes |
protected void startLocationAndSetIcon() { LatLng point = new LatLng(latitude, longitude); geoCoder.reverseGeoCode(new ReverseGeoCodeOption().location(point)); OverlayOptions options = new MarkerOptions().draggable(false) .position(point) .icon(BitmapDescriptorFactory.fromResource(R.drawable.atom_ui_map_mark)); if (overlay != null) { overlay.remove(); } overlay = baiduMap.addOverlay(options); // adapter.notifyDataSetChanged(); }
Example #7
Source File: MapPickerActivity.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
public void turnBack() { MyLocationData location = mBaiduMap.getLocationData(); if (location == null) { return; } // 实现动画跳转 MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(new LatLng(location.latitude, location.longitude)); mBaiduMap.animateMapStatus(u); mBaiduMap.clear(); // 发起反地理编码检索 mGeoCoder.reverseGeoCode((new ReverseGeoCodeOption()) .location(new LatLng(location.latitude, location.longitude))); }
Example #8
Source File: MapPickerActivity.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
@Override public void onReceiveLocation(BDLocation location) { if (null != location && location.getLocType() != BDLocation.TypeServerError) { // MyLocationData data = new MyLocationData.Builder()// // .direction(mCurrentX)// .accuracy(location.getRadius())// .latitude(location.getLatitude())// .longitude(location.getLongitude())// .build(); mBaiduMap.setMyLocationData(data); // 设置自定义图标 MyLocationConfiguration config = new MyLocationConfiguration( MyLocationConfiguration.LocationMode.NORMAL, true, null); mBaiduMap.setMyLocationConfigeration(config); mAddress = location.getAddrStr(); mName = location.getStreet(); mCity = location.getCity(); LatLng currentLatLng = new LatLng(location.getLatitude(), location.getLongitude()); mLoactionLatLng = currentLatLng; // 是否第一次定位 if (isFirstLoc) { isFirstLoc = false; // 实现动画跳转 MapStatusUpdate u = MapStatusUpdateFactory .newLatLng(currentLatLng); mBaiduMap.animateMapStatus(u); mGeoCoder.reverseGeoCode((new ReverseGeoCodeOption()) .location(currentLatLng)); return; } } }
Example #9
Source File: MainActivity.java From VirtualLocation with Apache License 2.0 | 5 votes |
/** * setCurrentMapLatLng 设置当前坐标 */ public static void setCurrentMapLatLng(LatLng arg0) { curLatlng = arg0; mMarker.setPosition(arg0); // 设置地图中心点为这是位置 LatLng ll = new LatLng(arg0.latitude, arg0.longitude); MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll); mBaiduMap.animateMapStatus(u); // 根据经纬度坐标 找到实地信息,会在接口onGetReverseGeoCodeResult中呈现结果 mSearch.reverseGeoCode(new ReverseGeoCodeOption().location(arg0)); }
Example #10
Source File: FakeWeiBoActivity.java From AndroidAnimationExercise with Apache License 2.0 | 5 votes |
@Override public void onReceiveLocation(BDLocation bdLocation) { Log.e(TAG, "onReceiveLocation: " + bdLocation); if (mLocationClient != null && mLocationClient.isStarted()) { mLocationClient.stop(); } district.setText(bdLocation.getAddress().district); latLng = new LatLng(bdLocation.getLatitude(), bdLocation.getLongitude()); movie.performClick(); // mGeoCoder.reverseGeoCode(new ReverseGeoCodeOption().location(latLng)); mGeoCoder.reverseGeoCode(new ReverseGeoCodeOption().location(new LatLng(39.977818,116.401535))); }
Example #11
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 #12
Source File: LocationActivity.java From Conquer with Apache License 2.0 | 5 votes |
@Override public void onReceiveLocation(BDLocation location) { // map view 销毁后不在处理新接收的位置 if (location == null || mMapView == null) return; if (lastLocation != null) { if (lastLocation.getLatitude() == location.getLatitude() && lastLocation.getLongitude() == location.getLongitude()) { BmobLog.i("获取坐标相同");// 若两次请求获取到的地理位置坐标是相同的,则不再定位 mLocClient.stop(); return; } } lastLocation = location; BmobLog.i("lontitude = " + location.getLongitude() + ",latitude = " + location.getLatitude() + ",地址 = " + lastLocation.getAddrStr()); MyLocationData locData = new MyLocationData.Builder().accuracy(location.getRadius()) // 此处设置开发者获取到的方向信息,顺时针0-360 .direction(100).latitude(location.getLatitude()).longitude(location.getLongitude()).build(); mBaiduMap.setMyLocationData(locData); LatLng ll = new LatLng(location.getLatitude(), location.getLongitude()); String address = location.getAddrStr(); if (address != null && !address.equals("")) { lastLocation.setAddrStr(address); } else { // 反Geo搜索 mSearch.reverseGeoCode(new ReverseGeoCodeOption().location(ll)); } // 显示在地图上 MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll); mBaiduMap.animateMapStatus(u); // 设置按钮可点击 // mHeaderLayout.getRightImageButton().setEnabled(true); }
Example #13
Source File: MainActivity.java From MoveMapLocation with Apache License 2.0 | 5 votes |
/** * 地图状态改变结束 * * @param mapStatus 地图状态改变结束后的地图状态 */ @Override public void onMapStatusChangeFinish(MapStatus mapStatus) { //地图操作的中心点 LatLng cenpt = mapStatus.target; geoCoder.reverseGeoCode(new ReverseGeoCodeOption().location(cenpt)); }
Example #14
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 #15
Source File: GeolocationModule.java From react-native-baidu-map with MIT License | 4 votes |
@ReactMethod public void reverseGeoCode(double lat, double lng) { getGeoCoder().reverseGeoCode(new ReverseGeoCodeOption() .location(new LatLng(lat, lng))); }
Example #16
Source File: GeolocationModule.java From react-native-baidu-map with MIT License | 4 votes |
@ReactMethod public void reverseGeoCodeGPS(double lat, double lng) { getGeoCoder().reverseGeoCode(new ReverseGeoCodeOption() .location(getBaiduCoorFromGPSCoor(new LatLng(lat, lng)))); }
Example #17
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); }