Bing 地图图钉错误

Bing Maps PushPin Error

你好,我正在尝试通过纬度和经度来确定我的图钉,但出于某种原因,我在纬度下得到一条错误行 图钉(纬度,经度) 我的地图很满意如果我只是将图钉更改为位置,则使用相同的代码居中,但我不明白为什么它不能与图钉一起使用?

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim latitude As Double = Double.Parse(TXTLAT.Text.Substring(0, TXTLAT.Text.IndexOf(","c)))
    Dim longitude As Double = Double.Parse(TXTLong.Text.Substring(TXTLong.Text.IndexOf(","c) + 1))


    UserControl11.BingMap.Center = New Microsoft.Maps.MapControl.WPF.Pushpin(latitude, longitude)
End Sub

要使地图居中,您需要传入 Location 对象,而不是图钉。图钉是显示在地图顶部的 UIElement,其中中心 属性 是地图的位置。如果您想将地图居中放置在某个位置并在那里显示图钉,请执行以下操作:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim latitude As Double = Double.Parse(TXTLAT.Text.Substring(0, TXTLAT.Text.IndexOf(","c)))
    Dim longitude As Double = Double.Parse(TXTLong.Text.Substring(TXTLong.Text.IndexOf(","c) + 1))

    Dim location = New Microsoft.Maps.MapControl.WPF.Location(latitude, longitude)

    Dim Pin = New Microsoft.Maps.MapControl.WPF.Pushpin()
    pin.Location = location

    UserControl11.BingMap.Center = location
End Sub

您可以在此处找到有关 Bing Maps WPF 控件的完整文档:https://msdn.microsoft.com/en-us/library/hh750210.aspx