BUG 27449
This commit is contained in:
@@ -8,8 +8,7 @@
|
||||
当前<br>位置
|
||||
</div> -->
|
||||
<div class="map-content">
|
||||
<AiTMap v-if="user.areaId" :areaId="user.areaId" :map.sync="map" :lib.sync="lib" :ops="ops"
|
||||
:libraries="['service', 'tools']"/>
|
||||
<AiTMap :map.sync="map" :lib.sync="lib" :ops="ops" :libraries="['service', 'tools']"/>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<div class="btn" @click="confirm">确认定位</div>
|
||||
@@ -63,10 +62,9 @@ export default {
|
||||
markerLayer: '',
|
||||
isFlag: false,
|
||||
latLng: {lat: '', lng: ''},
|
||||
retryTimes: 0
|
||||
}
|
||||
},
|
||||
computed: {...mapState(['user',])},
|
||||
computed: {...mapState(['user'])},
|
||||
mounted() {
|
||||
this.initMap()
|
||||
},
|
||||
@@ -74,36 +72,33 @@ export default {
|
||||
document.title = "楼栋定位"
|
||||
},
|
||||
methods: {
|
||||
initMap() { //初始化地图
|
||||
initMap(retryTimes = 0) { //初始化地图
|
||||
this.$nextTick(() => {
|
||||
let {map, retryTimes} = this
|
||||
let {map} = this
|
||||
if (map) {
|
||||
map.setZoom(15)
|
||||
map.on("click", (evt) => {
|
||||
this.handleMapClick(evt)
|
||||
});
|
||||
} else {
|
||||
if (retryTimes < 5)
|
||||
if (retryTimes < 10)
|
||||
setTimeout(() => {
|
||||
this.retryTimes++
|
||||
this.initMap()
|
||||
}, 1000)
|
||||
this.initMap(++retryTimes)
|
||||
}, 500)
|
||||
else console.error("地图渲染失败")
|
||||
}
|
||||
})
|
||||
},
|
||||
getLocale() {
|
||||
|
||||
wx.getLocation({
|
||||
type: 'gcj02',
|
||||
success: res => {
|
||||
console.log(res)
|
||||
let {latitude: lat, longitude: lng} = res
|
||||
this.handleMapClick({latlng: {lat, lng}})
|
||||
}
|
||||
})
|
||||
},
|
||||
handleMapClick(evt) {
|
||||
console.log(evt.latLng)
|
||||
let {lib: TMap, map} = this
|
||||
if (this.markerLayer) {
|
||||
this.markerLayer.setMap(null);
|
||||
|
||||
Reference in New Issue
Block a user