fis-sst / BlazorMaps

BlazorMaps is a Blazor library that provides a C# interface for maps provided by Leaflet.js library. It includes several Leaflet.js features which are easily accessible from C# level within a project and it does not require any use of JavaScript.
https://fis-sst.pl/en
MIT License
70 stars 26 forks source link

Parent component don't know about Map rendering #3

Closed iRumba closed 3 years ago

iRumba commented 3 years ago

In my page I can't subscribe Map events, because

    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
      if (!firstRender)
        return;
      this.MapReference = await this.MapJsInterop.Initialize(this.MapOptions);
      this.MapEvented = new MapEvented(this.MapReference, this.EventedJsInterop);
    }

So, property MapEvented declared in OnAfterRenderAsync, but in parent component I don't know when it happened. Parent's OnAfterRenderAsync not promise that children had rendered. https://github.com/dotnet/aspnetcore/issues/13781

When I subscribe on click event I get exception NRE, because method OnClick uses property MapEvented, that is null on time when my page rendered.

I think, that Map component must rise event "load" to know when it rendered.