openlayer new Style 如何画出一下两种效果?-灵析社区

瞳孔放大黑洞

![image.png](https://wmprod.oss-cn-shanghai.aliyuncs.com/images/20250103/a17195f9f157c235242e1e64113d9264.png) 请问一下 openlayer 咋样实现一下两种效果。 1、圆点 + 指针 + 扇形范围。 补充,扇形和 指针的指向 和角度 是通过 方位角 指定的 "{\"方位角\":\" 东南114°\",\"水平角\":\" 28°\",\"俯仰角\":\" 62°\",\"横滚角\":\" 7°\"}" 2、圆点 + 指针。 /** 照片 标记 点 高亮 */ const pointStyle = new Style({ image: new Circle({ radius: 6, fill: new Fill({ color: 'red', }), stroke: new Stroke({ color: '#fff', width: 2 }), }), });

阅读量:21

点赞量:0

问AI
const angle = parseFloat("东南114°".match(/(\d+)/)[1]); // 提取数字部分 const rotation = (angle - 90) * (Math.PI / 180); // 转换为弧度并进行调整 const fanShapeStyle = new Style({ image: new RegularShape({ fill: new Fill({ color: 'rgba(255,165,0,0.5)' }), // 半透明的橙色 points: 3, radius1: 50, radius2: 0, angle: rotation }), stroke: new Stroke({ color: 'red', width: 2 }) }); const pointerStyle = new Style({ geometry: function(feature) { const coordinates = feature.getGeometry().getCoordinates(); return new LineString([coordinates, [ coordinates[0] + 50 * Math.cos(rotation), coordinates[1] + 50 * Math.sin(rotation) ]]); }, stroke: new Stroke({ color: 'red', width: 2 }) });