问题描述
是否有人对如何在运行Mango的WP7客户端上的地图上实现可拖动图钉有任何见解?我有一个图钉绑定到地图上的地理位置,我希望用户能够在地图上拖动它并记录其新位置.我已经看到了一些资源,但是它们是用于非WP7 Bing Maps控件的.任何帮助将不胜感激.
Does anyone have any insight into how to implement a draggable pushpin on a map on a WP7 client running Mango? I have a pushpin bound to a geo-location on a map and I want the user to be able to drag it on a map and record its new location. I've seen some resources, but they're for non-WP7 Bing Maps control. Any help would be appreciated.
谢谢!
推荐答案
e.GetPosition(element)给出相对于参数传递的元素的位置.同样,使用ViewportPointToLocation进行转换的点必须相对于地图的位置.因此,您必须执行以下操作:
e.GetPosition(element) gives the position relative to the element passed on the parameter. Also, the point to convert using ViewportPointToLocation has to be relative to the position of the map. So, you have to do the following:
Pushpin myPin = sender as Pushpin;
Point p = e.GetPosition(**Map**);
g = Map.ViewportPointToLocation(p);
这篇关于WP7在地图上拖动图钉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!