vue3.0
1、找到文件public中的index.html 引入 <script src="https://webapi.amap.com/maps? v=1.4.10&key="你申请的key值"&plugin=AMap.MarkerClusterer,AMap.Geocode"></script>
2、找到vue.config.js加入 “下”并重启
configureWebpack: {
externals: {
AMap: "window.AMap"
}
}
3、在你页面中引入import AMap from "AMap";
4、开始创建地图
let self = this;
var lon = parseFloat(self.areaNameLonLat.lon)
var lat = parseFloat(self.areaNameLonLat.lat)
//绘制地图
self.LonLat = [lon,lat];
self.storeMap = new AMap.Map('container', {
resizeEnable:true,
viewMode:'2D',
showLabel:false,
labelzIndex:130,
pitch:40,
zoom:13,
layers:[
new AMap.TileLayer.RoadNet({
}),
new AMap.TileLayer.Satellite()
]
});
self.storeMap.setCenter(self.LonLat)
//渲染每个点的坐标点
self.pixelData.map(item =>
vue3.0 创建二维地图,在二维地图创建点并给每个点添加点击事件
最新推荐文章于 2024-08-09 17:29:51 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)