Xamarin.Forms.GoogleMaps
Xamarin.Forms.GoogleMaps copied to clipboard
Custom Pin Not Showing
VERSIONS
- Xamarin.Forms.GoogleMaps -3.3.0
- Xamarin.Forms - 4.2.0.910.310
PLATFORMS
- [x ] Android
- [ ] iOS
- [ ] UWP
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.
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.
Get the same but on both platforms
I can reproduce it on all Android devices only
It only renders the first element passed into BitmapDescriptorFactory.FromView
on Android right now.