在Bing Maps WPF

时间:2015-12-21 20:43:24

标签: wpf vb.net geocoding bing-maps pushpin

目前,当我加载我的程序时,Bing Maps只会将第一个图钉加载到地图上,对于我的示例,我有4个图钉应该在加载应用程序时显示,我将添加哪些附加代码以使其完整这四个。

另外,如果你不介意回答,我会有几个问题

我是否需要为每个位置使用循环?

我必须给每个人一个名字吗? (PIN)

我可以链接访问数据库而不是复制位置吗?

单击按钮时是否可以隐藏或移除图钉?

 Dim Pin = New Microsoft.Maps.MapControl.WPF.Pushpin()
    UserControl11.BingMap.Children.Add(Pin)

    Pin.Location = (New Location(55.852663, -2.3889276))
    Pin.Location = (New Location(55.956023, -3.1607265))
    Pin.Location = (New Location(54.840279, -3.2886766))
    Pin.Location = (New Location(52.819511, -1.8851815))

1 个答案:

答案 0 :(得分:1)

如果您只想创建这4个引脚,则可以使用以下代码:

Dim Pin = New Microsoft.Maps.MapControl.WPF.Pushpin()
Pin.Location = (New Location(55.852663, -2.3889276))
UserControl11.BingMap.Children.Add(Pin)

Dim Pin2 = New Microsoft.Maps.MapControl.WPF.Pushpin()
Pin2.Location = (New Location(55.956023, -3.1607265))
UserControl11.BingMap.Children.Add(Pin2)

Dim Pin3 = New Microsoft.Maps.MapControl.WPF.Pushpin()
Pin3.Location = (New Location(54.840279, -3.2886766))
UserControl11.BingMap.Children.Add(Pin3)

Dim Pin4 = New Microsoft.Maps.MapControl.WPF.Pushpin()
Pin4.Location = (New Location(52.819511, -1.8851815))
UserControl11.BingMap.Children.Add(Pin4)

或者,如果你的位置数据正在改变,或者你有一个阵列/位置信息列表,你可以循环,创建图钉并将它们添加到地图中,如下所示:

Dim myLocations(4) As Location
myLocations(0) = New Location(55.852663, -2.3889276)
myLocations(1) = New Location(55.956023, -3.1607265) 
myLocations(2) = New Location(54.840279, -3.2886766) 
myLocations(3) = New Location(52.819511, -1.8851815)

For index = 0 to myLocations.Length - 1
    Dim Pin = New Microsoft.Maps.MapControl.WPF.Pushpin()
    Pin.Location = myLocations(index)
    UserControl11.BingMap.Children.Add(Pin)
Next