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

Bring in .NET MAUI sample fixes into main #1343

Merged
merged 5 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Maui;assembly=Esri.ArcGISRuntime.Maui">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<esriUI:SceneView x:Name="MySceneView" Grid.Row="0" />
<esriUI:SceneView x:Name="MySceneView" />
<Button x:Name="UpdateObserverButton"
Grid.Row="1"
Margin="10"
Clicked="UpdateObserverWithCamera"
Text="Viewshed from Here" />
HorizontalOptions="End"
Text="Viewshed from Here"
VerticalOptions="Start" />
</Grid>
</ContentPage>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -5,59 +5,31 @@
xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Maui;assembly=Esri.ArcGISRuntime.Maui">
<Grid Style="{DynamicResource EsriSampleContainer}">
<esriUI:MapView x:Name="MyMapView" Style="{DynamicResource EsriSampleGeoView}" />
<Border Style="{DynamicResource EsriSampleControlPanel}">
<Grid Padding="5">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<ScrollView x:Name="MetadataScrollView"
Grid.Row="1"
IsVisible="false"
MaximumHeightRequest="400">
<Grid x:Name="InfoGrid">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Label Grid.Row="0"
Margin="5"
FontAttributes="Bold"
FontSize="Small"
Text="{Binding Path=Credits}" />
<Label Grid.Row="1"
FontSize="Micro"
LineBreakMode="WordWrap"
Text="{Binding Summary}" />
<Image x:Name="ShapefileThumbnailImage"
Grid.Row="2"
Margin="10" />
<Grid Grid.Row="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Grid.Column="0"
Margin="0,3"
FontAttributes="Bold"
FontSize="Micro"
Text="Tags:" />
<ListView Grid.Column="1"
HeightRequest="120"
ItemsSource="{Binding Tags}"
RowHeight="25"
WidthRequest="160" />
</Grid>
</Grid>
</ScrollView>
<Button Grid.Row="0"
Clicked="ShowMetadataClicked"
HeightRequest="40"
HorizontalOptions="FillAndExpand"
Text="Show/Hide Metadata" />
</Grid>
<Border x:Name="ControlPanel" Style="{DynamicResource EsriSampleControlPanel}">
<ScrollView MaximumHeightRequest="{OnIdiom Desktop=500, Default={Binding Height, Source=ControlPanel}}" Orientation="{OnPlatform iOS=Both, Default=Vertical}">
<StackLayout x:Name="InfoList" Spacing="5">
<Label FontAttributes="Bold"
FontSize="Large"
HorizontalOptions="Start"
LineBreakMode="WordWrap"
MaximumWidthRequest="400"
Text="{Binding Path=Credits}" />
<Label HorizontalOptions="Start"
LineBreakMode="WordWrap"
MaximumWidthRequest="400"
Text="{Binding Summary}" />
<Image x:Name="ShapefileThumbnailImage" HorizontalOptions="Start" />
<Label FontAttributes="Bold"
FontSize="Medium"
HorizontalOptions="Start"
Text="Tags:" />
<ListView HorizontalOptions="Start"
ItemsSource="{Binding Tags}"
MaximumWidthRequest="400"
RowHeight="25"
VerticalScrollBarVisibility="Never" />
</StackLayout>
</ScrollView>
</Border>
</Grid>
</ContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -26,59 +26,59 @@ public ReadShapefileMetadata()
{
InitializeComponent();

// Open a shapefile stored locally and add it to the map as a feature layer
// Open a shapefile stored locally and add it to the map as a feature layer.
_ = Initialize();
}

