如何动态创建一些我需要将它们添加到 bing Map 的图钉。说,我需要 10 个图钉。
下面是代码。
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