Select to view content in your preferred language

Use subset of BasemapGallery AvailableBasemaps (MAUI)

942
2
Jump to solution
05-19-2023 10:57 AM
Labels (4)
KarenRobine1
Regular Contributor

I'm using the BasemapGallery from Esri.ArcGISRuntime.Toolkit.Maui.  There's an AvailableBasemaps property. I'm trying to figure out a way to limit the number of basemaps added when the control is loaded with all of the basemaps. If anyone has some sample code for this, that would be greatly helpful.   I'm able to remove basemaps using a button after they are loaded, but this need it to occur before all the basemaps load (better performance 😁). Thanks.

0 Kudos
1 Solution

Accepted Solutions
MichaelBranscomb
Esri Frequent Contributor

For now, it looks like loading the default collection of ArcGIS Developer basemaps is unfortunately hard-coded in the Toolkit as currently released on NuGet.org. But the good news is, it's open source and you can easily resolve this yourself and rebuild (until we can triage and resolve appropriately).

You just need to remove the call to LoadFromDefaultPortal() on this line:

arcgis-maps-sdk-dotnet-toolkit/BasemapGallery.cs at main · Esri/arcgis-maps-sdk-dotnet-toolkit · Git...

Because that call ultimately calls PopulateFromDefaultList which creates a default ArcGISPortal instance (arcgis.com) and calls GetDeveloperBasemapsAsync():

arcgis-maps-sdk-dotnet-toolkit/BasemapGalleryController.cs at main · Esri/arcgis-maps-sdk-dotnet-too... 

View solution in original post

2 Replies
MichaelBranscomb
Esri Frequent Contributor

For now, it looks like loading the default collection of ArcGIS Developer basemaps is unfortunately hard-coded in the Toolkit as currently released on NuGet.org. But the good news is, it's open source and you can easily resolve this yourself and rebuild (until we can triage and resolve appropriately).

You just need to remove the call to LoadFromDefaultPortal() on this line:

arcgis-maps-sdk-dotnet-toolkit/BasemapGallery.cs at main · Esri/arcgis-maps-sdk-dotnet-toolkit · Git...

Because that call ultimately calls PopulateFromDefaultList which creates a default ArcGISPortal instance (arcgis.com) and calls GetDeveloperBasemapsAsync():

arcgis-maps-sdk-dotnet-toolkit/BasemapGalleryController.cs at main · Esri/arcgis-maps-sdk-dotnet-too... 

KarenRobine1
Regular Contributor

Thanks for the info on this. I ended up writing my own .NET Maui Control (ContentView) and adding the basemaps I needed from a configuration file. I just needed the ItemId and used ESRI.ArcGISRuntime.Portal.PortalItem to get the item. Then, once I instantiated the ESRI.ArcGISRuntime.Mapping.Basemap, I could get all of the relevant information (Name, Thumbnail, etc).   

0 Kudos