Skip to content

Conversation

@prathameshnarkhede
Copy link
Contributor

@prathameshnarkhede prathameshnarkhede commented Feb 27, 2025

  • Added support for 3D Basemaps in Basemap Gallery for SceneView.
  • There is a 3D tag in UI to identify 3D basemaps available.
  • Added caching to store Basemaps to make switching GeoModel type easier.
WPF WinUI/UWP MAUI
image image image
image image image

@prathameshnarkhede prathameshnarkhede self-assigned this Feb 27, 2025
@prathameshnarkhede prathameshnarkhede marked this pull request as ready for review February 27, 2025 22:36
@prathameshnarkhede prathameshnarkhede changed the base branch from main to v.next February 27, 2025 22:39
<toolkit:BasemapGallery
x:Name="Gallery"
Width="{x:Bind WidthSlider.Value}"
Width="{x:Bind WidthSlider.Value, Mode=OneWay}"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added Mode to One way to fix Width slider in WinUI and UWP.

Comment on lines +51 to +78
Grid thumbnailGrid = new Grid() { WidthRequest = 64, HeightRequest = 64 };
Image thumbnail = new Image { Aspect = Aspect.AspectFill, BackgroundColor = Colors.Transparent, HorizontalOptions = LayoutOptions.Center };
Border itemTypeBorder = new Border
{
StrokeShape = new RoundRectangle { CornerRadius = new CornerRadius(7) },
Padding = new Thickness(4, 0),
Margin = new Thickness(2),
HorizontalOptions = LayoutOptions.End,
VerticalOptions = LayoutOptions.Start,
};
itemTypeBorder.SetAppThemeColor(BackgroundColorProperty, Colors.LightGray, Colors.DarkGray);
Grid.SetRow(itemTypeBorder, 1);

Label itemTypeLabel = new Label
{
Text = "3D",
Margin = new Thickness(1),
HorizontalTextAlignment = TextAlignment.Center,
FontSize = 9,
FontAttributes = FontAttributes.Bold
};
itemTypeLabel.SetAppThemeColor(Label.TextColorProperty, Colors.Black, Colors.White);
itemTypeBorder.Content = itemTypeLabel;
itemTypeBorder.SetBinding(Border.IsVisibleProperty, static (BasemapGalleryItem item) => item.Is3D, BindingMode.OneWay);

thumbnailGrid.Children.Add(thumbnail);
thumbnailGrid.Children.Add(itemTypeBorder);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we added the Type of the Basemap (3D) identifier as seen in screenshot and unified thumbnail in a Grid

