//初始化地图 initMap() { let _this = this var map = new AMap.Map("mapContainer", { resizeEnable: true }); map.on('click', function (e) { let centerpoint = e.lnglat let radius = 5000; const r = 6371000; //地球的平均半径 const numpoints = 360; const phase = 2 * Math.PI / numpoints; let pointArr = [] //画点 for (let i = 0; i < numpoints; i += 90) { // 计算坐标点 let dx = (radius * Math.cos(i * phase)); let dy = (radius * Math.sin(i * phase)); // 转换成经纬度 let dlng = dx / (r * Math.cos(centerpoint.lat * Math.PI / 180) * Math.PI / 180); let dlat = dy / (r * Math.PI / 180); let newlng = centerpoint.lng + dlng; let newlag = centerpoint.lat + dlat; pointArr.push([newlng, newlag]) } var polygon = new AMap.Polygon ({ path: pointArr, borderWeight: 2, // 线条宽度,默认为 1 strokeColor: 'red', // 线条颜色 lineJoin: 'round' // 折线拐点连接处样式 }); map.add(polygon); map.setFitView() let polyEditor = new AMap.PolyEditor(map, polygon); polyEditor.open(); polyEditor.on('adjust', function(event) { _this.ruleForm.position=JSON.stringify(event.target.getPath()) }) }); },
高德地图创建电子围栏,鼠标单机选择电子围栏中心点
最新推荐文章于 2024-03-21 15:28:53 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)