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

Cannot derive from sealed type pin #637

Open goodguy010 opened 5 years ago

goodguy010 commented 5 years ago

Not a bug, but an error.

VERSIONS

PLATFORMS

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; }
}

amay077 commented 5 years ago

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"
};
devcssbet commented 4 years ago

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

redbeaner commented 4 years ago

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 ?

AutumnEvans418 commented 4 years ago

744 there is an issue for bindable tags

dalton5 commented 3 years ago

Hi,

Is there some news on the tag property bindable?

Thanks,