Skip to content

Commit

Permalink
Merge pull request #2293 from unoplatform/dev/vs/arcgis-docs
Browse files Browse the repository at this point in the history
docs: Updated ArcGisApp docs
  • Loading branch information
agneszitte authored May 30, 2024
2 parents d7caf86 + 0546881 commit 9383e7e
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 38 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/Learn/Maui/Assets/Screenshots/Windows/EsriMaps.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
129 changes: 91 additions & 38 deletions doc/Learn/Maui/ThirdParty-EsriMaps.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,54 +9,96 @@ The MapView control, that's part of the ArcGIS Maps SDK for .NET, can be used in

An existing sample app that showcases the controls is available [here](https://github.com/unoplatform/Uno.Samples/tree/master/UI/MauiEmbedding/ArcGisApp).

> [!NOTE]
> [!NOTE]
> For this sample you don't need to have a license, because it's just a demo and for development purposes.
>
> Esri ArcGIS Maps SDK for .NET is currently only compatible with Windows, Android, iOS, and Mac Catalyst when used with Uno Platform at the moment.
## Installation

In order to use the MapView control, you first need to create an account via the [ArcGIS Developers portal](https://developers.arcgis.com/sign-up/), and depending on the use of location services, you may also need an API key. This walkthrough does not require a license or an API key to run.

## Getting Started

1. Create a new application using the `unoapp` template, enabling .NET MAUI Embedding. In this case, we're going to use the Blank template (`-preset blank`) and include .NET MAUI Embedding support (`-maui`).
### [Visual Studio](#tab/vs)

```
dotnet new unoapp -preset blank -maui -o MauiEmbeddingApp
```
> [!NOTE]
> If you don't have the **Uno Platform Extension for Visual Studio** installed, follow [these instructions](xref:Uno.GetStarted.vs2022).
1. Next, add a reference to the [Esri.ArcGISRuntime.Maui NuGet package](https://www.nuget.org/packages/Esri.ArcGISRuntime.Maui) to the `MauiEmbeddingApp.MauiControls` project.
- Launch **Visual Studio** and click on **Create new project** on the Start Window. Alternatively, if you're already in Visual Studio, click **New, Project** from the **File** menu.

1. In the `AppBuilderExtensions` class, on `MauiEmbeddingApp.MauiControls` project, update the `UseMauiControls` extension method to call the `UseArcGISRuntime` method.
- Type `Uno Platform` in the search box

```cs
using Esri.ArcGISRuntime;
using Esri.ArcGISRuntime.Maui;
using Esri.ArcGISRuntime.Security;
- Click **Uno Platform App**, then **Next**

namespace MauiEmbeddingApp;
- Name the project `ArcGisApp` and click **Create**

public static class AppBuilderExtensions
{
public static MauiAppBuilder UseMauiControls(this MauiAppBuilder builder)
=> builder
.UseArcGISRuntime(
//config => config
// .UseLicense("[Your ArcGIS Maps SDK License key]")
// .UseApiKey("[Your ArcGIS location services API Key]")
// .ConfigureAuthentication(auth => auth
// .UseDefaultChallengeHandler() // Use the default authentication dialog
// )
)
.ConfigureFonts(fonts =>
{
fonts.AddFont("MauiEmbeddingApp/Assets/Fonts/OpenSansRegular.ttf", "OpenSansRegular");
fonts.AddFont("MauiEmbeddingApp/Assets/Fonts/OpenSansSemibold.ttf", "OpenSansSemibold");
});
}
```
At this point you'll enter the **Uno Platform Template Wizard**, giving you options to customize the generated application.

- Select **Blank** in **Presets** selection

- Select the **Platforms** tab and unselect **Desktop** and **Web Assembly** platforms

- Select the **Features** tab and click on **.NET MAUI Embedding**

> [!NOTE]
> If you have a license key and/or a location service API key, uncomment the `delegate` provided on `UseArcGISRuntime` method. This isn't required to run this sample.
- Click **Create** to complete the wizard

The template will create a solution with a single cross-platform project, named `ArcGisApp`, ready to run.

For more information on all the template options, see [Using the Uno Platform Template](xref:Uno.GettingStarted.UsingWizard).

### [Command Line](#tab/cli)

> [!NOTE]
> If you don't have the **Uno Platform dotnet new templates** installed, follow [dotnet new templates for Uno Platform](xref:Uno.GetStarted.dotnet-new).
Create a new application using the `unoapp` template, enabling .NET MAUI Embedding. In this case, we're going to use the Blank template (`-preset blank`) and include .NET MAUI Embedding support (`-maui`).

```bash
dotnet new unoapp -preset blank -maui -platforms "android" -platforms "ios" -platforms "maccatalyst" -platforms "windows" -o ArcGisApp
```

This will create a new folder called **ArcGisApp** containing the new application.

---

## Nuget Packages

Add a reference to the [Esri.ArcGISRuntime.Maui NuGet package](https://www.nuget.org/packages/Esri.ArcGISRuntime.Maui) to the `ArcGisApp.MauiControls` project.

## Updating AppBuilderExtensions

In the `AppBuilderExtensions` class, on `ArcGisApp.MauiControls` project, update the `UseMauiControls` extension method to call the `UseArcGISRuntime` method.

```cs
using Esri.ArcGISRuntime;
using Esri.ArcGISRuntime.Maui;
using Esri.ArcGISRuntime.Security;

namespace ArcGisApp;

public static class AppBuilderExtensions
{
public static MauiAppBuilder UseMauiControls(this MauiAppBuilder builder)
=> builder
.UseArcGISRuntime(
//config => config
// .UseLicense("[Your ArcGIS Maps SDK License key]")
// .UseApiKey("[Your ArcGIS location services API Key]")
// .ConfigureAuthentication(auth => auth
// .UseDefaultChallengeHandler() // Use the default authentication dialog
// )
)
.ConfigureFonts(fonts =>
{
fonts.AddFont("Assets/Fonts/OpenSansRegular.ttf", "OpenSansRegular");
fonts.AddFont("Assets/Fonts/OpenSansSemibold.ttf", "OpenSansSemibold");
});
}
```

> [!NOTE]
> If you have a license key and/or a location service API key, uncomment the `delegate` provided on `UseArcGISRuntime` method. This isn't required to run this sample.
## Adding MapView

Expand All @@ -68,7 +110,7 @@ In order to use the MapView control, you first need to create an account via the
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"
x:Class="MauiEmbeddingApp.MauiControls.EmbeddedControl">
x:Class="ArcGisApp.MauiControls.EmbeddedControl">
<Grid>
<esriUI:MapView x:Name="mapView"
HeightRequest="300"
Expand All @@ -84,7 +126,7 @@ In order to use the MapView control, you first need to create an account via the
using Esri.ArcGISRuntime.Mapping;
using Map = Esri.ArcGISRuntime.Mapping.Map;

namespace MauiEmbeddingApp.MauiControls;
namespace ArcGisApp.MauiControls;

public partial class EmbeddedControl : ContentView
{
Expand All @@ -105,11 +147,22 @@ In order to use the MapView control, you first need to create an account via the
```

1. Now the project is good to go! Press F5 and should see the MapView control running on your application.
For more detailed instructions specific to each platform, refer to the [Debug the App](xref:Uno.GettingStarted.CreateAnApp.VS2022#debug-the-app) documentation.

**App Render Output**
## App Render Output

- **Android:**
- ![Android EsriMaps](Assets/Screenshots/Android/EsriMaps.png)

![Android EsriMaps](Assets/Screenshots/Android/EsriMaps.png)

- **iOS:**

![iOS EsriMaps](Assets/Screenshots/iOS/EsriMaps.png)

- **Mac Catalyst:**

![Mac Catalyst EsriMaps](Assets/Screenshots/MacCatalyst/EsriMaps.png)

- **Windows:**
- ![Windows EsriMaps](Assets/Screenshots/Windows/EsriMaps.png)

![Windows EsriMaps](Assets/Screenshots/Windows/EsriMaps.png)

0 comments on commit 9383e7e

Please sign in to comment.