Commit abd7c0fb24561552b7ef011dc59674bfaad95984

Authored by wangfan
1 parent 18565e65

C端地图

... ... @@ -20,7 +20,7 @@ App({
system:{},
shareTicket:"",
onLaunch: async function (opt) {
console.log('onLaunch',opt);
console.log('onLaunch',opt);
mta.App.init({
"appID":"500667280",
"eventID":"500667287",
... ...
... ... @@ -114,6 +114,7 @@ Page({
titleBarHeight:h,
})
this.getPos(systemInfo);
this.getMarkers();
},
/**
... ... @@ -168,12 +169,10 @@ Page({
this.mapCtx.getRegion({
success:(res)=>{
console.log('regionchange.getRegion',res)
if(res.southwest.latitude!=this.mapData.region.southwest.latitude) {
//if(res.southwest.latitude!=this.mapData.region.southwest.latitude) {
this.mapData.region = res
setTimeout(()=>{
this.getMarkers();
},300)
}
this.getMarkers();
//}
},
})
}).catch((e) => {
... ... @@ -266,10 +265,10 @@ Page({
this.mapCtx.getRegion({
success:(res)=>{
console.log('mapUpdated.getRegion',res)
if(res.southwest.latitude!=this.mapData.region.southwest.latitude){
//if(res.southwest.latitude!=this.mapData.region.southwest.latitude){
this.mapData.region=res
//this.getMarkers();
}
//}
},
})
... ... @@ -312,11 +311,30 @@ Page({
}
this.setData(obj)
},
hasInRegionFlag:false,
hasInRegion(){//定位是否在地图视野内
if(this.hasInRegionFlag) return true;
if(!this.user.latitude) return false;//用户无定位
if(this.user.latitude==23.099994 && this.user.longitude==113.324520) return false;//默认位置
let map = this.mapData;
if(!map.region.northeast.latitude || !map.region.northeast.longitude) return false;//未获得视野
if(!map.region.southwest.latitude || !map.region.southwest.longitude) return false;//未获得视野
///判断定位 首次 进入视野
if(this.user.latitude>map.region.southwest.latitude
&& this.user.longitude>map.region.southwest.longitude
&& this.user.latitude<map.region.northeast.latitude
&& this.user.longitude<map.region.northeast.longitude){
this.hasInRegionFlag=true;
return true;
}
return false;
},
async getMarkers(){
let cmap=this.data.map;
let map = this.mapData;
//console.log('getMarkers',map.region);
if(!map.region.northeast.latitude) {
if(!this.hasInRegion()) {
console.log('FAIL:::',this.user,map)
return setTimeout(()=>{
this.getMarkers();
},300)
... ...