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

ClusterAggregates.razor often fails unless I add a delay #102

Open
MarkEvans8 opened this issue Sep 15, 2024 · 1 comment
Open

ClusterAggregates.razor often fails unless I add a delay #102

MarkEvans8 opened this issue Sep 15, 2024 · 1 comment

Comments

@MarkEvans8
Copy link

I'm a newbie so please excuse any mistakes I have made by submitting this issue. I have not used Slack before, and I was unable to join the group there. My email address is [email protected] if anyone needs to add me first.

I have found that the example file ClusterAggregates.razor often fails. It's inconsistent. The map always loads. But sometimes the bubble layer loads and sometimes it doesn't. When it fails, I get the following JS error:

atlas.min.js:55 Error: layers.75e0ea40-700e-4382-9741-5b7027861563: source "2671a15c-0192-4d19-b5e6-bdffc9c45ef8" not found
at Object.Rn [as emitValidationErrors] (atlas.min.js:56:9835)
at pt (atlas.min.js:56:355799)
at mt._validate (atlas.min.js:56:375637)
at mt.addLayer (atlas.min.js:56:367199)
at t.addLayer (atlas.min.js:105:172826)
at fN._addMapboxLayers (atlas.min.js:105:1048190)

I have also found that adding the following delay fixes the problem:

public async Task OnMapReady(MapEventArgs eventArgs)
{
    await eventArgs.Map.AddPopupAsync(_popup);        

    _datasource = new AzureMapsControl.Components.Data.DataSource
        {
            EventActivationFlags = AzureMapsControl.Components.Data.DataSourceEventActivationFlags.None(),
            Options = new()
            {
                Cluster = true,
                ClusterRadius = 50,
                ClusterProperties = new Dictionary<string, AzureMapsControl.Components.Atlas.Expression>(_entityTypes.Select(entityType => BuildClusterProperty(entityType)))
            }
        };

    await Task.Delay(100); // ############# map often fails without this delay ###############
    await eventArgs.Map.AddSourceAsync(_datasource);        
}

I'm wondering if there is a better way to avoid this issue?

To Reproduce

  1. Create a new Blazor Web app.
  2. Add all the nuget packages, links to js files, appconfig.json stuff, AuthService.cs, data file etc.
  3. Copy/paste ClusterAggregates.razor to your project.
  4. Run

Expected behavior
Load the bubble layer every time rather than just some of the time.

Desktop (please complete the following information):

  • OS: Windows 11
  • Browser Edge
  • VS 2022, .net 8.
@blackboxlogic
Copy link

blackboxlogic commented Oct 16, 2024

I fixed a similar issue by starting everything with OnLoad instead of OnReady. It seems like OnReady is more like AlmostReady. I found the answer here.

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

2 participants