Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RemoveHtmlMarkersAsync() Only removes the first marker #105

Open
blackboxlogic opened this issue Oct 16, 2024 · 0 comments
Open

RemoveHtmlMarkersAsync() Only removes the first marker #105

blackboxlogic opened this issue Oct 16, 2024 · 0 comments

Comments

@blackboxlogic
Copy link

Describe the bug
RemoveHtmlMarkersAsync() accepts a params array of markers, but it only removes the first marker passed in.

To Reproduce

@page "/Markers/HtmlMarkersRemove"
@rendermode InteractiveServer
@using AzureMapsControl.Components.Markers
@using AzureMapsControl.Components.Atlas

@using AzureMapsControl.Components.Map
<AzureMap Id="map"
          EventActivationFlags="MapEventActivationFlags
                                .None()
                                .Enable(MapEventType.Click, MapEventType.Load)"
          OnClick="OnMapClick" OnLoad="OnMapLoad" />

@code
{
	private List<HtmlMarker> Markers = new List<HtmlMarker>();

	public async Task OnMapLoad(MapEventArgs eventArgs)
	{
		for(int i = 0; i < 10; i++)
		{
			Markers.Add(new HtmlMarker(new HtmlMarkerOptions
				{
					Position = new Position(47.3769 + i, 8.5417 + i)
				}, HtmlMarkerEventActivationFlags.None()));
		}
	}

	public bool Added = false;

	public async Task OnMapClick(MapMouseEventArgs eventArgs)
	{
		if (Added)
		{
			// foreach (var marker in Markers)
			// {
			// 	await eventArgs.Map.RemoveHtmlMarkersAsync(marker);
			// }
			await eventArgs.Map.RemoveHtmlMarkersAsync(Markers);
		}
		else
		{
			await eventArgs.Map.AddHtmlMarkersAsync(Markers);
		}

		Added = !Added;
	}
}

Clicking once on the map adds 10 markers. Clicking again on the map only removes one marker. Replace the bulk operations with the loop version (currently commented out) and see that it works as expected.

Expected behavior
RemoveHtmlMarkersAsync() should remove all the markers that are passed in.

Desktop (please complete the following information):

  • OS: Windows 10 Home
  • Browser: Firefox (latest)
  • Version: 1.16.1

Additional context
The console output correctly indicates that all 10 items are removed, but the visual on the map only removes the first. I have not confirmed that this isn't an issue with azure maps. I believe AddHtmlMarkersAsync() and UpdateHtmlMarkersAsync() are working correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant