Commit e9c9204e authored by fengruiyu's avatar fengruiyu

用户不给定位权限默认定位到北京天安门

parent 6090d3b9
......@@ -76,7 +76,7 @@ var vm = new Vue({
point = B_MAP.getCenter();
}
console.log(this.NOWUSEBAIDU,point)
console.log(this.NOWUSEBAIDU, point)
getLocation(point, function (res) {
if (res.c) {
......@@ -107,9 +107,13 @@ var vm = new Vue({
}
},
initZsMap: function (pointStr) {
console.log(">>>>>>",pointStr)
console.log(">>>>>>>>>>>>>>",pointStr)
var th = this;
var inMsg = JSON.parse(pointStr)
if (inMsg.lat == 0 || inMsg.lng == 0 ||
inMsg.lat == '0' || inMsg.lng == '0') {
inMsg = {"lat": 39.90960456049752, "lng": 116.3972282409668, "inner": 0};
}
var point = {lat: parseFloat(inMsg.lat), lng: parseFloat(inMsg.lng)};
if (inMsg.inner == null) {
getLocation(point, function (res) {
......@@ -211,13 +215,12 @@ var vm = new Vue({
},
B_initmap: function (point, zoomLevel) {
this.NOWUSEBAIDU = true;
console.log("initB==>", point, zoomLevel)
// setTimeout(function () {
if (zoomLevel == undefined || zoomLevel == null)
zoomLevel = 6;
var th = vm;
if (th.B_MAPINITED == false) {
console.log(">>>>>>>initB==>", point, zoomLevel)
th.B_MAPINITED = true;
// 百度地图API功能
// $("#map").hide();
......@@ -247,15 +250,13 @@ var vm = new Vue({
});
} else {
B_MAP.centerAndZoom(new BMap.Point(point.lng, point.lat), zoomLevel); // 初始化地图,设置中心点坐标和地图级别
B_MAP.centerAndZoom(new BMap.Point(point.lng, point.lat), zoomLevel); // 初始化地图,设置中心点坐标和地图级别
setTimeout(function(){
B_MAP.centerAndZoom(new BMap.Point(point.lng, point.lat), zoomLevel); // 初始化地图,设置中心点坐标和地图级别
B_MAP.centerAndZoom(new BMap.Point(point.lng, point.lat), zoomLevel); // 初始化地图,设置中心点坐标和地图级别
},500)
//console.log(">>>>>>>", point, B_MAP.getCenter())
console.log(">>>>>>>cB==>", B_MAP.getCenter().lat, B_MAP.getCenter().lng, zoomLevel)
console.log(">>>>>>>", point, B_MAP.getCenter())
}
// },500)
},
......@@ -293,11 +294,11 @@ var vm = new Vue({
G_MAP.setCenter(point)
}
// if (!this.NOWUSEBAIDU && this.B_MAPINITED) {
// var bpoint = toBPoint(point)
// console.log("同步百度中心")
// B_MAP.setCenter(bpoint)
// }
if (!this.NOWUSEBAIDU && this.B_MAPINITED) {
var bpoint = toBPoint(point)
console.log("同步百度中心")
B_MAP.setCenter(bpoint)
}
}
}
})
......@@ -306,7 +307,6 @@ var vm = new Vue({
window.onload = function () {
// console.log("window.load_+++++++++++=")170.89184781519282,-9.108152184807182
allIsOk();
//vm.initZsMap('{"lat": 39.30336768549658, "lng": 350.8918478151928}')
}
......
......@@ -47,9 +47,13 @@ class GoogleMapFragment() : BaseFragment<ActivityGoogleMapBinding, HomeViewModel
private var gps = GPS(39.915121, 116.403947,0)
inner class MyLocationListener : BDLocationListener {
override fun onReceiveLocation(location: BDLocation?) {
override fun onReceiveLocation(location: BDLocation?) {//4.9E-324 4.9E-324
if( location?.latitude == 4.9E-324 ||location?.longitude == 4.9E-324){
return
}
gps.lat = location?.latitude?:39.915121
gps.lng = location?.longitude?:116.403947
KLog.e("onReceiveLocation","${location?.latitude} --- ${location?.longitude}")
}
}
......
......@@ -261,40 +261,43 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
var positioningBean: PositioningBean? = null
inner class MyLocationListener : BDLocationListener {
override fun onReceiveLocation(location: BDLocation) {
override fun onReceiveLocation(location: BDLocation?) {
if( location?.latitude == 4.9E-324 ||location?.longitude == 4.9E-324){
return
}
if (sp == null) {
sp = SPUtils.getInstance(SPUtils.POSITIONING_MAP)
}
if (positioningBean == null) {
positioningBean = PositioningBean()
}
positioningBean?.latitude = location.latitude
positioningBean?.longitude = location.longitude
positioningBean?.countryCode = location.countryCode
positioningBean?.country = location.country
positioningBean?.province = location.province
positioningBean?.city = location.city
positioningBean?.district = location.district
positioningBean?.town = location.town
positioningBean?.street = location.street
positioningBean?.addrStr = location.addrStr
positioningBean?.latitude = location?.latitude
positioningBean?.longitude = location?.longitude
positioningBean?.countryCode = location?.countryCode
positioningBean?.country = location?.country
positioningBean?.province = location?.province
positioningBean?.city = location?.city
positioningBean?.district = location?.district
positioningBean?.town = location?.town
positioningBean?.street = location?.street
positioningBean?.addrStr = location?.addrStr
sp?.encode(SPUtils.POSITIONING_MAP, Gson().toJson(positioningBean).toString())
// MapView 销毁后不在处理新接收的位置
mBaiduMap?.apply {
mCurrentLat = location.latitude
mCurrentLon = location.longitude
mCurrentAccracy = location.radius
mCurrentLat = location?.latitude?:0.0
mCurrentLon = location?.longitude?:0.0
mCurrentAccracy = location?.radius?:0f
myLocationData = MyLocationData.Builder()
.accuracy(location.radius) // 设置定位数据的精度信息,单位:米
.accuracy(location?.radius?:0f) // 设置定位数据的精度信息,单位:米
.direction(mCurrentDirection.toFloat()) // 此处设置开发者获取到的方向信息,顺时针0-360
.latitude(location.latitude)
.longitude(location.longitude)
.latitude(location?.latitude?:0.0)
.longitude(location?.longitude?:0.0)
.build()
this.setMyLocationData(myLocationData)
if (isFirstLoc) {
isFirstLoc = false
val ll = LatLng(location.latitude, location.longitude)
val ll = LatLng(location?.latitude?:0.0, location?.longitude?:0.0)
val builder = MapStatus.Builder()
builder.target(ll).zoom(18.0f)
this.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment