I implemented the custom map and custom pin as the example from docs.microsoft, but when I tap on a pin if its not the last one created pin then it cannot find the pin:
The error appears here in the Android Renderer
var customPin = GetCustomPin(marker);
if (customPin == null)
{
throw new Exception("Custom pin not found");
}
customPin can't get the values
This is how I place the pins:
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)));
I believe the issue is here
map.CustomPins = new List<CustomPin> { pin2 };
because of the "new" but how can I make this different to add as many pin as I want?
This is what I've tried
List<CustomPin> CustomPinsList = new List<CustomPin>();
CustomPinsList.Add(pin2);
map.CustomPins.Add(CustomPinsList[1]);
and this
map.CustomPins.Add(pin);