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

Anchor is initialized when updating Pin Android #609

Closed Yanc35 closed 5 years ago

Yanc35 commented 5 years ago

VERSIONS

PLATFORMS

ACTUAL BEHAVIOR

Anchor is initialized when updating Pin.

ACTUAL SCREENSHOTS/STACKTRACE

Anchor = new Point(0.5, 0.5) Anchor1 ↓ update Icon = RedCircle → Anchor is initialize (0.5, 1.0) Anchor2

EXPECTED BEHAVIOR

update Icon = RedCircle Anchor3

HOW TO REPRODUCE

// code for reproduce
Xamarin.Forms.GoogleMaps.Android/Logics/PinLogic.cs

protected override void OnUpdateIcon(Pin outerItem, Marker nativeItem)
{
    if (outerItem.Icon != null && outerItem.Icon.Type == BitmapDescriptorType.View)
    {
        // If the pin has an IconView set this method will convert it into an icon for the marker
        TransformXamarinViewToAndroidBitmap(outerItem, nativeItem);
    }
    else
    {
        var factory = _bitmapDescriptorFactory ?? DefaultBitmapDescriptorFactory.Instance;
        var nativeDescriptor = factory.ToNative(outerItem.Icon);
        nativeItem.SetIcon(nativeDescriptor);
        nativeItem.SetAnchor(0.5f, 1f);
        nativeItem.SetInfoWindowAnchor(0.5f, 0f);
    }
}

↓

//        nativeItem.SetAnchor(0.5f, 1f);
//        nativeItem.SetInfoWindowAnchor(0.5f, 0f);

Is there a situation where the last two lines are needed? need the branch condition?

amay077 commented 5 years ago

A-ha, I think no need last two lines too. Could you send me Pull request?