Код: Выделить всё
protected override void OnAppearing()
{
try
{
base.OnAppearing();
// Add the pin click events
foreach (var pin in _MapPlace.PinsToMap)
{
pin.MarkerClicked += async (s, args) =>
{
args.HideInfoWindow = true;
string pinName = ((Pin)s).Label;
await DisplayAlert("Pin Clicked", $"{pinName} was clicked.", "Ok");
};
}
BindingContext = _MapPlace;
_MapPlace.MoveMap();
MapPlaceList.PlaceList = _MapPlace.MasterPlaces;
}
catch (Exception ex)
{
App.ProcessException(ex);
}
_MasterPage.IsBusy = false;
}
Вот код, который заполняет список контактов в моей виртуальной машине.
Код: Выделить всё
private async Task UpdatePinList()
{
try
{
//Linq Query to get the places to map
var workPinList = (from p in MasterPlaces
where p.Selected == true
select new Pin()
{
Label = p.Title,
Address = p.Address,
Type = PinType.Place,
Location = new Location(p.Latitude, p.Longitude)
}).ToList();
//Add the current location to ensure the area is centered around it
if (IncludeCurrentLocation)
{
var currentLocation = await GeoLocationHelper.GetLocation();
workPinList.Add(new Pin() { Location = currentLocation });
}
//Build the mapspan.
DisplayArea = GetMapSpan(workPinList);
//Remove the pin as it will be shown natively via the map
if (IncludeCurrentLocation)
{
workPinList.RemoveAt(workPinList.Count - 1);
}
PinsToMap = new ObservableCollection
(workPinList);
if (PinsToMap.Count == 1)
{
SubTitle = PinsToMap[0].Label;
}
else
{
SubTitle= string.Concat(AppResources.NumberResultsCaption, " ", PinsToMap.Count.ToString());
}
if (WorkingMap != null)
{
//Now create and position the map
MoveMap();
}
}
catch (Exception ex)
{
App.ProcessException(ex);
}
}
Есть идеи относительно того, почему мне кажется, что код события MarkerClick не срабатывает?
Подробнее здесь: https://stackoverflow.com/questions/773 ... not-firing
Мобильная версия