Xamarin.forms.googlemaps: Cannot derive from sealed type pin

Created on 14 Jul 2019  路  5Comments  路  Source: amay077/Xamarin.Forms.GoogleMaps

Not a bug, but an error.

VERSIONS

  • Xamarin.Forms.GoogleMaps - 3.2.0
  • Xamarin.Forms - 4.1.0.581479
  • *

PLATFORMS

  • [X ] Android
  • [x] iOS
  • [ ] UWP

ACTUAL BEHAVIOR

I need to add custom properties to my pin. How I normally would do it is to derive from the pin class and add the custom properties, but that is not possible here as the pin class is sealed.

How can I add custom properties to the pin class??
Can I open the code in the nuget package and unseal the class and if so how? Or will that cause additional errors?

ACTUAL SCREENSHOTS/STACKTRACE

public class CustomGPin : Xamarin.Forms.GoogleMaps.Pin //cannot derive from sealed type pin
{
public string CustomProperty1 { get; set; }
public string CustomProperty2 { get; set; }
public string CustomProperty3 { get; set; }
public string CustomProperty4 { get; set; }
}

// paste stacktrace

EXPECTED BEHAVIOR

I would like to add custom properties to the pin class.
Adding custom properties to pin class are quite essential? So I would assume there is another way to do it?

HOW TO REPRODUCE

Reprode by trying to derive
public class CustomGPin : Xamarin.Forms.GoogleMaps.Pin //cannot derive from sealed type pin
{
public string CustomProperty1 { get; set; }
public string CustomProperty2 { get; set; }
public string CustomProperty3 { get; set; }
public string CustomProperty4 { get; set; }
}

Most helpful comment

Hi ! I switch from Xamarin.Forms.Map and as cannot derive CustomPin so I store my object in Tag. But i got a small issue where i can't to store object in Tag through Binding and use them in Custom Renderer. Any issue if make Tag a Bindable Property ?

All 5 comments

Yes, Pin is sealed class.
You can use Pin.Tag as object property.

class YourData 
{
    public string CustomProperty1 { get; set; }
    public string CustomProperty2 { get; set; }
    public string CustomProperty3 { get; set; }
    public string CustomProperty4 { get; set; } 
}

pin.Tag = new YourData
{
    CustomProperty1 = "A",
    CustomProperty2 = "B",
    CustomProperty3 = "C",
    CustomProperty4 = "D"
};

Why did you opt into sealing the class Pin as compared to Xamarin.Forms.Maps' Pin type ?

Hi ! I switch from Xamarin.Forms.Map and as cannot derive CustomPin so I store my object in Tag. But i got a small issue where i can't to store object in Tag through Binding and use them in Custom Renderer. Any issue if make Tag a Bindable Property ?

744 there is an issue for bindable tags

Hi,

Is there some news on the tag property bindable?

Thanks,

Was this page helpful?
0 / 5 - 0 ratings