Comment on lines +101 to +113
{
// Special template to take advantage of negative margin support on iOS, Mac

Border border = new Border
{
Padding = new Thickness(0),
#if __IOS__
StrokeThickness = 8,
#else
StrokeThickness = 1,
#endif
StrokeShape = new Rectangle(),
};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, we just moved the code at bottom and maintained same structure as Grid View of BasemapGallery

Comment on lines +284 to +309
private async Task<ObservableCollection<BasemapGalleryItem>> LoadBasemapGalleryItems(ArcGISPortal portal, CancellationToken cancellationToken = default)
{
ArcGISPortal defaultPortal = await ArcGISPortal.CreateAsync(cancellationToken);

var results = await defaultPortal.GetDeveloperBasemapsAsync(cancellationToken);

var listOfBasemaps = new List<BasemapGalleryItem>();

foreach (var basemap in results)
async Task<List<BasemapGalleryItem>> LoadBasemapsAsync(Func<CancellationToken, Task<IEnumerable<Basemap>>> getBasemapsFunc)
{
listOfBasemaps.Add(new BasemapGalleryItem(basemap));
var basemaps = await getBasemapsFunc(cancellationToken);
var basemapItems = basemaps.Select(basemap => new BasemapGalleryItem(basemap)).ToList();
foreach (var item in basemapItems)
{
_ = item.LoadAsync();
}
return basemapItems;
}
var basemapGalleryItems = new List<BasemapGalleryItem>();

foreach (var item in listOfBasemaps)
if (portal.PortalInfo?.Use3DBasemaps is true && GeoModel is Scene)
{
_ = item.LoadAsync();
_cached3DBasemaps ??= await LoadBasemapsAsync(portal.Get3DBasemapsAsync);
basemapGalleryItems.AddRange(_cached3DBasemaps);
}
return new ObservableCollection<BasemapGalleryItem>(listOfBasemaps);

_cached2DBasemaps ??= await LoadBasemapsAsync(portal.PortalInfo?.UseVectorBasemaps ?? false
? portal.GetVectorBasemapsAsync
: portal.GetBasemapsAsync);
basemapGalleryItems.AddRange(_cached2DBasemaps);

return new ObservableCollection<BasemapGalleryItem>(basemapGalleryItems);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the effort to reduce redundant code and unify Loading of Basemaps based on type of GeoModel, caching and support to 3D basemaps

Comment on lines -234 to -249
public async Task LoadFromDefaultPortal()
{
IsLoading = true;
_loadCancellationTokenSource = new CancellationTokenSource();
try
{
AvailableBasemaps = await PopulateFromDefaultList(_loadCancellationTokenSource.Token);
}
catch (OperationCanceledException)
{ }
finally
{
IsLoading = false;
}
}

Copy link
Contributor Author

@prathameshnarkhede prathameshnarkhede Mar 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code has been moved close to its invocation and implementation here.

Comment on lines +451 to +455
/// <summary>
/// Gets a value indicating whether this basemap is a 3D basemap.
/// </summary>
public bool Is3D => this.Basemap?.BaseLayers?.OfType<ArcGISSceneLayer>()?.Any() ?? false;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This property is used to bind the visibility of 3D tag on basemap.

Copy link
Contributor

@jnery jnery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks 👍 Great job, big PR 👏

@prathameshnarkhede prathameshnarkhede merged commit 75c9bbe into v.next Mar 19, 2025
@prathameshnarkhede prathameshnarkhede deleted the pratham/3d-basemapgallery branch March 19, 2025 18:40
dotMorten added a commit that referenced this pull request Apr 8, 2025
* Set version to 200.7

Compile WinUI with AoT support

* Order sample collection

* Add AoT support to Basemap Gallery

* Add x:Bind expressions to sample pages

* Add xaml generation to winui

* project settings cleanup

* Avoid use of implicit datacontext bindings

Use relative source or code-behind whenever possible

* Rewrites several parts of the SearchView to make it AoT compatible in WinUI (#620)

* Rewrites several parts of the SearchView to make it AoT compatible in WinUI

* Merge main to v.next (#623)

* Update BookmarksView template to use StackLayout and Labels to adapt new CollectionView. (#621)

* Add XML namespace and data binding in SymbolEditorSample to resolve bug with Angle property not being refresh in MAUI Android. (#622)

* Fix maui version

* Remove unused dependency

* Update WinUI AoT table

* Fix preview in compatibility table

* Add built-in barcode scanning (#615)

* Add support for built-in iOS barcode scanner
* Add Windows support to barcode scanner

* Adding barcode scanner to Android (#624)

* Adding barcode scanner to Android

* Improve windows scanning performance by just using default scanner

Improves scanner launch time from ~40s to 1-2s due to a poor/ineffecient device selector string.

* Update ios/catalyst target to 18.0 to match default ios tfm

* Fix warnings in Android introduced by transitive packages by locking in the dependent version minimums

* Fix indents

* 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

* Disable aot

Several controls are still not AoT compatible

* Enhance basemap loading with async task management caching (#631)

* Enhance basemap loading with async task management caching

- Introduces Task caching mechanism to manage asynchronous loading of basemap gallery items.
- Updates `LoadBasemapGalleryItems` to check for ongoing tasks, preventing multiple concurrent loads.

* Refactor basemap loading and portal change handling

* Refactor basemap handling on portal changes.
Restored `HandlePortalChanged` to manage portal changed event including cache invalidation and asynchronous basemap updates.
Added invalidating of cache on `AvailableBasemaps` assigned manually.

* Skip rendering unknown feature form element types

* Skip rendering unknown popup element types

* Mac Catalyst min version is 15

* Fix expired app certificate

---------

Co-authored-by: Prathamesh Narkhede <[email protected]>
Co-authored-by: Prathamesh Narkhede <[email protected]>
Co-authored-by: Morten Nielsen <[email protected]>
prathameshnarkhede added a commit that referenced this pull request May 1, 2025
… 9 (#630)

* Set version to 200.7

Compile WinUI with AoT support

* Order sample collection

* Add AoT support to Basemap Gallery

* Add x:Bind expressions to sample pages

* Add xaml generation to winui

* project settings cleanup

* Avoid use of implicit datacontext bindings

Use relative source or code-behind whenever possible

* Rewrites several parts of the SearchView to make it AoT compatible in WinUI (#620)

* Rewrites several parts of the SearchView to make it AoT compatible in WinUI

* Merge main to v.next (#623)

* Update BookmarksView template to use StackLayout and Labels to adapt new CollectionView. (#621)

* Add XML namespace and data binding in SymbolEditorSample to resolve bug with Angle property not being refresh in MAUI Android. (#622)

* Fix maui version

* Remove unused dependency

* Update WinUI AoT table

* Fix preview in compatibility table

* Add built-in barcode scanning (#615)

* Add support for built-in iOS barcode scanner
* Add Windows support to barcode scanner

* Adding barcode scanner to Android (#624)

* Adding barcode scanner to Android

* Improve windows scanning performance by just using default scanner

Improves scanner launch time from ~40s to 1-2s due to a poor/ineffecient device selector string.

* Update ios/catalyst target to 18.0 to match default ios tfm

* Fix warnings in Android introduced by transitive packages by locking in the dependent version minimums

* Fix indents

* 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

* Updated MAUI bindings to use new Compiled Bindings introduced in .Net 9

* Correcting data bindings and tested the code.
Removed CodeAnalysis Dynamic Dependencies

* Remove unused directives and dependencies in FloorFilter

* Remove DynamicDependency attributes and update to correct bindings

* Corrected bindings for FormAttachment

* Corrected Attachment binding for AttachmentsFormElementView

* Fix tooltip binding in AttachmentsFormElementView

* Refactor binding expressions for type safety

* Refactor popup element bindings for clarity

* Refactor element parameter types in bindings to its base type

* Update Picker IsEnabled binding in ComboBoxFormInputView to point source to TemplatedParent

* Remove AOT compilation from project configuration

---------

Co-authored-by: dotMorten <[email protected]>
Co-authored-by: Morten Nielsen <[email protected]>
Co-authored-by: dotMorten <[email protected]>
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

Successfully merging this pull request may close these issues.

5 participants