Skip to content

[BUG]: Deserialization of IGeometry fails #160

@Jacob-Steentoft

Description

@Jacob-Steentoft

Prerequisites

  • I have checked that this issue has not already been reported
  • I have tried clearing browser cache and restarting my application

Package Version

1.4.0-pre2

.NET Version

10

Browser

No response

What happened?

When the event OnClick is triggered the STJ deserializer fails with:
Error: System.NotSupportedException: DeserializationMustSpecifyTypeDiscriminator, Community.Blazor.MapLibre.Models.Feature.IGeometry Path: $.features[0].geometry | LineNumber: 0 | BytePositionInLine: 209.

Expected behavior

The data is deserialized correctly from the map.

Reproduction steps

1. Register callback on the map for clicks `await _map.OnClick("resource_marker", OnMapClick);`
2. Click on the map with an element that contains a `IGeometry`

Code Sample

private async Task OnMapClick(MapMouseEvent @event)
	{
		if (@event.Features.FirstOrDefault() is not {} feature)
		{
			return;
		}

		var id = feature.Properties["id"].GetGuid();

		var result = await resourceService.LookupResourcesAsync([id], CancelToken);
		if (!result.IsSuccessful)
		{
			Snacks.Add("Failed to load resource details", Severity.Error);
			return;
		}

		_selectedResource = result.Value[id];
		StateHasChanged();
	}

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions