在 MOUSE_MOVE 事件后测量地图上的线的长度
用户可以使用ESRI Flex Viewer 应用程序执行的操作之一是在地图上绘制形状(例如线条)。一旦用户完成绘制线条,他们将双击鼠标,从而触发 DrawEvent.DRAW_END 事件。触发此函数后,将通过调用 API 函数geometryService.project([geometryObject], SpatialReference);
来测量直线。
我希望能够在 MouseEvent.MOUSE_MOVE 事件之后调用此函数,以便动态测量线,而不是仅在 DRAW_END 事件之后调用。不幸的是,只有两个被调度的 DrawEvent 是 DrawEvent.DRAW_START 和 DrawEvent.DRAW_END。这些 ESRI 类是编译类,因此我无法对它们进行任何更改。
有没有办法将事件监听器添加到 MOUSE_MOVE 事件中,以获取正在绘制的线的当前几何形状并调用我的 API 函数来进行动态测量?
提前致谢。
One of the actions a user can perform using the ESRI Flex Viewer application is to draw a shape on a map (e.g. a line). Once the user is finished drawing the line, they will double-click the mouse which fires a DrawEvent.DRAW_END event. When this is fired, the line is measured using a call to an API function geometryService.project([geometryObject], spatialReference);
.
I want to be able to call this function after a MouseEvent.MOUSE_MOVE event in order to measure the line on the fly, instead of only after the DRAW_END event. Unfortunately, the only two DrawEvents that get dispatched are the DrawEvent.DRAW_START and DrawEvent.DRAW_END. These ESRI classes are compiled classes, so I cannot make any changes to them.
Is there a way to add an eventListener to a MOUSE_MOVE event that can grab the current geometry of the line that is being drawn and call my API function to measure on the fly?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过完全绕过几何服务并构建自己的解决方案找到了这个问题的解决方案。有一个 很棒的站点,它实现了 Vincenty 算法来测量两个坐标之间的距离。这是一种非常精确的近似算法(在 Vincenty 地球椭球上的 0.5 毫米以内),并且非常高效,因此可以经常使用(例如,在鼠标移动后)。
以下是实现此目的的基本步骤:
I found a solution to this problem by circumventing the geometry service altogether and building a solution of my own. There is a great site that implements the Vincenty algorithm for measuring the distance between two coordinates. This is a very accurate approximation algorithm (within .5mm on Vincenty's earth ellipsoid), and is meant to be very efficient so that it can be used frequently (e.g. after a mouse moves).
Here's the basic steps to implement this: