C# 是否有办法使用bing地图在windows phone 8上手动移动和调整图钉位置?

C# 是否有办法使用bing地图在windows phone 8上手动移动和调整图钉位置?,c#,mobile,windows-phone-8,bing-maps,C#,Mobile,Windows Phone 8,Bing Maps,我正在开发一个使用bing地图的windows phone 8.0应用程序。我想用我的当前位置添加一个图钉。到目前为止还不错。我没能做的就是移动那个别针。更准确地说,我想点击那个别针,然后把它移动到地图上的其他地方 我尝试了操纵开始、操纵增量、操纵完成等事件以及web上的其他资源,但还没有结果 我的C#代码: 有没有办法让针变得容易拔?如果我设置pin.AllowDrop=true,它将抛出NotImplementedException 提前谢谢你 您必须在地图上的鼠标事件上设置移动事件。这将使

我正在开发一个使用bing地图的windows phone 8.0应用程序。我想用我的当前位置添加一个图钉。到目前为止还不错。我没能做的就是移动那个别针。更准确地说,我想点击那个别针,然后把它移动到地图上的其他地方

我尝试了操纵开始、操纵增量、操纵完成等事件以及web上的其他资源,但还没有结果

我的C#代码:

有没有办法让针变得容易拔?如果我设置pin.AllowDrop=true,它将抛出NotImplementedException


提前谢谢你

您必须在地图上的鼠标事件上设置移动事件。这将使您能够跟踪用户移动到的位置。基本上,您将向图钉添加一个鼠标按下事件,该事件将设置一个标记来捕获以允许拖动图钉。然后使用地图上的鼠标移动事件重新定位图钉,并使用地图上的鼠标向上事件关闭拖动标志。您可能还希望显示地图的平移。当鼠标按下事件触发时,尝试捕获中心值,然后在鼠标移动事件上,当拖动标志打开时,将地图中心不断设置为该值。

只是想得有点不同

我使用的解决方案是在地图上覆盖十字线,这样用户可以通过拖动地图而不是拖动图钉来精确定位图钉。然后我会使用一个带有勾号和叉号的应用程序条来表示“创建pin”和“取消”


这只是一个供您考虑的替代UI想法,它可能更易于实现,也可能更易于用户使用。

这不是针对手机,而是针对Win8,但本教程可能会有所帮助?
public partial class MainPage : PhoneApplicationPage
    {
        Pushpin pin = new Pushpin();
        // Constructor
        public MainPage()
        {
            InitializeComponent();

            GetCurrentPosition();
        }

        async void GetCurrentPosition()
        {
        Geolocator geolocator = new Geolocator();
        geolocator.DesiredAccuracyInMeters = 50; 
        Geoposition geoposition = await geolocator.GetGeopositionAsync();
        Grid MyGrid = new Grid();
        MyGrid.RowDefinitions.Add(new RowDefinition());
        MyGrid.RowDefinitions.Add(new RowDefinition());
        MyGrid.Background = new SolidColorBrush(Colors.Transparent);            

        pin.Content = "I'm a pin";
        pin.Foreground = new SolidColorBrush(Colors.Purple);
        pin.ManipulationDelta += pin_ManipulationDelta;
        pin.ManipulationStarted += pin_ManipulationStarted;
        pin.ManipulationCompleted += pin_ManipulationCompleted;

        MyGrid.Children.Add(pin);

        //Creating a MapOverlay and adding the Grid to it.
        MapOverlay MyOverlay = new MapOverlay();
        MyOverlay.Content = MyGrid;

        MyOverlay.GeoCoordinate = new GeoCoordinate(geoposition.Coordinate.Latitude, geoposition.Coordinate.Longitude);
        MyOverlay.PositionOrigin = new Point(0, 0.5);

        MyMap.Center = new System.Device.Location.GeoCoordinate(geoposition.Coordinate.Latitude, geoposition.Coordinate.Longitude);
        MyMap.ZoomLevel = 16;
        MyMap.CartographicMode = Microsoft.Phone.Maps.Controls.MapCartographicMode.Road;

        MapLayer MyLayer = new MapLayer();
        MyLayer.Add(MyOverlay);
        MyMap.Layers.Add(MyLayer);

        translateTransform = new TranslateTransform();
    }

    void pin_ManipulationStarted(object sender, System.Windows.Input.ManipulationStartedEventArgs e)
    {
        //MessageBox.Show("started");
    }

    void pin_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e)
    {
        MessageBox.Show("moving");
         //how do a get the coordonites while I'm moving the pin?
    }

    void pin_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
    {
        MessageBox.Show("completed");
    }
}