地图中心定位

This commit is contained in:
liuye
2022-02-10 17:34:17 +08:00
parent cfc5b5afcd
commit 37f4c3d8d4
2 changed files with 17 additions and 2 deletions

View File

@@ -51,10 +51,26 @@ export default {
document.body.appendChild(script);
},
initTMap() {
var latLng = {}
if(this.config.lat) { //通用版
latLng = this.config
}else { //上架版
wx.getLocation({
type: 'gcj02', // 默认为wgs84的gps坐标如果要返回直接给openLocation用的火星坐标可传入'gcj02'
success: (res) => {
console.log(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(this.config.lat, this.config.lng),
center: new TMap.LatLng(latLng.lat, latLng.lng),
...this.ops
})
this.$emit('loaded')