在Bing地图WPF上显示多个图钉



当前,当我加载程序时,Bing Maps只会将第一个图钉加载到地图上,例如,我有4个图钉,应该在加载应用程序时显示,我会添加哪些额外的代码来完成这四个图钉。

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

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

我必须给每个人一个单独的名字吗?(引脚)

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

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

 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))

如果你只想创建这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

相关内容

  • 没有找到相关文章

最新更新