今天定位返回 I/坐标系~~: :(4.9E-324,4.9E-324)
发起定位
/初始化定位 private void initLocationListener() { locationClient = new LocationClient(this); locationClient.registerLocationListener(this); LocationClientOption option = new LocationClientOption(); option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);//设置定位模式 option.setCoorType("bd09ll");//返回的定位结果是百度经纬度,默认值gcj02 option.setOpenGps(true); option.setIsNeedAddress(true); locationClient.setLocOption(option); locationClient.start(); }
//百度定位的回调 @Override public void onReceiveLocation(BDLocation location) { double lat = location.getLatitude(); double lng = location.getLongitude(); if ("4.9E-324".equals(location.getLatitude())) { showToast("定位失败,请查看手机是否开启了定位权限"); } addressPoint = lng + "," + lat; Log.i("坐标系~~", ":(" + addressPoint + ")"); if (!TextUtils.isEmpty(addressPoint)) { locationClient.unRegisterLocationListener(this); locationClient.stop(); } }
莫名其妙的定位结果 查了原因 就是百度定位失败了 百度坐标定位失败 返回坐标默认为4.9E-324,4.9E-324 原因是我在用不同手机做测试时 有的品牌手机默认app安装后 不开启gps定位功能 可以在遇到这个结果是提示手动查询是否开启了应用的这个权限 解决