如何在OpenLayers中绘制多线?

发布于 2025-02-11 13:51:28 字数 361 浏览 2 评论 0原文

我已经在露天层中学到了一个绘图对象。

当用户移动鼠标时,我尝试绘制虚线。当用户单击最后一个和前一个线路时,应在直线上更​​换上一个线条。

它如何工作,我应该使用两个不同的绘图艾尔人并在它们之间切换?

还是我可以从绘制对象中检索最后一行并在直线上重新绘制它?

我尝试从官方文档中使用此示例:

https://openlayers.orgg/ en/最新/示例/量表式。html

I have learned a Draw object in Openlayers.

I try to draw the dotted line when user moves the mouse. When user clicks the last and prev lines should be replaced on straight line.

How does it work, should I use two different drawing ayers and switch between them?

Or I can retrieve a last line from draw object and redraw it on straight line?

I try to use this sample from official document:

https://openlayers.org/en/latest/examples/measure-style.html

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

睫毛上残留的泪 2025-02-18 13:51:28

有一个解决方案: Measure-style> style

  1. 重新写入时设置标签
draw.on('drawend', function (e) {
    e.feature.set('finished',true)
    ...
});
  1. 在功能绘制draw end end Rewrite 样式功能以不同的方式对待这两种情况
function styleFunction(feature, segments, drawType, tip) {
  const stroke = style.getStroke()
  if (feature.get('finished'))
    stroke.setLineDash(null)
  else 
    stroke.setLineDash([10,10])
...
}

There is a solution: measure-style

  1. Set a tag when feature draw end
draw.on('drawend', function (e) {
    e.feature.set('finished',true)
    ...
});
  1. Rewrite style function to treat the two situations differently
function styleFunction(feature, segments, drawType, tip) {
  const stroke = style.getStroke()
  if (feature.get('finished'))
    stroke.setLineDash(null)
  else 
    stroke.setLineDash([10,10])
...
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文