private async Task Initialize()
{
// Create a new map to display in the map view with a streets basemap
Map streetMap = new Map(BasemapStyle.ArcGISStreets);
// Create a new map to display in the map view with a streets basemap.
var streetMap = new Map(BasemapStyle.ArcGISStreets);

// Get the path to the downloaded shapefile
// Get the path to the downloaded shapefile.
string filepath = GetShapefilePath();

try
{
// Open the shapefile
// Open the shapefile.
ShapefileFeatureTable myShapefile = await ShapefileFeatureTable.OpenAsync(filepath);

// Read metadata about the shapefile and display it in the UI
// Read metadata about the shapefile and display it in the UI.
ShapefileInfo fileInfo = myShapefile.Info;
InfoGrid.BindingContext = fileInfo;
InfoList.BindingContext = fileInfo;

// Read the thumbnail image data into a byte array
// Read the thumbnail image data into a byte array.
Stream imageStream = await fileInfo.Thumbnail.GetEncodedBufferAsync();
byte[] imageData = new byte[imageStream.Length];
imageStream.Read(imageData, 0, imageData.Length);

// Create a new image source from the thumbnail data
// Create a new image source from the thumbnail data.
ImageSource streamImageSource = ImageSource.FromStream(() => new MemoryStream(imageData));

// Create a new image to display the thumbnail
Image image = new Image()
// Create a new image to display the thumbnail.
var image = new Image()
{
Source = streamImageSource,
Margin = new Thickness(10)
};

// Show the thumbnail image in a UI control
// Show the thumbnail image in a UI control.
ShapefileThumbnailImage.Source = image.Source;

// Create a feature layer to display the shapefile
FeatureLayer newFeatureLayer = new FeatureLayer(myShapefile);
// Create a feature layer to display the shapefile.
var newFeatureLayer = new FeatureLayer(myShapefile);
await newFeatureLayer.LoadAsync();

// Zoom the map to the extent of the shapefile
// Zoom the map to the extent of the shapefile.
MyMapView.SpatialReferenceChanged += async (s, e) =>
{
await MyMapView.SetViewpointGeometryAsync(newFeatureLayer.FullExtent);
};

// Add the feature layer to the map
// Add the feature layer to the map.
streetMap.OperationalLayers.Add(newFeatureLayer);

// Show the map in the MapView
// Show the map in the MapView.
MyMapView.Map = streetMap;
}
catch (Exception e)
Expand All @@ -87,12 +87,6 @@ private async Task Initialize()
}
}

private void ShowMetadataClicked(object sender, System.EventArgs e)
{
// Toggle the visibility of the metadata panel
MetadataScrollView.IsVisible = !MetadataScrollView.IsVisible;
}

