BlazorLeaflet icon indicating copy to clipboard operation
BlazorLeaflet copied to clipboard

Stop working after "RemoveLayer(Marker)"

Open markus-renezeder opened this issue 3 years ago • 0 comments

Hello and thank you very much for sharing your code with us!

I was working with an "older" version of your code and it was working fine. After I found the possibility to use the map bounds in the current version, I updated the code. After the update the application stops working if I remove a marker from the map (the Blazor app stops, the map is still working).

You can reproduce it with your sample application by trying to draw a shape.

I did a little bit of research and restored the async function from the older version in LeafletInterop.cs which works for me.

//public static void RemoveLayer(IJSRuntime jsRuntime, string mapId, string layerId)
//{
//	jsRuntime.InvokeVoidAsync($"{_BaseObjectContainer}.removeLayer", mapId, layerId).GetAwaiter().GetResult();
//	DisposeLayerReference(layerId);
//}

public static async ValueTask RemoveLayer(IJSRuntime jsRuntime, string mapId, string layerId)
{
	await jsRuntime.InvokeVoidAsync($"{_BaseObjectContainer}.removeLayer", mapId, layerId);
	DisposeLayerReference(layerId);
}

I'm using .NET Core 5, Blazor Server Side.

BR Markus

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