地图中心定位
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user