darnton / LeafletBlazor

Blazor component for interop with Leaflet slippy map library.
30 stars 20 forks source link

How to add Icon to MarkerOptions? #11

Open cwschroeder opened 3 years ago

cwschroeder commented 3 years ago

I tried to extend the MarkerOptions by an Icon object like that.

public class Icon : InteropObject
{
        [JsonIgnore]
        public IconOptions IconOptions { get; set; }

        public Icon(string iconUrl)
        {
            this.IconOptions = new IconOptions()
            {
                IconUrl = iconUrl,
            };

        }

        protected override async Task<IJSObjectReference> CreateJsObjectRef()
        {
            return await JSBinder.JSRuntime.InvokeAsync<IJSObjectReference>("L.icon", IconOptions);
        }
}

public class IconOptions
{
    public string IconUrl { get; set; }
} 

Unfortunately the JS-Runtime throws an error because createIcon() does not exist. What is missing?

timothyparez commented 3 years ago

14