uniapp 地图中心,经纬度转换为地址
```//获取当前地图中心的经纬度getCenterLanLat(){vart=this;this.mapContext=
// 获取当前地图中心的经纬度
getCenterLanLat() {
var t = this;
this.mapContext = uni.createMapContext('0', this);
console.log('获取中心点', this.mapContext);
this.mapContext.getCenterLocation({
type: 'gcj02',
geocode: true,
success: res => {
console.log(res.latitude,'~~~'+res.longitude);
t.$forceUpdate();
t.$emit('longLatDetail', address);
},
fail: err => {
console.log(t.latitude);
console.log('获取当前地图中心的经纬度2', err);
}
});
},
//传入经纬度,转换成地理位置
site: function() {
//longitude,latitude:经纬度
var point = new plus.maps.Point(longitude,latitude);
plus.maps.Map.reverseGeocode(
point,
{},
function(event) {
var add = event.address; // 转换后的地理位置
var point = event.coord; // 转换后的坐标信息
var coordType = event.coordType; // 转换后的坐标系类型
}
);
}
相关文章
发表评论
评论列表
- 这篇文章还没有收到评论,赶紧来抢沙发吧~