function showMap(Lng, Lat) {
var map = new BMapGL.Map('container');
var point = new BMapGL.Point(Lng,Lat);
map.centerAndZoom(point, 15);
map.enableScrollWheelZoom(true);
// 添加标记点
let marker = new BMapGL.Marker(point);
map.addOverlay(marker);
//信息窗口配置
let opts = {
width: 250, // 宽度
height: 100, // 高度
title: '经纬度信息' //标题
}
let info = `当前位置经度为${Lng},纬度为${Lat}`
// 创建信息窗口对象
let infoWindow = new BMapGL.InfoWindow(info, opts);
// 打开信息窗口
map.openInfoWindow(infoWindow, point);
// 创建地理编码(地理解析器)实例
var myGeo = new BMapGL.Geocoder();
// 根据坐标得到地址描述 下面输入坐标。
myGeo.getLocation(new BMapGL.Point(Lng, Lat), function (result) {
VM.position.addr = result.address; //result.address 是当前的位置,个人根据情况赋值
})
}
百度地图开放平台——根据经纬度显示当前位置信息
最新推荐文章于 2024-04-23 15:56:26 发布