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