我们是后端返回的具体的位置信息,然后在百度地图上读取的时候不能把具体的坐标读取完全(返回130.2555555555)地图控件读取的时候是(120.2555),解决办法就是直接给marker点新增一个对象
// 向marker中存储数据
this.editMk.item = e
// marker标记点坐标
this.poleList.forEach(e => {
this.editPoint = new BMap.Point(e.lng, e.lat)
// 添加marker图片 设置大小 标记点不能拖动 没有定义缩放地图时改变图片大小
this.editMk = new BMap.Marker(this.editPoint, { icon: new BMap.Icon(require('@/assets/bigScreen/dian.png'), new BMap.Size(18, 18), { imageSize: new BMap.Size(18, 18) }), enableMassClear: false, enableDragging: false })
// 向marker中存储数据
this.editMk.item = e
this.map.addOverlay(this.editMk)
this.editMk.addEventListener('click', (e) => {
// that.showHidePole = true
console.log(e, 'woshi eeee')
this.$refs.poles.style.display = 'block'
const lng = e.target.item.lng
const lat = e.target.item.lat
const projectId = window.localStorage.getItem('equipmentProject')
const params = {
lng: lng,
lat: lat,
projectId: projectId
}
queryPoleAndAttributeDeviceByLatAndLng(params).then(res => {
console.log(res.data, '新增灯杆信息')
this.deviceName = res.data[0].pole.deviceName// 灯杆名称
this.deviceCode = res.data[0].pole.deviceCode// 灯杆编号
})
})
})