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

BasemapGallery loading demo data in production release #566

Open
espenrl opened this issue Apr 5, 2024 · 2 comments
Open

BasemapGallery loading demo data in production release #566

espenrl opened this issue Apr 5, 2024 · 2 comments
Milestone

Comments

@espenrl
Copy link

espenrl commented Apr 5, 2024

Hi, I have a hard time initializing BasemapGallery.AvailableBasemaps with a custom list of basemaps. The shown gallery is overridden by the loading of what seems to be demo data. Except for a sample app, why would one want this behavior?

PS: Not using a portal

public BasemapGallery()
{
_controller = new BasemapGalleryController();
_controller.PropertyChanged += HandleControllerPropertyChanged;
ListItemTemplate = DefaultListDataTemplate;
GridItemTemplate = DefaultGridDataTemplate;
ControlTemplate = DefaultControlTemplate;
_ = _controller.LoadFromDefaultPortal();
}

@dotMorten
Copy link
Member

The shown gallery is overridden by the loading of what seems to be demo data

Could you clarify what you mean by that? Any chance you could provide a small reproducer that demonstrates the issue?

@espenrl
Copy link
Author

espenrl commented Apr 8, 2024

I can see I was a bit short in my description. I'll explain myself more clearly.

If I add this xaml

<toolkit:BasemapGallery />

then I get a list of maps

image

I would expect to get an empty basemap gallery, I expect to get nothing at all. That is what I think of as "demo basemaps". For me it is a bit unusual that a UI control loads default data.

Then I try this expecting to stop loading the "demo basemaps"

<toolkit:BasemapGallery Portal="{x:Null}" />

But it still continues loading.

Next up is

<toolkit:BasemapGallery Portal="{x:Null}"
                        AvailableBasemaps="{Binding Basemaps}" />
public MapPageViewModel()
{
    LoadBasemapGallery();
}

private async void LoadBasemapGallery()
{
    var aTask = BasemapGalleryItem.CreateAsync(new Basemap(new ArcGISTiledLayer(new Uri(Constants.GeodataServiceUri.Bilder))));
    var bTask = BasemapGalleryItem.CreateAsync(new Basemap(new ArcGISTiledLayer(new Uri(Constants.GeodataServiceUri.VectorNordenBasisTerreng))));
    var cTask = BasemapGalleryItem.CreateAsync(new Basemap(new ArcGISTiledLayer(new Uri(Constants.GeodataServiceUri.VectorNordenGråtoneTerreng))));

    await Task.WhenAll(aTask, bTask, cTask);

    Basemaps.Add(aTask.Result);
    Basemaps.Add(bTask.Result);
    Basemaps.Add(cTask.Result);
}

public ObservableCollection<BasemapGalleryItem> Basemaps { get; } = new();

But it still continues to load the "demo basemaps" and I can't get it to show my custom basemaps definition.

At this point I looked up the source code

public BasemapGallery()
{
_controller = new BasemapGalleryController();
_controller.PropertyChanged += HandleControllerPropertyChanged;
ListItemTemplate = DefaultListDataTemplate;
GridItemTemplate = DefaultGridDataTemplate;
ControlTemplate = DefaultControlTemplate;
_ = _controller.LoadFromDefaultPortal();
}

..and discovered that the loading of initial "demo basemaps" are triggered from the constructor regardless of anything else. For apps that don't use this initial setup of basemaps I think that is a bit unfortunate. It also leads to many ArcGISWebException because of missing ChallengeHandler setup, thus slowing down app startup.

@pMaske pMaske modified the milestone: 200.5 May 29, 2024
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

3 participants