I have got a WPF MVVM app where I have a MapView, and the BasemapGallery from the toolkit:
<esri:MapView
x:Name="MainMapView"
Map="{Binding Map}"
/>
<esritoolkit:BasemapGallery
x:Name="BasemapGallery"
GeoModel="{Binding ElementName=MainMapView, Path=Map}"
AvailableBasemaps="{Binding AvailableBasemaps}"/>
The Map property on the VM:
private Map _map;
public Map Map
{
get { return _map; }
set { SetProperty(ref _map, value); }
}
// initialized in VM constructor
Map = new Map
{
InitialViewpoint = new Viewpoint(new MapPoint(X, Y, spatialReference: SpatialReference.Create(3857)), 130617),
Basemap = new Basemap(BasemapStyle.ArcGISTopographic)
};
Changing the mapview's base map from the gallery works fine. The gallery loads base maps from AGOL which is something I would like to override. The app will be on an offline device so I have some map packages locally but I am currently testing with a VectorTileServer base map:
var vectorTiledLayer = new ArcGISVectorTiledLayer(new Uri("https://server/arcgis/rest/services/MyService/VectorTileServer"));
var newBaseMap = new Basemap(vectorTiledLayer)
var item = await BasemapGalleryItem.CreateAsync(newBaseMap);
AvailableBasemaps = new List<BasemapGalleryItem>();
AvailableBasemaps.Add(item);
// where AvailableBasemaps is:
private IList<BasemapGalleryItem> _availableBasemaps;
public IList<BasemapGalleryItem> AvailableBasemaps
{
get { return _availableBasemaps; }
set { SetProperty(ref _availableBasemaps, value); }
}
The gallery is still showing the AGOL base maps, and not at all my custom base map.
What am I doing wrong?
Esri.ArcGISRuntime.WPF v100.15.0
Esri.ArcGISRuntime.Toolkit v100.15.0