Skip to content

Layer Visible doesn't work with multiple dynamic layers. #467

Description

@dirk193

When I dynamically create multiple layers from a list, only the first layer is shown or hidden.

public partial class YMobileMap { private List<FakeVM>? _fakeLayers = []; protected async override Task OnInitializedAsync() { _fakeLayers = []; for (int i = 0; i < 10; i++) { _fakeLayers.Add(new FakeVM { Longitude = 8.413 + i / 100.0 }); } } private async Task FakeVisibleAsync() { _fakeIsVisible = !_fakeIsVisible; foreach (var item in _fakeLayers) { await item.GraphicsLayerRef.SetVisibility(_fakeIsVisible); } } }

public class FakeVM { public GraphicsLayer? GraphicsLayerRef { get; set; } public double Longitude { get; set; } }

Razor File:

`

    <Map>

        @{
            foreach (var item in _fakeLayers)
            {
                <GraphicsLayer @ref="item.GraphicsLayerRef">
                    <Graphic Geometry="new Point(item.Longitude, 49.007)" >
                        @{
                            var color = new MapColor("red");
                        }
                        <SimpleMarkerSymbol Style="SimpleMarkerSymbolStyle.Circle" Color="color" Size="10" />

                    </Graphic>
                </GraphicsLayer>
            }

        <OpenStreetMapLayer />
    </Map>
</MapView>

Visible InVisible
`

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions