Java Code Examples for com.baidu.location.BDLocation#getLongitude()
The following examples show how to use
com.baidu.location.BDLocation#getLongitude() .
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: LocationService.java From Conquer with Apache License 2.0 | 6 votes |
@Override public void onReceiveLocation(BDLocation location) { L.i(location.getLocType() + "," + +location.getOperators() + "," + location.getLatitude() + "," + location.getLongitude() + "," + location.getAddrStr()); // 成功定位 if (location.getLocType() == 161 || location.getLocType() == 61) { lastPoint = new LocationInfo(location.getLongitude(), location.getLatitude(), location.getAddrStr()); } else {// 定位失败 lastPoint = new LocationInfo(0, 0, "定位失败"); } // 停止定位 mLocationClient.stop(); if (listener != null) { listener.onLocateCompleted(lastPoint); } }
Example 2
Source File: WBPostActivity.java From Simpler with Apache License 2.0 | 6 votes |
@Override public void onReceiveLocation(BDLocation location) { // 在回调方法运行在remote进程 // 获取定位类型 int locType = location.getLocType(); if (locType == BDLocation.TypeGpsLocation || locType == BDLocation.TypeNetWorkLocation || locType == BDLocation.TypeOffLineLocation) { // 定位成功。GPS定位结果 || 网络定位结果 || 离线定位结果 // 纬度 mLatitude = location.getLatitude(); // 经度 mLongitude = location.getLongitude(); // 获取地址信息 mAddrStr = location.getAddrStr(); mHandler.sendEmptyMessage(HANDLE_ADDRESS_OK); } else if (location.getLocType() == BDLocation.TypeServerError) { mHandler.sendEmptyMessage(HANDLE_SERVER_ERROR); } else if (location.getLocType() == BDLocation.TypeNetWorkException) { mHandler.sendEmptyMessage(HANDLE_NETWORK_EXCEPTION); } else if (location.getLocType() == BDLocation.TypeCriteriaException) { mHandler.sendEmptyMessage(HANDLE_CRITERIA_EXCEPTION); } }
Example 3
Source File: MainActivity.java From Study_Android_Demo with Apache License 2.0 | 6 votes |
@Override public void onReceiveLocation(BDLocation bdLocation) { //查看定位结果 Log.d("Tag", "定位返回----" + bdLocation.getAddrStr()); //定位成功后,把定位的点,设置地图的中心点 //包装经纬,从定位信息中,获取经纬度 LatLng currentLatLng = new LatLng(bdLocation.getLatitude(), bdLocation.getLongitude()); //构建地图状态 MapStatus status = new MapStatus.Builder() //包装经纬度 .target(currentLatLng) //缩放等级 .zoom(15) //构建 .build(); //通过地图工厂设置地图状态 MapStatusUpdate update = MapStatusUpdateFactory.newMapStatus(status); //更新地图界面 mBaiduMap.setMapStatus(update); }
Example 4
Source File: SearchGoodsActivity.java From school_shop with MIT License | 6 votes |
@Override public void onReceiveLocation(BDLocation location) { //Receive Location lat = location.getLatitude(); lont = location.getLongitude(); // showButtomToast("lat="+location.getLatitude()+" , lont="+location.getLocType()); //定位成功 if (location.getLocType()==161||location.getLocType()==61) { isLocalSuccess = localsuccess; mLocationClient.stop(); progressBarTitle.setText(getStringByRId(R.string.localSuccess)); showButtomToast(getStringByRId(R.string.localSuccess)); }else if (location.getLocType()==167||location.getLocType()==62) { isLocalSuccess = localfail; showButtomToast(getStringByRId(R.string.localFail)); mLocationClient.stop(); } }
Example 5
Source File: MainActivity.java From Mobike with Apache License 2.0 | 6 votes |
/** * des:地图跳到指定位置 * * @param location */ private void navigateTo(BDLocation location) { if (isFirstLocation) { LatLng ll = new LatLng(location.getLatitude(), location.getLongitude()); MapStatusUpdate update = MapStatusUpdateFactory.newLatLng(ll); baiduMap.animateMapStatus(update); update = MapStatusUpdateFactory.zoomTo(18f); baiduMap.animateMapStatus(update); isFirstLocation = false; } MyLocationData.Builder builder = new MyLocationData.Builder(); builder.latitude(location.getLatitude()); builder.longitude(location.getLongitude()); MyLocationData data = builder.build(); baiduMap.setMyLocationData(data); }
Example 6
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 7
Source File: BaiduUtils.java From LocationProvider with Apache License 2.0 | 5 votes |
public static void prinftBDLocation(BDLocation bdLocation) { Log.d("@@@", "====================BDLocation Strat===================="); String str = "BDLocation{" + "locationID='" + bdLocation.getLocationID() + '\'' + ", locType=" + bdLocation.getLocType() + ", locTime='" + bdLocation.getTime() + '\'' + ", latitude=" + bdLocation.getLatitude() + ", longitude=" + bdLocation.getLongitude() + ", radius=" + bdLocation.getRadius() + ", addrStr=" + bdLocation.getAddrStr() + ", country='" + bdLocation.getCountry() + '\'' + ", countryCode='" + bdLocation.getCountryCode() + '\'' + ", city='" + bdLocation.getCity() + '\'' + ", cityCode='" + bdLocation.getCityCode() + '\'' + ", district='" + bdLocation.getDistrict() + '\'' + ", street='" + bdLocation.getStreet() + '\'' + ", streetNumber='" + bdLocation.getStreetNumber() + '\'' + ", locationDescribe='" + bdLocation.getLocationDescribe() + '\'' + ", buildingID='" + bdLocation.getBuildingID() + '\'' + ", buildingName='" + bdLocation.getBuildingName() + '\'' + ", floor='" + bdLocation.getFloor() + '\'' + ", speed=" + bdLocation.getSpeed() + '\'' + ", satelliteNumber=" + bdLocation.getSatelliteNumber() + '\'' + ", altitude=" + bdLocation.getAltitude() + '\'' + ", direction=" + bdLocation.getDirection() + '\'' + ", operators=" + bdLocation.getOperators() + '\'' + "}"; Log.d("@@@", str); Log.d("@@@", "====================BDLocation End===================="); }
Example 8
Source File: LocationUtil.java From apollo-DuerOS with Apache License 2.0 | 5 votes |
@Override public void onReceiveLocation(BDLocation bdLocation) { if (bdLocation.getLocType() == BDLocation.TypeGpsLocation) { // GPS Location LogUtil.d(TAG, "getLocType: TypeGpsLocation"); } else if (bdLocation.getLocType() == BDLocation.TypeNetWorkLocation) { // network location LogUtil.d(TAG, "getLocType: TypeNetWorkLocation"); } else if (bdLocation.getLocType() == BDLocation.TypeOffLineLocation) { // offline location LogUtil.d(TAG, "getLocType: TypeOffLineLocation"); } else { LogUtil.e(TAG, "getLocType: Type Error, type=" + bdLocation.getLocType()); return; } mLocationGCJ02 = bdLocation; mLocationBD09LL = convertToBD09LL(bdLocation); mLastLongitude = bdLocation.getLongitude(); mLastLatitude = bdLocation.getLatitude(); mLastLongitudeBd09ll = mLocationBD09LL.getLongitude(); mLastLatitudeBd09ll = mLocationBD09LL.getLatitude(); if ((mRequestLocCnt++) == SAFE_POSITION_DURATION_TIME) { safeLastPosition(); mRequestLocCnt = 0; } if (mOnLocationListener != null) { mOnLocationListener.onLocationChange(mLocationBD09LL.getLatitude(), mLocationBD09LL.getLongitude(), mLocationBD09LL.getRadius(), mLocationBD09LL.getDirection()); } }
Example 9
Source File: BaiduMapActivity.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 5 votes |
@Override public void onReceiveLocation(BDLocation location) { if (location == null) { return; } Log.d("map", "On location change received:" + location); Log.d("map", "addr:" + location.getAddrStr()); sendButton.setEnabled(true); if (progressDialog != null) { progressDialog.dismiss(); } if (lastLocation != null) { if (lastLocation.getLatitude() == location.getLatitude() && lastLocation.getLongitude() == location.getLongitude()) { Log.d("map", "same location, skip refresh"); // mMapView.refresh(); //need this refresh? return; } } lastLocation = location; mBaiduMap.clear(); LatLng llA = new LatLng(lastLocation.getLatitude(), lastLocation.getLongitude()); CoordinateConverter converter= new CoordinateConverter(); converter.coord(llA); converter.from(CoordinateConverter.CoordType.COMMON); LatLng convertLatLng = converter.convert(); OverlayOptions ooA = new MarkerOptions().position(convertLatLng).icon(BitmapDescriptorFactory .fromResource(R.drawable.icon_marka)) .zIndex(4).draggable(true); mBaiduMap.addOverlay(ooA); MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(convertLatLng, 17.0f); mBaiduMap.animateMapStatus(u); }
Example 10
Source File: BaiduAddress.java From AssistantBySDK with Apache License 2.0 | 5 votes |
public void setBD09LL() { BDLocation bl = new BDLocation(); bl.setLatitude(this.latitude); bl.setLongitude(this.longitude); bl = LocationClient.getBDLocationInCoorType(bl, BDLocation.BDLOCATION_GCJ02_TO_BD09LL); this.latitude = bl.getLatitude(); this.longitude = bl.getLongitude(); }
Example 11
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 12
Source File: EaseBaiduMapActivity.java From Social with Apache License 2.0 | 5 votes |
@Override public void onReceiveLocation(BDLocation location) { if (location == null) { return; } Log.d("map", "On location change received:" + location); Log.d("map", "addr:" + location.getAddrStr()); sendButton.setEnabled(true); if (progressDialog != null) { progressDialog.dismiss(); } if (lastLocation != null) { if (lastLocation.getLatitude() == location.getLatitude() && lastLocation.getLongitude() == location.getLongitude()) { Log.d("map", "same location, skip refresh"); // mMapView.refresh(); //need this refresh? return; } } lastLocation = location; mBaiduMap.clear(); LatLng llA = new LatLng(lastLocation.getLatitude(), lastLocation.getLongitude()); CoordinateConverter converter= new CoordinateConverter(); converter.coord(llA); converter.from(CoordinateConverter.CoordType.COMMON); LatLng convertLatLng = converter.convert(); OverlayOptions ooA = new MarkerOptions().position(convertLatLng).icon(BitmapDescriptorFactory .fromResource(R.drawable.ease_icon_marka)) .zIndex(4).draggable(true); mBaiduMap.addOverlay(ooA); MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(convertLatLng, 17.0f); mBaiduMap.animateMapStatus(u); }
Example 13
Source File: MapActivity.java From BaiduMap-TrafficAssistant with MIT License | 4 votes |
@Override public void onReceiveLocation(BDLocation location) { MyLocationData data = new MyLocationData.Builder()// .direction(mCurrentX)// .accuracy(location.getRadius())// .latitude(location.getLatitude())// .longitude(location.getLongitude())// .build(); mBaiduMap.setMyLocationData(data); // 设置自定义图标 MyLocationConfiguration config = new MyLocationConfiguration( mLocationMode, true, mIconLocation); mBaiduMap.setMyLocationConfigeration(config); // 更新经纬度 mLatitude = location.getLatitude(); mLongitude = location.getLongitude(); if (isFirstIn) { LatLng latlng = new LatLng(location.getLatitude(), location.getLongitude()); MapStatusUpdate msu = MapStatusUpdateFactory.newLatLng(latlng); mBaiduMap.animateMapStatus(msu); isFirstIn = false; Toast.makeText(context, location.getAddrStr(), Toast.LENGTH_SHORT).show(); Log.i("TAG", location.getAddrStr() + "\n" + location.getAltitude() + "" + "\n" + location.getCity() + "\n" + location.getCityCode() + "\n" + location.getCoorType() + "\n" + location.getDirection() + "\n" + location.getDistrict() + "\n" + location.getFloor() + "\n" + location.getLatitude() + "\n" + location.getLongitude() + "\n" + location.getNetworkLocationType() + "\n" + location.getProvince() + "\n" + location.getSatelliteNumber() + "\n" + location.getStreet() + "\n" + location.getStreetNumber() + "\n" + location.getTime() + "\n"); // 弹出对话框显示定位信息; Builder builder = new Builder(context); builder.setTitle("为您获得的定位信息:"); builder.setMessage("当前位置:" + location.getAddrStr() + "\n" + "城市编号:" + location.getCityCode() + "\n" + "定位时间:" + location.getTime() + "\n" + "当前纬度:" + location.getLatitude() + "\n" + "当前经度:" + location.getLongitude()); builder.setPositiveButton("确定", null); AlertDialog alertDialog = builder.create(); alertDialog.show(); }// if }
Example 14
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); }
Example 15
Source File: RouteService.java From Mobike with Apache License 2.0 | 4 votes |
@Override public void onReceiveLocation(BDLocation bdLocation) { if (null == bdLocation) return; //"4.9E-324"表示目前所处的环境(室内或者是网络状况不佳)造成无法获取到经纬度 if ("4.9E-324".equals(String.valueOf(bdLocation.getLatitude())) || "4.9E-324".equals(String.valueOf(bdLocation.getLongitude()))) { return; }//过滤百度定位失败 Log.d("gaolei", "RouteService---------getAddrStr()-------------" + bdLocation.getAddrStr()); double routeLat = bdLocation.getLatitude(); double routeLng = bdLocation.getLongitude(); RoutePoint routePoint = new RoutePoint(); routePoint.setRouteLat(routeLat); routePoint.setRouteLng(routeLng); if (routPointList.size() == 0) routPointList.add(routePoint); else { RoutePoint lastPoint = routPointList.get(routPointList.size() - 1); if (routeLat == lastPoint.getRouteLat() && routeLng == lastPoint.getRouteLng()) { } else { LatLng lastLatLng = new LatLng(lastPoint.getRouteLat(), lastPoint.getRouteLng()); LatLng currentLatLng = new LatLng(routeLat, routeLng); if (routeLat > 0 && routeLng > 0) { double distantce = DistanceUtil.getDistance(lastLatLng, currentLatLng); // Log.d("gaolei", "distantce--------------" + distantce); if (distantce > 5) { routPointList.add(routePoint); totalDistance += distantce; } } } } totalTime = (int) (System.currentTimeMillis() - beginTime) / 1000 / 60; totalPrice = (float) (Math.floor(totalTime / 30) * 0.5 + 0.5); // Log.d("gaolei", "biginTime--------------" + beginTime); Log.d("gaolei", "totalTime--------------" + totalTime); Log.d("gaolei", "totalDistance--------------" + totalDistance); startNotifi(totalTime + "分钟", totalDistance + "米", totalPrice + "元"); Intent intent = new Intent("com.locationreceiver"); Bundle bundle = new Bundle(); bundle.putString("totalTime", totalTime + "分钟"); bundle.putString("totalDistance", totalDistance + "米"); bundle.putString("totalPrice", totalPrice + "元"); intent.putExtras(bundle); sendBroadcast(intent); }
Example 16
Source File: BaiduMapSelectPoiFragment.java From BmapLite with Apache License 2.0 | 4 votes |
@Override public void onReceiveLocation(BDLocation location) { // map view 销毁后不在处理新接收的位置 if (location == null || mMapView == null) { return; } if (null == BApp.MY_LOCATION) { BApp.MY_LOCATION = new MyPoiModel(TypeMap.TYPE_BAIDU); } BApp.MY_LOCATION.setName("我的位置"); BApp.MY_LOCATION.setLatitude(location.getLatitude()); BApp.MY_LOCATION.setLongitude(location.getLongitude()); BApp.MY_LOCATION.setAltitude(location.getAltitude()); BApp.MY_LOCATION.setAccuracy(location.getRadius()); CacheInteracter interacter = new CacheInteracter(getActivity()); if (BApp.MY_LOCATION.getLongitude() == 0 || BApp.MY_LOCATION.getLatitude() == 0 ||BApp.MY_LOCATION.getLongitude() == 4.9E-324 || BApp.MY_LOCATION.getLatitude() == 4.9E-324){ BApp.MY_LOCATION.setLatitude(interacter.getLatitude()); BApp.MY_LOCATION.setLongitude(interacter.getLongitude()); } MyLocationData locData = new MyLocationData.Builder() .direction(mXDirection) .latitude(BApp.MY_LOCATION.getLatitude()) .longitude(BApp.MY_LOCATION.getLongitude()) .accuracy((float) BApp.MY_LOCATION.getAccuracy()) .build(); mBaiduMap.setMyLocationData(locData); if (isFirstLoc || isRequest) { if (location.getLatitude() == 0 || location.getLongitude() == 0 || location.getLatitude() == 4.9E-324 || location.getLongitude() == 4.9E-324) { onMessage("无法获取到位置信息,请连接网络后再试"); } MapStatus.Builder builder = new MapStatus.Builder(); builder.target(new LatLng(BApp.MY_LOCATION.getLatitude(), BApp.MY_LOCATION.getLongitude())).zoom(18f); mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); interacter.setLatitude(BApp.MY_LOCATION.getLatitude()); interacter.setLongitude(BApp.MY_LOCATION.getLongitude()); isRequest = false; isFirstLoc = false; } }
Example 17
Source File: RouteBaiduBusActivity.java From BmapLite with Apache License 2.0 | 4 votes |
@Override public void onReceiveLocation(BDLocation location) { // map view 销毁后不在处理新接收的位置 if (location == null || mMapView == null) { return; } if (null == BApp.MY_LOCATION) { BApp.MY_LOCATION = new MyPoiModel(TypeMap.TYPE_BAIDU); } BApp.MY_LOCATION.setName("我的位置"); BApp.MY_LOCATION.setLatitude(location.getLatitude()); BApp.MY_LOCATION.setLongitude(location.getLongitude()); BApp.MY_LOCATION.setAltitude(location.getAltitude()); BApp.MY_LOCATION.setAccuracy(location.getRadius()); CacheInteracter interacter = new CacheInteracter(this); if (BApp.MY_LOCATION.getLongitude() == 0 || BApp.MY_LOCATION.getLatitude() == 0 || BApp.MY_LOCATION.getLongitude() == 4.9E-324 || BApp.MY_LOCATION.getLatitude() == 4.9E-324) { BApp.MY_LOCATION.setLatitude(interacter.getLatitude()); BApp.MY_LOCATION.setLongitude(interacter.getLongitude()); } MyLocationData locData = new MyLocationData.Builder() .direction(mXDirection) .latitude(BApp.MY_LOCATION.getLatitude()) .longitude(BApp.MY_LOCATION.getLongitude()) .accuracy((float) BApp.MY_LOCATION.getAccuracy()) .build(); mBaiduMap.setMyLocationData(locData); if (isFirstLoc || isRequest) { if (location.getLatitude() == 0 || location.getLongitude() == 0 || location.getLatitude() == 4.9E-324 || location.getLongitude() == 4.9E-324) { onMessage("无法获取到位置信息,请连接网络后再试"); } MapStatus.Builder builder = new MapStatus.Builder(); builder.target(new LatLng(BApp.MY_LOCATION.getLatitude(), BApp.MY_LOCATION.getLongitude())).zoom(18f); mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); mSearchInteracter.searchLatLng(BApp.MY_LOCATION.getLatitude(), BApp.MY_LOCATION.getLongitude(), 1, this); interacter.setLatitude(BApp.MY_LOCATION.getLatitude()); interacter.setLongitude(BApp.MY_LOCATION.getLongitude()); isRequest = false; isFirstLoc = false; } }
Example 18
Source File: RouteBaiduBusActivity.java From BmapLite with GNU General Public License v3.0 | 4 votes |
@Override public void onReceiveLocation(BDLocation location) { // map view 销毁后不在处理新接收的位置 if (location == null || mMapView == null) { return; } if (null == BApp.MY_LOCATION) { BApp.MY_LOCATION = new MyPoiModel(TypeMap.TYPE_BAIDU); } BApp.MY_LOCATION.setName("我的位置"); BApp.MY_LOCATION.setLatitude(location.getLatitude()); BApp.MY_LOCATION.setLongitude(location.getLongitude()); BApp.MY_LOCATION.setAltitude(location.getAltitude()); BApp.MY_LOCATION.setAccuracy(location.getRadius()); CacheInteracter interacter = new CacheInteracter(this); if (BApp.MY_LOCATION.getLongitude() == 0 || BApp.MY_LOCATION.getLatitude() == 0 || BApp.MY_LOCATION.getLongitude() == 4.9E-324 || BApp.MY_LOCATION.getLatitude() == 4.9E-324) { BApp.MY_LOCATION.setLatitude(interacter.getLatitude()); BApp.MY_LOCATION.setLongitude(interacter.getLongitude()); } MyLocationData locData = new MyLocationData.Builder() .direction(mXDirection) .latitude(BApp.MY_LOCATION.getLatitude()) .longitude(BApp.MY_LOCATION.getLongitude()) .accuracy((float) BApp.MY_LOCATION.getAccuracy()) .build(); mBaiduMap.setMyLocationData(locData); if (isFirstLoc || isRequest) { if (location.getLatitude() == 0 || location.getLongitude() == 0 || location.getLatitude() == 4.9E-324 || location.getLongitude() == 4.9E-324) { onMessage("无法获取到位置信息,请连接网络后再试"); } MapStatus.Builder builder = new MapStatus.Builder(); builder.target(new LatLng(BApp.MY_LOCATION.getLatitude(), BApp.MY_LOCATION.getLongitude())).zoom(18f); mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); mSearchInteracter.searchLatLng(BApp.MY_LOCATION.getLatitude(), BApp.MY_LOCATION.getLongitude(), 1, this); interacter.setLatitude(BApp.MY_LOCATION.getLatitude()); interacter.setLongitude(BApp.MY_LOCATION.getLongitude()); isRequest = false; isFirstLoc = false; } }
Example 19
Source File: BaiduMapSelectPoiFragment.java From BmapLite with GNU General Public License v3.0 | 4 votes |
@Override public void onReceiveLocation(BDLocation location) { // map view 销毁后不在处理新接收的位置 if (location == null || mMapView == null) { return; } if (null == BApp.MY_LOCATION) { BApp.MY_LOCATION = new MyPoiModel(TypeMap.TYPE_BAIDU); } BApp.MY_LOCATION.setName("我的位置"); BApp.MY_LOCATION.setLatitude(location.getLatitude()); BApp.MY_LOCATION.setLongitude(location.getLongitude()); BApp.MY_LOCATION.setAltitude(location.getAltitude()); BApp.MY_LOCATION.setAccuracy(location.getRadius()); CacheInteracter interacter = new CacheInteracter(getActivity()); if (BApp.MY_LOCATION.getLongitude() == 0 || BApp.MY_LOCATION.getLatitude() == 0 ||BApp.MY_LOCATION.getLongitude() == 4.9E-324 || BApp.MY_LOCATION.getLatitude() == 4.9E-324){ BApp.MY_LOCATION.setLatitude(interacter.getLatitude()); BApp.MY_LOCATION.setLongitude(interacter.getLongitude()); } MyLocationData locData = new MyLocationData.Builder() .direction(mXDirection) .latitude(BApp.MY_LOCATION.getLatitude()) .longitude(BApp.MY_LOCATION.getLongitude()) .accuracy((float) BApp.MY_LOCATION.getAccuracy()) .build(); mBaiduMap.setMyLocationData(locData); if (isFirstLoc || isRequest) { if (location.getLatitude() == 0 || location.getLongitude() == 0 || location.getLatitude() == 4.9E-324 || location.getLongitude() == 4.9E-324) { onMessage("无法获取到位置信息,请连接网络后再试"); } MapStatus.Builder builder = new MapStatus.Builder(); builder.target(new LatLng(BApp.MY_LOCATION.getLatitude(), BApp.MY_LOCATION.getLongitude())).zoom(18f); mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); interacter.setLatitude(BApp.MY_LOCATION.getLatitude()); interacter.setLongitude(BApp.MY_LOCATION.getLongitude()); isRequest = false; isFirstLoc = false; } }
Example 20
Source File: BaiduMapRouteFragment.java From BmapLite with GNU General Public License v3.0 | 4 votes |
@Override public void onReceiveLocation(BDLocation location) { // map view 销毁后不在处理新接收的位置 if (location == null || mMapView == null) { return; } if (null == BApp.MY_LOCATION) { BApp.MY_LOCATION = new MyPoiModel(TypeMap.TYPE_BAIDU); } BApp.MY_LOCATION.setName("我的位置"); BApp.MY_LOCATION.setLatitude(location.getLatitude()); BApp.MY_LOCATION.setLongitude(location.getLongitude()); BApp.MY_LOCATION.setAltitude(location.getAltitude()); BApp.MY_LOCATION.setAccuracy(location.getRadius()); CacheInteracter interacter = new CacheInteracter(getActivity()); if (BApp.MY_LOCATION.getLongitude() == 0 || BApp.MY_LOCATION.getLatitude() == 0 ||BApp.MY_LOCATION.getLongitude() == 4.9E-324 || BApp.MY_LOCATION.getLatitude() == 4.9E-324){ BApp.MY_LOCATION.setLatitude(interacter.getLatitude()); BApp.MY_LOCATION.setLongitude(interacter.getLongitude()); } MyLocationData locData = new MyLocationData.Builder() .direction(mXDirection) .latitude(BApp.MY_LOCATION.getLatitude()) .longitude(BApp.MY_LOCATION.getLongitude()) .accuracy((float) BApp.MY_LOCATION.getAccuracy()) .build(); mBaiduMap.setMyLocationData(locData); if (isFirstLoc || isRequest) { if (location.getLatitude() == 0 || location.getLongitude() == 0 || location.getLatitude() == 4.9E-324 || location.getLongitude() == 4.9E-324){ onMessage("无法获取到位置信息,请连接网络后再试"); } MapStatus.Builder builder = new MapStatus.Builder(); builder.target(new LatLng(BApp.MY_LOCATION.getLatitude(), BApp.MY_LOCATION.getLongitude())).zoom(18f); mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); mSearchInteracter.searchLatLng(BApp.MY_LOCATION.getLatitude(), BApp.MY_LOCATION.getLongitude(), 1, this); interacter.setLatitude(BApp.MY_LOCATION.getLatitude()); interacter.setLongitude(BApp.MY_LOCATION.getLongitude()); isRequest = false; isFirstLoc = false; } }