private static string GetShapefilePath()
{
return DataManager.GetDataFolder("d98b3e5293834c5f852f13c569930caa", "TrailBikeNetwork.shp");
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Maui;assembly=Esri.ArcGISRuntime.Maui">
<Grid Style="{DynamicResource EsriSampleContainer}">
<esriUI:MapView x:Name="MyMapView" Style="{DynamicResource EsriSampleGeoView}" />
<Border Style="{DynamicResource EsriSampleControlPanel}">
<Grid>
<Button x:Name="MyRendererButton"
Clicked="Button_Clicked"
IsEnabled="False"
Text="Change Renderer" />
</Grid>
</Border>
<Grid>
<esriUI:MapView x:Name="MyMapView" />
<Button x:Name="MyRendererButton"
Margin="10"
Clicked="Button_Clicked"
HorizontalOptions="End"
IsEnabled="False"
Text="Change Renderer"
VerticalOptions="Start" />
</Grid>
</ContentPage>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Maui;assembly=Esri.ArcGISRuntime.Maui">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<esriUI:MapView x:Name="MyMapView" />
<Button x:Name="ClipButton"
Grid.Row="0"
Margin="10"
Clicked="ClipButton_Clicked"
Text="Clip" />
<esriUI:MapView x:Name="MyMapView" Grid.Row="1" />
HorizontalOptions="End"
Text="Clip"
VerticalOptions="Start" />
</Grid>
</ContentPage>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Maui;assembly=Esri.ArcGISRuntime.Maui">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<esriUI:MapView x:Name="MyMapView" />
<Button x:Name="CutButton"
Grid.Row="0"
Margin="10"
Clicked="CutButton_Clicked"
Text="Cut" />
<esriUI:MapView x:Name="MyMapView" Grid.Row="1" />
HorizontalOptions="End"
Text="Cut"
VerticalOptions="Start" />
</Grid>
</ContentPage>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,60 @@
<esriUI:SceneView x:Name="MySceneView"
AtmosphereEffect="Realistic"
Style="{DynamicResource EsriSampleGeoView}" />
<Border Style="{DynamicResource EsriSampleControlPanel}" WidthRequest="{OnPlatform MacCatalyst=375, WinUI=375}">
<StackLayout>
<StackLayout Orientation="Horizontal" Spacing="5">
<Picker x:Name="MissionSelectionBox"
HorizontalTextAlignment="Center"
WidthRequest="150" />
<Button x:Name="MissionPlayPause"
Clicked="MissionPlayPlauseClick"
Text="Pause"
WidthRequest="75" />
<Button x:Name="CameraControlButton"
Clicked="ToggleFollowPlane"
Text="Don't Follow"
WidthRequest="110" />
</StackLayout>
<Label Text="Mission Progress:" />
<Slider x:Name="MissionProgressBar"
Maximum="100"
ValueChanged="MissionProgressOnSeek"
WidthRequest="350" />
<Grid ColumnDefinitions="100,*">
<StackLayout Orientation="Vertical">
<Label>Altitude:</Label>
<Label x:Name="AltitudeLabel" />
<Label>Heading:</Label>
<Label x:Name="HeadingLabel" />
<Label>Pitch:</Label>
<Label x:Name="PitchLabel" />
<Label>Roll:</Label>
<Label x:Name="RollLabel" />
</StackLayout>
<Border Style="{DynamicResource EsriSampleControlPanel}">
<ScrollView>
<StackLayout Spacing="5">
<Label FontAttributes="Bold" Text="Select a mission:" />
<Picker x:Name="MissionSelectionBox" />
<Label FontAttributes="Bold" Text="Mission progress:" />
<Slider x:Name="MissionProgressBar"
Maximum="100"
ValueChanged="MissionProgressBar_ValueChanged" />
<Label FontAttributes="Bold" Text="Play mission:" />
<Switch x:Name="PlaySwitch"
HorizontalOptions="Start"
Toggled="PlaySwitch_Toggled" />
<Label FontAttributes="Bold" Text="Follow plane:" />
<Switch x:Name="FollowSwitch"
HorizontalOptions="Start"
Toggled="FollowSwitch_Toggled" />
<Label>
<Label.FormattedText>
<FormattedString>
<Span FontAttributes="Bold" Text="Altitude: " />
<Span x:Name="AltitudeLabel" />
</FormattedString>
</Label.FormattedText>
</Label>
<Label>
<Label.FormattedText>
<FormattedString>
<Span FontAttributes="Bold" Text="Heading: " />
<Span x:Name="HeadingLabel" />
</FormattedString>
</Label.FormattedText>
</Label>
<Label>
<Label.FormattedText>
<FormattedString>
<Span FontAttributes="Bold" Text="Pitch: " />
<Span x:Name="PitchLabel" />
</FormattedString>
</Label.FormattedText>
</Label>
<Label>
<Label.FormattedText>
<FormattedString>
<Span FontAttributes="Bold" Text="Roll: " />
<Span x:Name="RollLabel" />
</FormattedString>
</Label.FormattedText>
</Label>
<esriUI:MapView x:Name="InsetMapView"
Grid.Column="1"
HeightRequest="150"
HorizontalOptions="End"
IsAttributionTextVisible="False"
VerticalOptions="Start"
WidthRequest="150" />
</Grid>
</StackLayout>
HeightRequest="200"
IsAttributionTextVisible="False" />
</StackLayout>
</ScrollView>
</Border>
</Grid>
</ContentPage>
Loading
Loading