BlazorLeaflet icon indicating copy to clipboard operation
BlazorLeaflet copied to clipboard

Icons Size and Anchor in webassembly core hosted

Open Bisjob opened this issue 4 years ago • 4 comments

Hi, thanks for your Leaflet wrapper ! I'm using it in a webassembly core hosted (.NET Core 3.1), and when I set a size or an Anchor to a marker, there a not added to the map anymore. I never stop to my breakpoint at the begining addMarker function in leafletBlazorInterops.js

I think this is an sort of incompatibility width Size? and Point? types.

I replaced

public Size? Size { get; set; }
public Point? Anchor { get; set; }

by

public int Width { get; set; }
public int Height { get; set; }
public int AnchorX { get; set; }
public int AnchorY { get; set; }

and

iconSize: icon.size ? L.point(icon.size.value.width, icon.size.value.height) : null,
iconAnchor: icon.anchor ? L.point(icon.anchor.value.x, icon.anchor.value.y) : null,

by

iconSize: (icon.width != 0 && icon.height != 0) ? L.point(icon.width, icon.height) : null,
iconAnchor: (icon.anchorX != 0 || icon.anchorY != 0) ? L.point(icon.anchorX, icon.anchorY) : null,

to make it works

Bisjob avatar Jun 22 '20 11:06 Bisjob

It appears to be something about how Blazor WASM serializes nullable value types. (Still investigating.)

chucker avatar Jul 11 '20 20:07 chucker

This appears to be a Blazor issue. https://github.com/dotnet/aspnetcore/issues/23885

chucker avatar Jul 12 '20 21:07 chucker

I have the same issue still with .NET 5. @Rizov74's fix works luckily.

johannesmols avatar Nov 12 '20 21:11 johannesmols

I have the same issue in .NET Core 5, Blazor Server Side. @Rizov74 fix works fine!

markus-renezeder avatar Mar 28 '21 05:03 markus-renezeder