无法在openlayer中2分之间绘制弧度
我在画布上有2分。 假设点-A [x = 4.1549997,y = 4.005]和point-b [x = 2.77,y = 3.5749998]
现在,我想从 point-a&gt中绘制一个弧箭头;点b 和 point-b> Point-A 使用OpenLayers 3库。
到目前为止,我已经能够使用Linestring成功创建直箭。但是,我找不到OpenLayer给出的任何内置功能,可以在2分之间绘制弧线。
var me = this;
var line = new ol.geom.LineString(coordinate);
var fl = new ol.Feature({
name: "line",
geometry: line
});
fl.setProperties({
'coordinate': coordinate
});
fl.setStyle( function(feature, resolution) {
return me.getStyles(fl);
});
return fl;
getStyles: function (fObj) {
var geometry = fObj.getGeometry();
var styles = [new ol.style.Style({
stroke: new ol.style.Stroke({
width: 5,
color: 'rgb(21,150,18)',
lineDash: [.2,5]
})
})];
geometry.forEachSegment(function(start, end) {
var dx = end[0] - start[0];
var dy = end[1] - start[1];
var rotation = Math.atan2(dy, dx);
styles.push(new ol.style.Style({
geometry: new ol.geom.Point(end),
image: new ol.style.Icon({
src: '../images/arrow_test.png',
anchor: [0.75, 0.5],
rotateWithView: true,
rotation: -rotation
})
}));
})
return styles;
},
有人可以在这里帮助我吗?
注意 - 此外,我还担心还有一件事。当 apoint-a和point-b 之间绘制多个弧线时,它们不应彼此重叠。
I have 2 points on canvas.
Lets say point-A [x=4.1549997, y=4.005] and Point-B [x=2.77, y=3.5749998]
Now, I want to draw an arc arrow from Point-A > Point-B AND Point-B > Point-A using OpenLayers 3 Library.
So far, I have been able to successfully create Straight Arrows using LineString. But, I could not find any inbuilt functionality given by OpenLayer to draw ARC between 2 points.
var me = this;
var line = new ol.geom.LineString(coordinate);
var fl = new ol.Feature({
name: "line",
geometry: line
});
fl.setProperties({
'coordinate': coordinate
});
fl.setStyle( function(feature, resolution) {
return me.getStyles(fl);
});
return fl;
getStyles: function (fObj) {
var geometry = fObj.getGeometry();
var styles = [new ol.style.Style({
stroke: new ol.style.Stroke({
width: 5,
color: 'rgb(21,150,18)',
lineDash: [.2,5]
})
})];
geometry.forEachSegment(function(start, end) {
var dx = end[0] - start[0];
var dy = end[1] - start[1];
var rotation = Math.atan2(dy, dx);
styles.push(new ol.style.Style({
geometry: new ol.geom.Point(end),
image: new ol.style.Icon({
src: '../images/arrow_test.png',
anchor: [0.75, 0.5],
rotateWithView: true,
rotation: -rotation
})
}));
})
return styles;
},
Can anyone please help me here regarding this ?
Note - Also, there is one more thing which I am concerned also. When multiple ARCs are drawn between Point-A and Point-B, then they should not overlap on each other.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论