|
...
|
...
|
@@ -114,7 +114,9 @@ Page({ |
|
|
|
statusBarHeight: pt,
|
|
|
|
titleBarHeight:h,
|
|
|
|
})
|
|
|
|
this.getPos(systemInfo);
|
|
|
|
//this.getPos(systemInfo);
|
|
|
|
this.systemInfo=systemInfo
|
|
|
|
this.selectComponent('#getpos').getPos();
|
|
|
|
this.getMarkers();
|
|
|
|
},
|
|
|
|
|
|
...
|
...
|
@@ -152,68 +154,30 @@ Page({ |
|
|
|
onShareAppMessage: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
getPos(systemInfo){
|
|
|
|
this._getPos().then(res => {
|
|
|
|
console.log('wx.getLocation.then', res);
|
|
|
|
this.hasGetLocation=true;
|
|
|
|
let map = this.data.map;
|
|
|
|
map.latitude = res.latitude;
|
|
|
|
map.longitude = res.longitude;
|
|
|
|
onpos(e){
|
|
|
|
let res=e.detail;
|
|
|
|
this.hasGetLocation=true;
|
|
|
|
let map = this.data.map;
|
|
|
|
map.latitude = res.latitude;
|
|
|
|
map.longitude = res.longitude;
|
|
|
|
|
|
|
|
this.user.latitude = res.latitude;
|
|
|
|
this.user.longitude = res.longitude;
|
|
|
|
|
|
|
|
console.log('onShow.getPos',systemInfo,getApp().system.windowHeight-this.transverseViewHeight)
|
|
|
|
map.height = systemInfo.windowHeight-this.transverseViewHeight
|
|
|
|
this.setData({
|
|
|
|
map: map,
|
|
|
|
})
|
|
|
|
this.user.latitude = res.latitude;
|
|
|
|
this.user.longitude = res.longitude;
|
|
|
|
map.height = this.systemInfo.windowHeight-this.transverseViewHeight
|
|
|
|
this.setData({
|
|
|
|
map: map,
|
|
|
|
})
|
|
|
|
if(this.mapCtx){
|
|
|
|
this.mapCtx.getRegion({
|
|
|
|
success:(res)=>{
|
|
|
|
console.log('regionchange.getRegion',res)
|
|
|
|
//if(res.southwest.latitude!=this.mapData.region.southwest.latitude) {
|
|
|
|
this.mapData.region = res
|
|
|
|
//this.getMarkers();
|
|
|
|
this.mapData.region = res
|
|
|
|
//this.getMarkers();
|
|
|
|
//}
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}).catch((e) => {
|
|
|
|
this.hasGetLocation=false;
|
|
|
|
console.log('wx.getLocation.catch', e);
|
|
|
|
if ('getLocation:fail auth deny' == e.errMsg
|
|
|
|
|| 'getLocation:fail:auth denied' == e.errMsg
|
|
|
|
|| 'getLocation:fail authorize no response' == e.errMsg) {
|
|
|
|
this.selectComponent('#showModal').options({
|
|
|
|
header: '定位失败',
|
|
|
|
body: '需要地理位置授权'
|
|
|
|
}).show();
|
|
|
|
} else {
|
|
|
|
setTimeout(() => {
|
|
|
|
this.getPos(systemInfo)
|
|
|
|
}, 500)
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
},
|
|
|
|
_getPos(){
|
|
|
|
return new Promise((success, fail) => {
|
|
|
|
wx.getLocation({
|
|
|
|
type: 'gcj02',
|
|
|
|
success: (res) => {
|
|
|
|
success(res)
|
|
|
|
},
|
|
|
|
fail: (res) => {
|
|
|
|
fail(res)
|
|
|
|
},
|
|
|
|
complete: (res) => {
|
|
|
|
console.log('wx.getLocation', res)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
showModal(e){
|
|
|
|
wx.openSetting()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
regionchange(e){
|
|
|
|
console.log('regionchange', e)
|
...
|
...
|
|