Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 44 additions & 2 deletions src/AzureMapsControl.Components/Map/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ public async ValueTask AddHtmlMarkersAsync(IEnumerable<HtmlMarker> markers)
if (markers != null)
{
_logger?.LogAzureMapsControlInfo(AzureMapLogEvent.Map_AddHtmlMarkersAsync, "Adding html markers");
HtmlMarkers = (HtmlMarkers ?? Array.Empty<HtmlMarker>()).Concat(markers);
HtmlMarkers = (HtmlMarkers ?? Array.Empty<HtmlMarker>()).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(),
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -565,7 +607,7 @@ public async ValueTask RemoveHtmlMarkersAsync(IEnumerable<HtmlMarker> 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)}");
Expand Down
6 changes: 3 additions & 3 deletions src/AzureMapsControl.Components/typescript/core/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down