直接上代码(描点部分)
this.tableData是获取到的锚点数据
position是每个锚点的坐标
marker.on('click', function (e) {})点击事件
let map = new AMap.Map("container", {
zoom: this.zoom,
pitch: 50,
viewMode: this.viewMode, // 开启3D视图,默认为关闭
});
// 构造点标记
map.clearMap();
this.markers = [];
this.tableData.forEach((element) => {
var marker = new AMap.Marker({
icon: "https://webapi.amap.com/theme/v1.3/markers/n/mark_b.png",
position: element.pos,//描点坐标
anchor: "bottom-center",//偏移位
});
map.add(marker);//添加
marker.setLabel({
direction: "top",
offset: new AMap.Pixel(0, -10), // 设置文本标注偏移量
content: element.name, // 设置文本标注内容
});
this.markers.push(marker);
//本来想着function写外面调用,但是描点坐标内容获取不到,有大神会留言
marker.on('click', function (e) {//点击事件
console.log(