themronion / Maui.GoogleMaps

Map library for MAUI using Google maps API
https://www.nuget.org/packages/Onion.Maui.GoogleMaps/
MIT License
76 stars 33 forks source link

Unable to add pins in iOS #17

Closed edgiardina closed 11 months ago

edgiardina commented 11 months ago

VERSIONS

IDE

PLATFORMS

ACTUAL BEHAVIOR

We are seeing this error trying to add pins to iOS (missing ctx)

   at ObjCRuntime.NativeObjectExtensions.GetNonNullHandle(INativeObject self, String argumentName)
   at CoreAnimation.CALayer.RenderInContext(CGContext ctx)
   at Maui.GoogleMaps.Utils.ConvertViewToImage(UIView view)
   at Maui.GoogleMaps.Logics.iOS.PinLogic.<>c__DisplayClass31_0.<OnUpdateIconView>b__0()
   at Foundation.NSObject.InvokeOnMainThread(Action action)
   at Maui.GoogleMaps.Logics.iOS.PinLogic.OnUpdateIconView(Pin outerItem, Marker nativeItem)
   at Maui.GoogleMaps.Logics.iOS.PinLogic.CreateNativeItem(Pin outerItem)
   at Maui.GoogleMaps.Logics.DefaultLogic`3[[Maui.GoogleMaps.Pin, Maui.GoogleMaps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Google.Maps.Marker, Google.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Google.Maps.MapView, Google.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].AddItems(IList newItems)
   at Maui.GoogleMaps.Logics.BaseLogic`1[[Google.Maps.MapView, Google.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs notifyCollectionChangedEventArgs)
   at System.Collections.ObjectModel.ObservableCollection`1[[Maui.GoogleMaps.Pin, Maui.GoogleMaps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   at System.Collections.ObjectModel.ObservableCollection`1[[Maui.GoogleMaps.Pin, Maui.GoogleMaps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].OnCollectionChanged(NotifyCollectionChangedAction action, Object item, Int32 index)
   at System.Collections.ObjectModel.ObservableCollection`1[[Maui.GoogleMaps.Pin, Maui.GoogleMaps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].InsertItem(Int32 index, Pin item)
   at System.Collections.ObjectModel.Collection`1[[Maui.GoogleMaps.Pin, Maui.GoogleMaps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].Add(Pin item)
   at [***OBSCURED FOR SECURITY***].Views.GoogleMapView.RefreshPins() in [***OBSCURED FOR SECURITY***]\GoogleMapView.cs:line 369

At line 369 we are simply trying to add a pin to the map like so:

               Pins.Add(new Pin()
                {
                    Anchor = new Point(pinData.AnchorX, pinData.AnchorY),
                    BindingContext = pinData.ViewModel,
                    Icon = descriptor,
                    Label = pinData.ViewModel?.MapDisplayName,
                    Position = new Position(pinData.Latitude, pinData.Longitude)
                });

ACTUAL SCREENSHOTS/STACKTRACE

// Paste stacktrace/screenshots/recordings

EXPECTED BEHAVIOR

// Write about the behavior what you expected

HOW TO REPRODUCE

// code and steps to reproduce
themronion commented 11 months ago

Hi, please check the sample repo and how i add images for the pins. Hopefully you will find the answer there