Bug 30385 - Map Pin Clicked stops firing after pins changed
Summary: Map Pin Clicked stops firing after pins changed
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.4.4
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2015-05-23 18:03 UTC by WillG
Modified: 2016-04-08 19:53 UTC (History)
5 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description WillG 2015-05-23 18:03:31 UTC
This is NOT https://bugzilla.xamarin.com/show_bug.cgi?id=29017 - that is now working for me


Pins added to map - they display properly and I receive Clicked notifications from them.
As the map is scrolled I wanted to update the pins displayed to reflect the new view area.
Once I have replaced the pins, and reattached the Clicked handler, they now never trigger the Clicked event again.

I create a Xamarin.Forms.Maps map for iOS. (Maps

I add some pins

I add click handlers to the pins

These all work fine

The user now drags the map and fire my onDrag handler

I then want to refresh the pins to reflect the new view area This works too - except now the Clicked event on the pins is ignored. The info box is displayed, but the handler itself is never called when I click the info box. This works when first set but not after the pins are changed.

I have tried creating new pins on drag:

foreach (Place p in PlaceList){
  Pin newPin = new Pin();
  pin.Label = p.PlaceName;
  pin.Clicked += DoPinClick;
and then I tried reusing the existing pins on drag:

Pin pin;
for (int i = 0; i < PlaceList.Count; i++) {
  if (i > 9)
    // max of 10 pins
  Place p = PlaceList [i];
  if (i >= map.Pins.Count - 1) {
    // a new pin to be created and added to the map pins
    pin = new Pin();
    pin.Clicked += DoPinClick;
    pin.Label = p.PlaceName;
    map.Pins.Add (pin);
  } else {
    // there was already a pin in that slot, get it and reuse it
    pin = map.Pins [i];
    pin.Label = p.PlaceName;
  pin.Position = p.Position;
  // copy the pin into the slot it occupies already
  map.Pins [i] = pin;
But whichever approach I follow the event handler only works until I change the pins.
Comment 1 Chris King 2015-05-26 16:00:59 UTC
We'd be happy to help you resolve this issue. Please help us by attaching a reduced reproduction to the bug by starting with a clean Xamarin.Forms project and adding just the code necessary to demonstrate the issue. If you'd do this for us we would very much appreciate it. 

Warm regards,
Xamarin Forms Team
Comment 2 Jason Smith [MSFT] 2016-04-08 19:53:53 UTC
Thank you for your bug report. As we have not received the information requested, we cannot properly triage your bug and are marking it resolved.

Warm regards,
Xamarin Forms Team