首页 > 代码库 > openlayers3 画扇形
openlayers3 画扇形
参考了http://www.cnblogs.com/lingxue3769/archive/2011/11/01/2231409.html同学的博客
和
百度知道https://zhidao.baidu.com/question/244106942859229564.html同学的回复
我这边修改了下根据点来画
/**
* 创建扇形
* @param [x,y] center 扇形中心点
* @param number randius 扇形半径 与中心点对应的坐标系单位
* @param number sAngle 扇形起始边与X轴正方向夹角°
* @param number angle 圆心角°(逆时针方向为正)
* @returns {ol.geom.Polygon}
* @constructor
*/
ol.geom.Sector = function (center, randius, sAngle, angle) {
sAngle = (360 - sAngle + 90) % 360;
var points = [];
points.push(center);
var ep = null;
for (var i = 0; i <= angle; ++i) {
var x = center[0] + randius * Math.cos(degreeToRadian(sAngle + i));
var y = center[1] + randius * Math.sin(degreeToRadian(sAngle + i));
points.push([x, y]);
}
points.push(center);
return new ol.geom.Polygon([points]);
};
var degreeToRadian = function (degree) {
return Math.PI * degree / 180;
};
openlayers3 画扇形