Xamarin.Forms.GoogleMaps icon indicating copy to clipboard operation
Xamarin.Forms.GoogleMaps copied to clipboard

Cannot derive from sealed type pin

Open goodguy010 opened this issue 6 years ago • 5 comments

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

goodguy010 avatar Jul 14 '19 13:07 goodguy010

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

amay077 avatar Jul 22 '19 11:07 amay077

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

devcssbet avatar Oct 23 '19 10:10 devcssbet

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 ?

redbeaner avatar Apr 25 '20 12:04 redbeaner

#744 there is an issue for bindable tags

AutumnEvans418 avatar Sep 10 '20 19:09 AutumnEvans418

Hi,

Is there some news on the tag property bindable?

Thanks,

dalton5 avatar Dec 16 '20 18:12 dalton5