Skip to content

Commit 93c8e1c

Browse files
authored
[WinUI] Display Overview Map (#1730)
1 parent 8a544f2 commit 93c8e1c

File tree

6 files changed

+158
-0
lines changed

6 files changed

+158
-0
lines changed
157 KB
Loading
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<UserControl
2+
x:Class="ArcGIS.WinUI.Samples.DisplayOverviewMap.DisplayOverviewMap"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:esri="using:Esri.ArcGISRuntime"
6+
xmlns:esriUI="using:Esri.ArcGISRuntime.UI.Controls"
7+
xmlns:toolkit="using:Esri.ArcGISRuntime.Toolkit.UI.Controls">
8+
<Grid>
9+
<esriUI:MapView x:Name="MyMapView" />
10+
<toolkit:OverviewMap Width="220"
11+
Height="220"
12+
Margin="5"
13+
HorizontalAlignment="Left"
14+
VerticalAlignment="Top"
15+
GeoView="{x:Bind MyMapView}"
16+
ScaleFactor="10" />
17+
</Grid>
18+
</UserControl>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// Copyright 2026 Esri.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
4+
// You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
5+
//
6+
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
7+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
8+
// language governing permissions and limitations under the License.
9+
10+
using Esri.ArcGISRuntime.Data;
11+
using Esri.ArcGISRuntime.Geometry;
12+
using Esri.ArcGISRuntime.Mapping;
13+
using Esri.ArcGISRuntime.Symbology;
14+
using Esri.ArcGISRuntime.Tasks;
15+
using Esri.ArcGISRuntime.Tasks.Offline;
16+
using Esri.ArcGISRuntime.UI;
17+
using Esri.ArcGISRuntime.ArcGISServices;
18+
using Esri.ArcGISRuntime.UI.Controls;
19+
using System;
20+
using System.Linq;
21+
using System.Threading.Tasks;
22+
using Microsoft.UI.Xaml;
23+
using Microsoft.UI.Xaml.Input;
24+
25+
namespace ArcGIS.WinUI.Samples.DisplayOverviewMap
26+
{
27+
[ArcGIS.Samples.Shared.Attributes.Sample(
28+
name: "Display overview map",
29+
category: "Map",
30+
description: "Include an overview or inset map as an additional map view to show the wider context of the primary view.",
31+
instructions: "Pan or zoom across the map view to browse through the tourist attractions feature layer and notice the viewpoint and scale of the linked overview map update automatically. When running the sample on a desktop, you can also navigate by panning and zooming on the overview map. However, interactivity of the overview map is disabled on mobile devices.",
32+
tags: new[] { "context", "inset", "map", "minimap", "overview", "preview", "small scale", "toolkit", "view" })]
33+
[ArcGIS.Samples.Shared.Attributes.OfflineData()]
34+
public partial class DisplayOverviewMap
35+
{
36+
// URL to the feature service.
37+
private const string FeatureServiceUrl = "https://services6.arcgis.com/Do88DoK2xjTUCXd1/arcgis/rest/services/OSM_Tourism_NA/FeatureServer/0";
38+
39+
// Hold a reference to the feature table.
40+
private ServiceFeatureTable _featureTable;
41+
42+
43+
public DisplayOverviewMap()
44+
{
45+
InitializeComponent();
46+
_ = Initialize();
47+
}
48+
49+
private async Task Initialize()
50+
{
51+
// Create new Map with basemap.
52+
MyMapView.Map = new Map(BasemapStyle.ArcGISTopographic);
53+
54+
// Set the initial map location.
55+
MyMapView.SetViewpoint(new Viewpoint(49.28299, -123.12052, 70000));
56+
57+
// Create the feature table, referring to the feature service.
58+
_featureTable = new ServiceFeatureTable(new Uri(FeatureServiceUrl));
59+
60+
// Create a feature layer to visualize the features in the table.
61+
FeatureLayer featureLayer = new FeatureLayer(_featureTable);
62+
63+
// Add the layer to the map.
64+
MyMapView.Map.OperationalLayers.Add(featureLayer);
65+
66+
}
67+
}
68+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Display overview map
2+
3+
Include an overview or inset map as an additional map view to show the wider context of the primary view.
4+
5+
![Image of display overview map](DisplayOverviewMap.jpg)
6+
7+
## Use case
8+
9+
An overview map provides a useful, smaller-scale overview of the current map view's location. For example, when you need to inspect a layer with many features while remaining aware of the wider context of the view, use an overview map to help show the extent of the main map view.
10+
11+
## How to use the sample
12+
13+
Pan or zoom across the map view to browse through the tourist attractions feature layer and notice the viewpoint and scale of the linked overview map update automatically. When running the sample on a desktop, you can also navigate by panning and zooming on the overview map. However, interactivity of the overview map is disabled on mobile devices.
14+
15+
## How it works
16+
17+
1. Create a `Map` with the `ArcGISTopographic` basemap style and add it to the `MapView`.
18+
2. Instantiate a `FeatureLayer` from a `ServiceFeatureTable` and append it to the `Map`'s operational layers.
19+
3. In the user-interface, declare an `OverviewMap` object from the ArcGIS Maps SDK for .NET Toolkit.
20+
4. Assign the `MapView` to the `MyOverviewMap.GeoView` property of the `OverviewMap` to connect the `MapView` with the `OverviewMap`.
21+
5. Set the scale factor of the `OverviewMap` with the `MyOverviewMap.ScaleFactor`.
22+
23+
## Relevant API
24+
25+
* MapView
26+
* OverviewMap
27+
28+
## About the data
29+
30+
The data used in this sample is the [OpenStreetMap Tourist Attractions for North America](https://www.arcgis.com/home/item.html?id=addaa517dde346d1898c614fa91fd032) feature layer, which is scale-dependent and displays at scales larger than 1:160,000.
31+
32+
## Additional information
33+
34+
This sample uses the overview map toolkit component which can be accessed using the Esri.ArcGISRuntime.Toolkit nuget package. The [toolkit](https://github.com/Esri/arcgis-toolkit-dotnet) can also be cloned and set up locally. For information about setting up the toolkit, visit the [repository](https://github.com/Esri/arcgis-toolkit-dotnet/blob/main/README.md).
35+
36+
## Tags
37+
38+
context, inset, map, minimap, overview, preview, small scale, toolkit, view
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"category": "Map",
3+
"description": "Include an overview or inset map as an additional map view to show the wider context of the primary view.",
4+
"formal_name": "DisplayOverviewMap",
5+
"ignore": false,
6+
"images": [
7+
"DisplayOverviewMap.jpg"
8+
],
9+
"keywords": [
10+
"context",
11+
"inset",
12+
"map",
13+
"minimap",
14+
"overview",
15+
"preview",
16+
"small scale",
17+
"toolkit",
18+
"view"
19+
],
20+
"offline_data": [],
21+
"redirect_from": [
22+
"/net/latest/maui/sample-code/display-overview-map.htm"
23+
],
24+
"relevant_apis": [
25+
"MapView",
26+
"OverviewMap"
27+
],
28+
"snippets": [
29+
"DisplayOverviewMap.xaml.cs",
30+
"DisplayOverviewMap.xaml"
31+
],
32+
"title": "Display overview map"
33+
}

src/WinUI/readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@
165165
* [Create and save map](ArcGIS.WinUI.Viewer/Samples/Map/AuthorMap) - Create and save a map as an ArcGIS `PortalItem` (i.e. web map).
166166
* [Create dynamic basemap gallery](ArcGIS.WinUI.Viewer/Samples/Map/CreateDynamicBasemapGallery) - Implement a basemap gallery that automatically retrieves the latest customization options from the basemap styles service.
167167
* [Display map](ArcGIS.WinUI.Viewer/Samples/Map/DisplayMap) - Display a map with an imagery basemap.
168+
* [Display overview map](ArcGIS.WinUI.Viewer/Samples/Map/DisplayOverviewMap) - Include an overview or inset map as an additional map view to show the wider context of the primary view.
168169
* [Download preplanned map area](ArcGIS.WinUI.Viewer/Samples/Map/DownloadPreplannedMap) - Take a map offline using a preplanned map area.
169170
* [Generate offline map](ArcGIS.WinUI.Viewer/Samples/Map/GenerateOfflineMap) - Take a web map offline.
170171
* [Generate offline map (overrides)](ArcGIS.WinUI.Viewer/Samples/Map/GenerateOfflineMapWithOverrides) - Take a web map offline with additional options for each layer.

0 commit comments

Comments
 (0)