Right now, my code looks like this:
private void AddIvy()
{
Pin one = new Pin()
{
Label = "Ivy",
Position = new Position(38.021436330, -78.653405170),
Icon = BitmapDescriptorFactory.FromBundle("Recycle")
};
MyMap.Pins.Add(one);
one.Clicked += onIvyClicked;
MyMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(38.021436330, -78.653405170), Distance.FromKilometers(10)));
}
async private void onIvyClicked(object sender, EventArgs e)
{
await PopupNavigation.Instance.PushAsync(new Ivy());
}
When the pin one
is clicked, the pop up page Ivy
should appear. It says that one.Clicked
is obsolete and to change it to MyMap.PinClicked
. However, changing the code to MyMap.PinClicked
makes Ivy
pop up for every pin on my map. How can I change the code so that Ivy
only pops up when one
is clicked?
The Pin class defines a MarkerClicked
event, which is fired when a Pin is tapped.
you could try to use like:
Pin one = new Pin()
{
Label = "Ivy",
Position = new Position(38.021436330, -78.653405170),
Icon = BitmapDescriptorFactory.FromBundle("Recycle")
};
one.MarkerClicked += async (s, args) =>
{
await PopupNavigation.Instance.PushAsync(new Ivy());
};
the more you could refer to Interact with a pin .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.