This commit is contained in:
liuye
2022-02-10 18:24:04 +08:00
parent d41c398857
commit ec439a6e9b

View File

@@ -6,7 +6,7 @@
<script>
import {mapState} from 'vuex'
import {mapActions, mapState} from 'vuex'
export default {
name: "AiTMap",
props: {
@@ -52,38 +52,38 @@ export default {
document.body.appendChild(script);
},
initTMap() {
var latLng = {}
if(this.config.lat) { //通用版
latLng = this.config
this.mapLib = TMap
this.tmap = new TMap.Map(this.$refs.tmap, {
zoom: 11,
center: new TMap.LatLng(latLng.lat, latLng.lng),
...this.ops
})
this.$emit('loaded')
this.$emit('update:lib', TMap)
this.$emit('update:map', this.tmap)
this.areaId && this.getMapArea()
}else { //上架版
// var latLng = {}
// if(this.config.lat) { //通用版
// latLng = this.config
// this.mapLib = TMap
// this.tmap = new TMap.Map(this.$refs.tmap, {
// zoom: 11,
// center: new TMap.LatLng(latLng.lat, latLng.lng),
// ...this.ops
// })
// this.$emit('loaded')
// this.$emit('update:lib', TMap)
// this.$emit('update:map', this.tmap)
// this.areaId && this.getMapArea()
// }else { //上架版
this.wxInvoke(['getLocation', {
}, (res) => {
latLng = {
lat: res.latitude,
lng: res.longitude
}
this.mapLib = TMap
this.tmap = new TMap.Map(this.$refs.tmap, {
zoom: 11,
center: new TMap.LatLng(latLng.lat, latLng.lng),
...this.ops
})
this.$emit('loaded')
this.$emit('update:lib', TMap)
this.$emit('update:map', this.tmap)
this.areaId && this.getMapArea()
}])
// this.wxInvoke(['getLocation', {
// }, (res) => {
// latLng = {
// lat: res.latitude,
// lng: res.longitude
// }
// this.mapLib = TMap
// this.tmap = new TMap.Map(this.$refs.tmap, {
// zoom: 11,
// center: new TMap.LatLng(latLng.lat, latLng.lng),
// ...this.ops
// })
// this.$emit('loaded')
// this.$emit('update:lib', TMap)
// this.$emit('update:map', this.tmap)
// this.areaId && this.getMapArea()
// }])
// wx.getLocation({
// type: 'gcj02', // 默认为wgs84的gps坐标如果要返回直接给openLocation用的火星坐标可传入'gcj02'
@@ -95,8 +95,14 @@ export default {
// }
// }
// });
}
this.tmap = new TMap.Map(this.$refs.tmap, {
zoom: 11,
...this.ops
})
this.$emit('loaded')
this.$emit('update:lib', TMap)
this.$emit('update:map', this.tmap)
this.areaId && this.getMapArea()
},
fitBounds(latLngList, count = 0) {