0
如何動態創建幾個圖釘,我需要將它們添加到bing地圖中。說,我需要10個圖釘。如何動態地爲bing地圖創建幾個圖釘
以下是代碼。
for(int i =0 ; i <=10 ; i++)
{
Pushpin pp = new Pushpin();
}
---更新:
Pushpin[] pp = new Pushpin[intcount];
int PinNbr = 1;
//---- get the items out one by one:
foreach (var c in Cat)
{
if (c.GpsLat != null && c.GpsLon != null)
{
//--default fixed location : Lat/Lon
double KM = CalculateDistance("1.xxxxx", "103.xxxxxx", c.GpsLat, c.GpsLon);
if ((KM < 2.0)))
{
//--- show the pushpin
pp[PinNbr] = new Pushpin();
pp[PinNbr].Content = c.BizId.ToString() + "," + c.BizName;
pp[PinNbr].Width = 180;
pp[PinNbr].Height = 120;
//-------- All use the same eventHandler
pp[PinNbr].MouseLeftButtonUp += new MouseButtonEventHandler(Pushpin_MouseLeftButtonUp);
map1.Children.Add(pp[PinNbr]);
PinNbr++;
}
}
//-- using Lat/lon
map1.Center = new GeoCoordinate(1.2xxxx, 103.3xxx);
map1.ZoomLevel = 13;
}
//-------- All use the same eventHandler
我做了與你相似的方法什麼的。但Bing Map只在顯示12時顯示一個PushPin。 – MilkBottle
在您的代碼中,我看不到您在哪裏設置圖釘的位置。 – anderZubi
謝謝。它似乎工作。但是,讓我稍後檢查並報告。 – MilkBottle