百度地图绘制扇形
function Sector1(point2, radius, sDegree, eDegree, pointCount) { let points = []; //创建构成多边形的点数组 let step = ((eDegree - sDegree) / pointCount) || pointCount; //根据扇形的总夹角确定每步夹角度数 points.push(point2); for (let i = sDegree; i < eDegree + 0.001; i += step) { //循环获取每步的圆弧上点的坐标,存入点数组 points.push(EOffsetBearing(point2, radius * 1000, i)); } points.push(point2); //根据构成的点数组以及其他参数画多边形 let polygon = new BMapGL.Polygon( points, { strokeColor: "blue", strokeWeight: 3, strokeOpacity: 0.7, fillColor: 'rgb(40,75,151)' }); map.addOverlay(polygon) console.log(points) return polygon; } //使用数学的方法计算需要画扇形的圆弧上的点坐标 function EOffsetBearing(point3, dist, bearing) { let lngConv = map.getDistance(point3, new BMapGL.Point(point3.lng + 0.1, point3.lat)) * 10; //计算1经度与原点的距离 let latConv = map.getDistance(point3, new BMapGL.Point(point3.lng, point3.lat + 0.1)) * 10; //计算1纬度与原点的距离 let lat = dist * Math.cos(bearing * Math.PI / 180) / latConv; //正弦计算待获取的点的纬度与原点纬度差 let lng = dist * Math.sin(bearing * Math.PI / 180) / lngConv; //余弦计算待获取的点的经度与原点经度差 return new BMapGL.Point(point3.lng + lng, point3.lat + lat); } Sector1(new BMapGL.Point(119.20920035759737, 38.6103169759151), 50, 58, 176, 50)
本文来自博客园,作者:ALin_Da,转载请注明原文链接:https://www.cnblogs.com/alinda/p/15767706.html
。 一个programmer小菜鸟的成长记