0

我实现了自定义地图和自定义引脚作为 docs.microsoft 的示例,但是当我点击一个引脚时,如果它不是最后一个创建的引脚,那么它找不到引脚:

错误

错误出现在 Android 渲染器中

var customPin = GetCustomPin(marker);
                if (customPin == null)
                {
                    throw new Exception("Custom pin not found");
                }

customPin 无法获取值

这就是我放置引脚的方式:

CustomPin pin = new CustomPin();
            pin.Type = PinType.Place;
            pin.Label = "Bus # 1";
            pin.Address = "394 Pacific Ave, San Francisco CA";
            pin.Name = "Xamarin";
            pin.Url = "url test";
            pin.Position = (new Position(9.934224393214128, -84.08272226354063));
            map.CustomPins = new List<CustomPin> { pin };
            map.Pins.Add(pin);
            map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(9.934224393214128, -84.08272226354063), Distance.FromMiles(1.0)));



            CustomPin pin2 = new CustomPin();
            pin2.Type = PinType.Place;
            pin2.Label = "Bus # 2";
            pin2.Address = "394 Pacific Ave, San Francisco CA";
            pin2.Name = "Xamarin";
            pin2.Url = "url test";
            pin2.Position = (new Position(9.932673627402988, -84.07538128629682));
            map.CustomPins = new List<CustomPin> { pin2 };
            map.Pins.Add(pin2);
            map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(9.932673627402988, -84.07538128629682), Distance.FromMiles(1.0)));

我相信问题就在这里

map.CustomPins = new List<CustomPin> { pin2 };

由于“新”,但我怎样才能使这个不同以添加尽可能多的引脚?

这是我尝试过的

List<CustomPin> CustomPinsList = new List<CustomPin>();
CustomPinsList.Add(pin2);
map.CustomPins.Add(CustomPinsList[1]);

和这个

map.CustomPins.Add(pin);
4

0 回答 0