2013-05-28 112 views
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 

回答

1

如果你在的Windows Phone 7.1使用BingMaps,你可以做这样的:

for (int i = 0; i <= 10; i++) 
    { 
     Pushpin pp = new Pushpin(); 
     pp.Location = new GeoCoordinate(latitude, longitude); 
     pp.Content = //Content for the Pushpin; 
     myMap.Children.Add(pp); //myMap is your map control 
    } 
+0

我做了与你相似的方法什么的。但Bing Map只在显示12时显示一个PushPin。 – MilkBottle

+0

在您的代码中,我看不到您在哪里设置图钉的位置。 – anderZubi

+0

谢谢。它似乎工作。但是,让我稍后检查并报告。 – MilkBottle

相关问题