Skip to content

Commit 75c9bbe

Browse files
Support for BasemapGallery toolkit control to include 3D Basemaps (#628)
* Add 3D Basemap Gallery support in WPF and BasemapGalleryItem * Add 3D basemap support to BasemapGallery in UWP, WinUI and MAUI Changed 3D basemap identification from Enum to boolean for simplified binding * Added condition to check if `GeoModel` is a `Scene` before fetching 3D basemaps * Renamed `BasemapGallery3DAppearanceSample` to `BasemapGallerySceneViewAppearanceSample`. * Consolidated Basemap fetching methods * Refactor BasemapGalleryItem to dynamically determine Is3D * Refactored 3D tag in BasemapGallery to sta on top right corner of the image in Grid View. * Introduce caching for basemaps in BasemapGalleryController * Update src/Toolkit/Toolkit.WinUI/Esri.ArcGISRuntime.Toolkit.WinUI.csproj * Update bindings to use static lambdas for type safety as new feature from .Net 9 * Reverted binding style for private set properties * Revert Margin in Basemap Gallery Item * Fixing bug in BasemapGallery loading * Restore styling for basemapgallery * Refactor basemap loading to be fully asynchronous * Refactor basemap loading and update visibility handling * Update BasemapGallery itemTypeBorder to theme-based color * Add one-way binding to fix the width sldier in WinUI and UWP and error handling improvements * Refactor loading state handling in BasemapGalleryController * Refactor basemap update logic in BasemapGallery * Enhance theme management in BasemapGallery
1 parent ecff211 commit 75c9bbe

File tree

15 files changed

+568
-142
lines changed

15 files changed

+568
-142
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ContentPage
3+
x:Class="Toolkit.SampleApp.Maui.Samples.BasemapGallerySceneViewAppearanceSample"
4+
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
6+
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
7+
xmlns:esri="clr-namespace:Esri.ArcGISRuntime.Maui;assembly=Esri.ArcGISRuntime.Maui"
8+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9+
xmlns:toolkit="clr-namespace:Esri.ArcGISRuntime.Toolkit.Maui;assembly=Esri.ArcGISRuntime.Toolkit.Maui"
10+
Title="3D BasemapGallery - appearance"
11+
mc:Ignorable="d">
12+
<ContentPage.Content>
13+
<Grid BackgroundColor="{AppThemeBinding Dark=Black, Light=White}">
14+
<Grid.RowDefinitions>
15+
<RowDefinition Height="Auto" />
16+
<RowDefinition Height="*" />
17+
<RowDefinition Height="200" />
18+
</Grid.RowDefinitions>
19+
<StackLayout Grid.Row="0" Orientation="Horizontal">
20+
<Button Clicked="Button_Add_Item" Text="Add special items" />
21+
<Button Clicked="Button_Remove_Item" Text="Remove last item" />
22+
</StackLayout>
23+
24+
<esri:SceneView x:Name="MySceneView" Grid.Row="1" />
25+
26+
<toolkit:BasemapGallery
27+
x:Name="Gallery"
28+
Grid.Row="2"
29+
GeoModel="{Binding Source={x:Reference MySceneView}, Path=Scene, Mode=OneWay}" />
30+
</Grid>
31+
</ContentPage.Content>
32+
</ContentPage>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using Esri.ArcGISRuntime.Mapping;
2+
using Esri.ArcGISRuntime.Toolkit.Maui;
3+
4+
namespace Toolkit.SampleApp.Maui.Samples
5+
{
6+
[XamlCompilation(XamlCompilationOptions.Compile)]
7+
[SampleInfo(Category = "BasemapGallery", Description = "Sceneview Basemap Appearance customization sample", ApiKeyRequired = true)]
8+
public partial class BasemapGallerySceneViewAppearanceSample : ContentPage
9+
{
10+
public BasemapGallerySceneViewAppearanceSample()
11+
{
12+
InitializeComponent();
13+
MySceneView.Scene = new Scene(BasemapStyle.ArcGISImagery);
14+
}
15+
16+
private async void Button_Add_Item(object? sender, EventArgs e)
17+
{
18+
if (Gallery.AvailableBasemaps is null) return;
19+
BasemapGalleryItem item = await BasemapGalleryItem.CreateAsync(new Basemap());
20+
item.Name = "With Thumbnail";
21+
item.Tooltip = Guid.NewGuid().ToString();
22+
item.Thumbnail = new Esri.ArcGISRuntime.UI.RuntimeImage(new Uri("https://www.esri.com/content/dam/esrisites/en-us/home/homepage-tile-arcgis-collaboration.jpg"));
23+
Gallery.AvailableBasemaps.Add(item);
24+
25+
BasemapGalleryItem item2 = await BasemapGalleryItem.CreateAsync(new Basemap());
26+
item2.Name = "Without Thumbnail";
27+
Gallery.AvailableBasemaps.Add(item2);
28+
}
29+
30+
private void Button_Remove_Item(object? sender, EventArgs e)
31+
{
32+
if (Gallery.AvailableBasemaps?.Any() == true)
33+
{
34+
Gallery.AvailableBasemaps.RemoveAt(Gallery.AvailableBasemaps.Count - 1);
35+
}
36+
}
37+
}
38+
}

src/Samples/Toolkit.SampleApp.UWP/Samples/BasemapGallery/BasemapGalleryAppearanceSample.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
Background="White">
5151
<toolkit:BasemapGallery
5252
x:Name="Gallery"
53-
Width="{x:Bind WidthSlider.Value}"
53+
Width="{x:Bind WidthSlider.Value, Mode=OneWay}"
5454
GeoModel="{x:Bind MyMapView.Map, Mode=OneWay}" />
5555
</Border>
5656
</Grid>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<Page
2+
x:Class="Esri.ArcGISRuntime.Toolkit.SampleApp.Samples.BasemapGallery.BasemapGallerySceneViewAppearanceSample"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:esri="using:Esri.ArcGISRuntime.UI.Controls"
7+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8+
xmlns:toolkit="using:Esri.ArcGISRuntime.Toolkit.UI.Controls"
9+
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
10+
mc:Ignorable="d">
11+
<Page.Resources>
12+
<Style TargetType="Button">
13+
<Setter Property="HorizontalAlignment" Value="Stretch" />
14+
</Style>
15+
</Page.Resources>
16+
<Grid>
17+
<esri:SceneView x:Name="MySceneView" />
18+
19+
<Border
20+
Width="200"
21+
Margin="8"
22+
Padding="8"
23+
HorizontalAlignment="Right"
24+
VerticalAlignment="Top"
25+
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
26+
<StackPanel>
27+
<TextBlock Text="Control Width:" />
28+
<Slider
29+
x:Name="WidthSlider"
30+
Maximum="1000"
31+
Minimum="0"
32+
Value="200" />
33+
<TextBlock Text="Gallery View Style: " />
34+
<ComboBox
35+
x:Name="ViewStyleCombobox"
36+
HorizontalAlignment="Stretch"
37+
SelectionChanged="ViewStyleCombobox_SelectionChanged" />
38+
<Button
39+
Margin="0,4,0,4"
40+
Click="Button_Add_Last"
41+
Content="Add special items" />
42+
<Button Click="Button_Remove_Last" Content="Remove last item" />
43+
</StackPanel>
44+
</Border>
45+
46+
<Border
47+
Margin="8"
48+
HorizontalAlignment="Left"
49+
VerticalAlignment="Bottom"
50+
Background="White">
51+
<toolkit:BasemapGallery
52+
x:Name="Gallery"
53+
Width="{x:Bind WidthSlider.Value, Mode=OneWay}"
54+
GeoModel="{x:Bind MySceneView.Scene, Mode=OneWay}" />
55+
</Border>
56+
</Grid>
57+
</Page>
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using Esri.ArcGISRuntime.Mapping;
2+
using Esri.ArcGISRuntime.Toolkit.UI;
3+
using System;
4+
using System.Linq;
5+
6+
namespace Esri.ArcGISRuntime.Toolkit.SampleApp.Samples.BasemapGallery
7+
{
8+
[SampleInfo(ApiKeyRequired = true)]
9+
public sealed partial class BasemapGallerySceneViewAppearanceSample : Page
10+
{
11+
public BasemapGallerySceneViewAppearanceSample()
12+
{
13+
InitializeComponent();
14+
MySceneView.Scene = new Scene(BasemapStyle.ArcGISImagery);
15+
ViewStyleCombobox.Items.Add("Auto");
16+
ViewStyleCombobox.Items.Add("List");
17+
ViewStyleCombobox.Items.Add("Grid");
18+
ViewStyleCombobox.SelectedIndex = 0;
19+
}
20+
21+
private void ViewStyleCombobox_SelectionChanged(object sender, SelectionChangedEventArgs e)
22+
{
23+
switch (ViewStyleCombobox.SelectedIndex)
24+
{
25+
case 0:
26+
Gallery.GalleryViewStyle = BasemapGalleryViewStyle.Automatic;
27+
break;
28+
case 1:
29+
Gallery.GalleryViewStyle = BasemapGalleryViewStyle.List;
30+
break;
31+
case 2:
32+
Gallery.GalleryViewStyle = BasemapGalleryViewStyle.Grid;
33+
break;
34+
}
35+
}
36+
37+
private async void Button_Add_Last(object sender, RoutedEventArgs e)
38+
{
39+
BasemapGalleryItem item = await BasemapGalleryItem.CreateAsync(new Basemap());
40+
item.Name = "With Thumbnail";
41+
item.Tooltip = Guid.NewGuid().ToString();
42+
item.Thumbnail = new ArcGISRuntime.UI.RuntimeImage(new Uri("https://www.esri.com/content/dam/esrisites/en-us/home/homepage-tile-arcgis-collaboration.jpg"));
43+
Gallery.AvailableBasemaps.Add(item);
44+
45+
BasemapGalleryItem item2 = await BasemapGalleryItem.CreateAsync(new Basemap());
46+
item2.Name = "Without Thumbnail";
47+
Gallery.AvailableBasemaps.Add(item2);
48+
}
49+
50+
private void Button_Remove_Last(object sender, RoutedEventArgs e)
51+
{
52+
if (Gallery.AvailableBasemaps.Any())
53+
{
54+
Gallery.AvailableBasemaps.Remove(Gallery.AvailableBasemaps.Last());
55+
}
56+
}
57+
}
58+
}

src/Samples/Toolkit.SampleApp.UWP/Toolkit.Samples.UWP.csproj

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@
119119
<DependentUpon>MainPage.xaml</DependentUpon>
120120
</Compile>
121121
<Compile Include="SampleDatasource.cs" />
122+
<Compile Include="Samples\BasemapGallery\BasemapGallerySceneViewAppearanceSample.xaml.cs">
123+
<DependentUpon>BasemapGallerySceneViewAppearanceSample.xaml</DependentUpon>
124+
</Compile>
122125
<Compile Include="Samples\BasemapGallery\BasemapGalleryAppearanceSample.xaml.cs">
123126
<DependentUpon>BasemapGalleryAppearanceSample.xaml</DependentUpon>
124127
</Compile>
@@ -218,6 +221,10 @@
218221
<Generator>MSBuild:Compile</Generator>
219222
<SubType>Designer</SubType>
220223
</Page>
224+
<Page Include="Samples\BasemapGallery\BasemapGallerySceneViewAppearanceSample.xaml">
225+
<Generator>MSBuild:Compile</Generator>
226+
<SubType>Designer</SubType>
227+
</Page>
221228
<Page Include="Samples\BasemapGallery\BasemapGalleryAppearanceSample.xaml">
222229
<Generator>MSBuild:Compile</Generator>
223230
<SubType>Designer</SubType>
@@ -322,9 +329,9 @@
322329
<Project>{a6431f30-a608-4c78-80be-548c322cbe75}</Project>
323330
<Name>Esri.ArcGISRuntime.Toolkit.UWP</Name>
324331
</ProjectReference>
325-
<PackageReference Include="Esri.ArcGISRuntime.UWP">
326-
<Version>$(ArcGISRuntimePackageVersion)</Version>
327-
</PackageReference>
332+
<PackageReference Include="Esri.ArcGISRuntime.UWP">
333+
<Version>$(ArcGISRuntimePackageVersion)</Version>
334+
</PackageReference>
328335
</ItemGroup>
329336
</When>
330337
<Otherwise>
@@ -358,4 +365,4 @@
358365
<Target Name="AfterBuild">
359366
</Target>
360367
-->
361-
</Project>
368+
</Project>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<UserControl
2+
x:Class="Esri.ArcGISRuntime.Toolkit.Samples.BasemapGallery.BasemapGallerySceneViewAppearanceSample"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013"
7+
xmlns:local="clr-namespace:Esri.ArcGISRuntime.Toolkit.Samples.BasemapGallery"
8+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9+
d:DesignHeight="450"
10+
d:DesignWidth="800"
11+
mc:Ignorable="d">
12+
<Grid>
13+
<esri:SceneView x:Name="MySceneView" />
14+
<Border
15+
Width="200"
16+
Margin="8"
17+
Padding="8"
18+
HorizontalAlignment="Right"
19+
VerticalAlignment="Top"
20+
Background="White">
21+
<StackPanel>
22+
<Label Content="Control Width:" />
23+
<Slider
24+
x:Name="WidthSlider"
25+
Maximum="1000"
26+
Minimum="0"
27+
Value="200" />
28+
<Label Content="Gallery View Style: " />
29+
<ComboBox x:Name="ViewStyleCombobox" SelectionChanged="ViewStyleCombobox_SelectionChanged" />
30+
<Button
31+
Margin="0,4,0,4"
32+
Click="Button_Add_Last"
33+
Content="Add special items" />
34+
<Button Click="Button_Remove_Last" Content="Remove last item" />
35+
</StackPanel>
36+
</Border>
37+
38+
<Border
39+
Margin="8"
40+
HorizontalAlignment="Left"
41+
VerticalAlignment="Bottom"
42+
Background="White">
43+
<esri:BasemapGallery
44+
x:Name="Gallery"
45+
Width="{Binding ElementName=WidthSlider, Path=Value}"
46+
GeoModel="{Binding ElementName=MySceneView, Path=Scene, Mode=OneWay}" />
47+
</Border>
48+
</Grid>
49+
</UserControl>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
using Esri.ArcGISRuntime.Mapping;
2+
using Esri.ArcGISRuntime.Toolkit.UI;
3+
using System;
4+
using System.Linq;
5+
using System.Windows;
6+
using System.Windows.Controls;
7+
8+
namespace Esri.ArcGISRuntime.Toolkit.Samples.BasemapGallery
9+
{
10+
[SampleInfo(Category = "BasemapGallery", DisplayName = "Sceneview BasemapGallery - Appearance", Description = "Sample showing customization options related to appearance for a Sceneview Basemap Gallery", ApiKeyRequired = true)]
11+
public partial class BasemapGallerySceneViewAppearanceSample : UserControl
12+
{
13+
public BasemapGallerySceneViewAppearanceSample()
14+
{
15+
InitializeComponent();
16+
MySceneView.Scene = new Scene(BasemapStyle.ArcGISImagery);
17+
ViewStyleCombobox.Items.Add("Auto");
18+
ViewStyleCombobox.Items.Add("List");
19+
ViewStyleCombobox.Items.Add("Grid");
20+
ViewStyleCombobox.SelectedIndex = 0;
21+
}
22+
23+
private void ViewStyleCombobox_SelectionChanged(object sender, SelectionChangedEventArgs e)
24+
{
25+
switch (ViewStyleCombobox.SelectedIndex)
26+
{
27+
case 0:
28+
Gallery.GalleryViewStyle = BasemapGalleryViewStyle.Automatic;
29+
break;
30+
case 1:
31+
Gallery.GalleryViewStyle = BasemapGalleryViewStyle.List;
32+
break;
33+
case 2:
34+
Gallery.GalleryViewStyle = BasemapGalleryViewStyle.Grid;
35+
break;
36+
}
37+
}
38+
39+
private async void Button_Add_Last(object sender, RoutedEventArgs e)
40+
{
41+
BasemapGalleryItem item = await BasemapGalleryItem.CreateAsync(new Basemap());
42+
item.Name = "With Thumbnail";
43+
item.Tooltip = Guid.NewGuid().ToString();
44+
item.Thumbnail = new ArcGISRuntime.UI.RuntimeImage(new Uri("https://www.esri.com/content/dam/esrisites/en-us/home/homepage-tile-arcgis-collaboration.jpg"));
45+
Gallery.AvailableBasemaps.Add(item);
46+
47+
BasemapGalleryItem item2 = await BasemapGalleryItem.CreateAsync(new Basemap());
48+
item2.Name = "Without Thumbnail";
49+
Gallery.AvailableBasemaps.Add(item2);
50+
}
51+
52+
private void Button_Remove_Last(object sender, RoutedEventArgs e)
53+
{
54+
if (Gallery.AvailableBasemaps.Any())
55+
{
56+
Gallery.AvailableBasemaps.Remove(Gallery.AvailableBasemaps.Last());
57+
}
58+
}
59+
}
60+
}

0 commit comments

Comments
 (0)