diff --git a/src/AzureMapsControl.Components/Map/Map.cs b/src/AzureMapsControl.Components/Map/Map.cs index 0bfee93..af082c8 100644 --- a/src/AzureMapsControl.Components/Map/Map.cs +++ b/src/AzureMapsControl.Components/Map/Map.cs @@ -444,7 +444,7 @@ public async ValueTask AddHtmlMarkersAsync(IEnumerable markers) if (markers != null) { _logger?.LogAzureMapsControlInfo(AzureMapLogEvent.Map_AddHtmlMarkersAsync, "Adding html markers"); - HtmlMarkers = (HtmlMarkers ?? Array.Empty()).Concat(markers); + HtmlMarkers = (HtmlMarkers ?? Array.Empty()).Concat(markers).ToArray(); _logger?.LogAzureMapsControlInfo(AzureMapLogEvent.Map_AddHtmlMarkersAsync, $"{markers.Count()} new html markers will be added"); var parameters = GetHtmlMarkersCreationParameters(markers); await _jsRuntime.InvokeVoidAsync(Constants.JsConstants.Methods.Core.AddHtmlMarkers.ToCoreNamespace(), @@ -530,6 +530,48 @@ await _jsRuntime.InvokeVoidAsync(Constants.JsConstants.Methods.Core.UpdateHtmlMa } : null })); + foreach (var updateWithOptions in updates.Where(u => u.Options != null)) + { + var targetMarker = HtmlMarkers.First(marker => marker.Id == updateWithOptions.Marker.Id); + + if (updateWithOptions.Options.Anchor.ToString() != null) + { + targetMarker.Options.Anchor = updateWithOptions.Options.Anchor; + } + if (updateWithOptions.Options.Color != null) + { + targetMarker.Options.Color = updateWithOptions.Options.Color; + } + if (updateWithOptions.Options.Draggable != null) + { + targetMarker.Options.Draggable = updateWithOptions.Options.Draggable; + } + if (updateWithOptions.Options.HtmlContent != null) + { + targetMarker.Options.HtmlContent = updateWithOptions.Options.HtmlContent; + } + if (updateWithOptions.Options.Position != null) + { + targetMarker.Options.Position = updateWithOptions.Options.Position; + } + if (updateWithOptions.Options.PixelOffset != null) + { + targetMarker.Options.PixelOffset = updateWithOptions.Options.PixelOffset; + } + if (updateWithOptions.Options.SecondaryColor != null) + { + targetMarker.Options.SecondaryColor = updateWithOptions.Options.SecondaryColor; + } + if (updateWithOptions.Options.Text != null) + { + targetMarker.Options.Text = updateWithOptions.Options.Text; + } + if (updateWithOptions.Options.Visible != null) + { + targetMarker.Options.Visible = updateWithOptions.Options.Visible; + } + } + foreach (var updateWithPopup in updates.Where(update => update.Options?.Popup != null)) { var marker = HtmlMarkers.First(marker => marker.Id == updateWithPopup.Marker.Id); @@ -565,7 +607,7 @@ public async ValueTask RemoveHtmlMarkersAsync(IEnumerable markers) _logger?.LogAzureMapsControlInfo(AzureMapLogEvent.Map_RemoveHtmlMarkersAsync, "Removing html markers"); if (HtmlMarkers != null && markers != null) { - HtmlMarkers = HtmlMarkers.Where(marker => markers.Any(m => m != null && m.Id != marker.Id)); + HtmlMarkers = HtmlMarkers.Where(marker => !markers.Any(m => m != null && m.Id == marker.Id)).ToArray(); _logger?.LogAzureMapsControlDebug(AzureMapLogEvent.Map_RemoveHtmlMarkersAsync, $"{markers.Count()} html markers will be removed"); var ids = markers.Select(marker => marker.Id); _logger?.LogAzureMapsControlDebug(AzureMapLogEvent.Map_RemoveHtmlMarkersAsync, $"Ids: {string.Join('|', ids)}"); diff --git a/src/AzureMapsControl.Components/typescript/core/core.ts b/src/AzureMapsControl.Components/typescript/core/core.ts index be3038a..12976ba 100644 --- a/src/AzureMapsControl.Components/typescript/core/core.ts +++ b/src/AzureMapsControl.Components/typescript/core/core.ts @@ -384,7 +384,7 @@ export class Core { } public static removeHtmlMarkers(markerIds: string[]): void { - this._map.markers.remove(this._map.markers.getMarkers().find(marker => markerIds.indexOf((marker as any).amc.id) > -1)); + this._map.markers.remove(this._map.markers.getMarkers().filter(marker => markerIds.includes((marker as any).amc.id))); } public static removeLayers(ids: string[]): void { @@ -458,7 +458,7 @@ export class Core { if (htmlMarkerOption.options.color) { options.color = htmlMarkerOption.options.color; } - if (htmlMarkerOption.options.draggable) { + if (htmlMarkerOption.options.draggable !== null) { options.draggable = htmlMarkerOption.options.draggable; } if (htmlMarkerOption.options.htmlContent) { @@ -476,7 +476,7 @@ export class Core { if (htmlMarkerOption.options.text) { options.text = htmlMarkerOption.options.text; } - if (htmlMarkerOption.options.visible) { + if (htmlMarkerOption.options.visible !== null) { options.visible = htmlMarkerOption.options.visible; } if (htmlMarkerOption.popupOptions) {