你好,我正试图通过纬度和经度来确定我的图钉,但由于某种原因,我在纬度下得到了一条错误线pushpin(纬度,经度)如果我只是将pushpin更改为Location,我的地图很乐意使用相同的代码居中,但我不明白为什么它不适用于pushpin?
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对象,而不是Pushpin。Pushpin是一个显示在地图顶部的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