|
@@ -114,6 +114,7 @@ Page({ |
|
@@ -114,6 +114,7 @@ Page({ |
|
114
|
northeast:{},
|
114
|
northeast:{},
|
|
115
|
},
|
115
|
},
|
|
116
|
},
|
116
|
},
|
|
|
|
117
|
+ mapDataLast:null,//最后一次成功视角,防止地图视角丢失
|
|
117
|
onReady: function () {
|
118
|
onReady: function () {
|
|
118
|
this.mapCtx = wx.createMapContext('map')
|
119
|
this.mapCtx = wx.createMapContext('map')
|
|
119
|
// this.mapCtx.moveToLocation({
|
120
|
// this.mapCtx.moveToLocation({
|
|
@@ -372,8 +373,19 @@ Page({ |
|
@@ -372,8 +373,19 @@ Page({ |
|
372
|
hasInRegionFlag:false,
|
373
|
hasInRegionFlag:false,
|
|
373
|
hasInRegion(){//定位是否在地图视野内
|
374
|
hasInRegion(){//定位是否在地图视野内
|
|
374
|
let map = this.mapData;
|
375
|
let map = this.mapData;
|
|
375
|
- if(!map.region.northeast.latitude || !map.region.northeast.longitude) return {flag:false,msg:'未获得视野'};//未获得视野
|
|
|
|
376
|
- if(!map.region.southwest.latitude || !map.region.southwest.longitude) return {flag:false,msg:'未获得视野'};//未获得视野
|
376
|
+ if(!map.region.northeast.latitude || !map.region.northeast.longitude) {//未获得视野
|
|
|
|
377
|
+ if(this.mapDataLast){
|
|
|
|
378
|
+ this.mapData=this.mapDataLast
|
|
|
|
379
|
+ }
|
|
|
|
380
|
+ return {flag:false,msg:'未获得视野',map:map,mapDataLast:this.mapDataLast};
|
|
|
|
381
|
+ }
|
|
|
|
382
|
+ if(!map.region.southwest.latitude || !map.region.southwest.longitude) {//未获得视野
|
|
|
|
383
|
+ if(this.mapDataLast){
|
|
|
|
384
|
+ this.mapData=this.mapDataLast
|
|
|
|
385
|
+ }
|
|
|
|
386
|
+ return {flag:false,msg:'未获得视野',map:map,mapDataLast:this.mapDataLast};
|
|
|
|
387
|
+ }
|
|
|
|
388
|
+ this.mapDataLast=JSON.parse(JSON.stringify(this.mapData));
|
|
377
|
if(this.hasInRegionFlag) return {flag:true,msg:'二次获取'};
|
389
|
if(this.hasInRegionFlag) return {flag:true,msg:'二次获取'};
|
|
378
|
if(!this.user.latitude) return {flag:false,msg:'用户无定位'};//用户无定位
|
390
|
if(!this.user.latitude) return {flag:false,msg:'用户无定位'};//用户无定位
|
|
379
|
//if(this.user.latitude==def_latitude && this.user.longitude==def_longitude) return false;//默认位置
|
391
|
//if(this.user.latitude==def_latitude && this.user.longitude==def_longitude) return false;//默认位置
|