Problems removing individual Pins in Xamarin.Forms.Maps

Hello all,

I'm learning/working on a project that uses Forms Maps. Nothing too spicy, just basic pin manipulation. I'm having problems removing individual pin instances using mapInstance.Pins.Remove(somePin). I make this call when the maps PropertyChanged event triggers. The data for the pin is removed but the image remains drawn on the map. Is there some kind of update call that I'm missing where the map redraws itself? My search attempts for similar issues have been fairly fruitless and frustration continues to mount. Making a call to mapInstance.Pins.Clear() works but I do not want to re-populate the entire list every time there is a change (this also causes flickering). This is all being debugged on an Android (Gmaps) device.


  • MakaniMakani USMember

    I'm having issues too. I get this: UIKit Consistency error: you are calling a UIKit method that can only be invoked from the UI thread.

  • Thibault_VellicusThibault_Vellicus CHUniversity ✭✭

    Same problem here but only with Android.
    Pins.Remove is working as espected with iOS...

    @Makani: try Device.BeginInvokeOnMainThread(() => Pins.Remove(pinToRemove));

  • DominicBeauprDominicBeaupr CAMember ✭✭

    I have the same issue, could not remove an individual pin. Nothing happens when calling pins.Remove(pinToRemove). Did you find any solution ? I already wrap the remove code in Device.BeginInvokeOnMainThread.


  • HebaAhmedHebaAhmed USMember ✭✭

    i use this
    Device.BeginInvokeOnMainThread(() =>

                    for (int x = 0; x < customMap.Pins.Count; x++)
                    { customMap.Pins.RemoveAt(x); }//.Remove(customMap.Pins[x]); }
                    for (int x = 0; x < customMap.CustomPins.Count; x++)
                    { customMap.CustomPins.RemoveAt(x); }//.Remove(customMap.CustomPins[x]); }

    and this
    Device.BeginInvokeOnMainThread(() =>


    and no one work
    what should i do??

  • RyanSmith.9175RyanSmith.9175 USMember ✭✭

    Has anyone figured this out?

  • SunnyKhan.3452SunnyKhan.3452 USMember ✭✭

    Did anyone find solution for this? If yes, please share or any suggestion is good. I need an urgent fix.

  • ThorvaldBoeThorvaldBoe NOMember ✭✭

    I'm facing the same issue. Anyone found a solution for this?

  • ThorvaldBoeThorvaldBoe NOMember ✭✭

    Ok, so I'm in a hurry, and needed to find a fix asap. I ended up calling Pins.Clear() before adding all my pins from scratch every time they changed. Somehow Clear() works, while Remove() doesn't. My map doesn't have a lot of pins, so it works fine. But if you had a lot of pins, or the pin locations changed frequently, it would certainly be nice to be able to remove a single pin.

    It seems to me that the data structure is updated (i.e the pin is actually removed from the list) when using Remove(), but the map doesn't update itself afterwards. That might also explain why simply changing the position of an existing pin (which was my first attempt to solve this) didn't work either.

    As a newcomer to the Xamarin world, I must say I am really impressed with the overall architecture, the intentions for the platform and how easy it is to build apps that work on all mobile platforms. BUT, once I go slightly beneath the surface, issues like these tend to appear. It steals a lot of time, and makes the product appear unfinished, in my opinion. I really hope MS will help drive the Xamarin product to a more mature state, and have components where the basic feature works, and hell, maybe even a XAML viewer that works too... :)

Sign In or Register to comment.