将锚线添加到 Bing 地图自定义图钉并允许用户拖动
我目前正在使用 Bing Map 控件开发 Silverlight 应用程序,我正在使用由网格元素内的图像和文本块组成的自定义图钉,效果很好,这也允许我拥有悬停和右键单击事件到目前为止,每个图钉都很好,但是我需要使用户能够向任何方向拖动图钉,并有一条线将其连接到其实际位置,有点像锚点。
我正在努力了解如何做到这一点,我已经看到了很多有关使图钉能够通过鼠标移动的信息,但线条和锚点部分给我带来了一些问题。目前,我将图钉保存在各种可观察集合中,以便当它们更新时 UI 也会更新。如果有人对添加此功能的干净方式有任何想法,请告诉我,我将不胜感激。
非常感谢
I am currently working on a Silverlight application using the Bing Map control, i am using a custom pushpin made up of an Image and a text block within a grid element, which works fine, this also allows me to have hover and right click events for each pushpin so all good so far, however there is a need for me to enable the user to drag the pushpin in any direction and have an a line connecting it to its actual position, sort of like an anchoring point.
I am struggling to see how to do this, I have seen lots of information on making the pushpins have the capability to be moved by the mouse but the line and anchor part is causing me a bit of a problem. Currently i keep my pushpins in various Observable Collections so that when they are updated the UI updates. If anyone has an Idea on a clean way of adding this functionality please let me know it will be much appreciated.
Many Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我没有时间敲出一个完整的例子。不过,我将放弃解决方案的基础。将模板替换为基于
Canvas
的模板。例如,您可以将一个椭圆作为地图上的实际点,一个具有 ContentPresenter 的可拖动边框和一条充当系绳的线。所需的代码是 a) 允许拖动边框,b) 移动线的一端,使其位于边框下方。
I haven't got time to knock up a complete example. However I'll give away the basis of the solution. Replace the template with one based on a
Canvas
. For example you could have an ellipse to be the actual point on the map, a draggable border that has the ContentPresenter and a line to act as a tether.The code needed is a) allow the Border to be dragged about and b) to move one end of the line about so that it lies under the Border.
我仍然对其他方法感兴趣,但我提出了一种将图钉元素与 MapPolyline 配对的解决方案,这与鼠标处理相结合,允许用户拖动图钉更新两者,它非常有效,并且可以用于现在。不过,我仍然希望听到其他人提出更好的建议。
I am still interested in other approaches but I have come up with a solution of paring my pushpin element with a MapPolyline, this in conjunction with the mouse handling to allow the user to drag the pushpin updates both, it is pretty effective and will do for now. I would still like to hear from anyone else with better suggestions though.