问题描述
我以 docs.microsoft 中的示例实现了自定义地图和自定义图钉,但是当我点击某个图钉时,如果它不是最后一个创建的图钉,则它找不到该图钉:
错误出现在 Android Renderer 中
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);
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)