在WINRT中将多个PushPin添加到Bing Map控件(XAML& C#)

时间:2012-09-17 12:00:48

标签: windows-runtime bing-maps winrt-xaml

如何将多个推针添加到bing map控件。在我的应用程序中,我尝试添加一些用户控件(推针)作为该地图控件的子项。但问题在于,当我执行缩放-in和缩小操作时,推针在地图周围移动并错过放置位置。 这是我用于向地图添加多个图钉的代码:

            foreach (var item in PushPinCollection)
            {
                    var pin = new CustomMapPin(Convert.ToInt32(item.BackgroundColorID)) { Name = item.ID.ToString() };
                    pin.DoubleTapped += PushpinTapped1;
                     pin.Tapped += PinTapped;
                     var loc = new Location(Convert.ToDouble(item.Latitude, System.Globalization.CultureInfo.InvariantCulture), Convert.ToDouble(item.Longitude, System.Globalization.CultureInfo.InvariantCulture));
                     pin.SetValue(MapLayer.PositionProperty, loc);
                     NoteMap.Children.Add(pin);
                }

1 个答案:

答案 0 :(得分:3)

试试这个:

            Bing.Maps.Location loc = new Bing.Maps.Location
            {
                Latitude = latitude,
                Longitude = longitude
            };

            myMap.SetView(loc, 13);

            Pushpin pushpin = new Pushpin();
            pushpin.Tapped +=pushpin_Tapped;

            pushpin.Text = address;
            MapLayer.SetPosition(pushpin, loc);
            myMap.Children.Add(pushpin);