amay077 / Xamarin.Forms.GoogleMaps

Map library for Xamarin.Forms using Google maps API
https://www.nuget.org/packages/Xamarin.Forms.GoogleMaps/
MIT License
546 stars 346 forks source link

Custom Pin Not Showing #682

Open chrisfoulds opened 4 years ago

chrisfoulds commented 4 years ago

VERSIONS

PLATFORMS

ACTUAL BEHAVIOR

Image with Pin not showing I am using the following code, I get a coloured square at the correct location just no image.

`var startPin = new Pin()
            {
                Type = PinType.Place,
                Label = "Start",
                ZIndex = 5,
                Address = DateTimeToString(currentRun.startDateTime, true),
                Position = new Position(startItem.position.Latitude, startItem.position.Longitude),
            };

            startPin.Icon = BitmapDescriptorFactory.FromView(
                    new ContentView
                    {
                        WidthRequest = 45,
                        HeightRequest = 45,
                        BackgroundColor=Color.Blue,
                        Content = new Image
                        {
                            Source = ImageSource.FromFile("fas_dot_circle.png")

                        }
                    }
                );`

If I change the content to this, the text shows I just can't get an image to display

` Content = new Label
                        {
                            Text="Hello" , TextColor=Color.White

                        }`

EXPECTED BEHAVIOR

To see the image, not just get the background color as a square.

KevinHu-au commented 4 years ago

I also got this issue. Seems like PinLogic.TransformXamarinViewToAndroidBitmap() cannot properly convert the XF view to the Android view. After a few try, I suspect the Platform.GetRenderer(view) only return the top level element.

My solution for this issue to fork the library and update the PinLogic and MapRenderer classes to handle the custom pins. See issue #681 for more details.

microsec-bohdan commented 2 years ago

Get the same but on both platforms

bbenetskyy commented 2 years ago

I can reproduce it on all Android devices only

hvaughan3 commented 1 year ago

It only renders the first element passed into BitmapDescriptorFactory.FromView on Android right now.