如何为bing map动态创建一些图钉

时间:2013-05-28 07:52:45

标签: windows-phone-7

如何动态创建一些图钉,我需要将它们添加到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 

1 个答案:

答案 0 :(得分: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
    }
相关问题