|
...
|
...
|
@@ -114,6 +114,7 @@ Page({ |
|
|
|
northeast:{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mapDataLast:null,//最后一次成功视角,防止地图视角丢失
|
|
|
|
onReady: function () {
|
|
|
|
this.mapCtx = wx.createMapContext('map')
|
|
|
|
// this.mapCtx.moveToLocation({
|
|
...
|
...
|
@@ -372,8 +373,19 @@ Page({ |
|
|
|
hasInRegionFlag:false,
|
|
|
|
hasInRegion(){//定位是否在地图视野内
|
|
|
|
let map = this.mapData;
|
|
|
|
if(!map.region.northeast.latitude || !map.region.northeast.longitude) return {flag:false,msg:'未获得视野'};//未获得视野
|
|
|
|
if(!map.region.southwest.latitude || !map.region.southwest.longitude) return {flag:false,msg:'未获得视野'};//未获得视野
|
|
|
|
if(!map.region.northeast.latitude || !map.region.northeast.longitude) {//未获得视野
|
|
|
|
if(this.mapDataLast){
|
|
|
|
this.mapData=this.mapDataLast
|
|
|
|
}
|
|
|
|
return {flag:false,msg:'未获得视野',map:map,mapDataLast:this.mapDataLast};
|
|
|
|
}
|
|
|
|
if(!map.region.southwest.latitude || !map.region.southwest.longitude) {//未获得视野
|
|
|
|
if(this.mapDataLast){
|
|
|
|
this.mapData=this.mapDataLast
|
|
|
|
}
|
|
|
|
return {flag:false,msg:'未获得视野',map:map,mapDataLast:this.mapDataLast};
|
|
|
|
}
|
|
|
|
this.mapDataLast=JSON.parse(JSON.stringify(this.mapData));
|
|
|
|
if(this.hasInRegionFlag) return {flag:true,msg:'二次获取'};
|
|
|
|
if(!this.user.latitude) return {flag:false,msg:'用户无定位'};//用户无定位
|
|
|
|
//if(this.user.latitude==def_latitude && this.user.longitude==def_longitude) return false;//默认位置
|
...
|
...
|
|