Set the map's reference scale and which feature layers should honor the reference scale.
Use case
Setting a reference scale on a Map
fixes the size of symbols and text to the desired height and width at that scale. As you zoom in and out, symbols and text will increase or decrease in size accordingly. When no reference scale is set, symbol and text sizes remain the same size relative to the MapView
.
Map annotations are typically only relevant at certain scales. For instance, annotations to a map showing a construction site are only relevant at that construction site's scale. So, when the map is zoomed out that information shouldn't scale with the MapView
, but should instead remain scaled with the Map
.
How to use the sample
Use the control at the top to set the map's reference scale (1:500,000 1:250,000 1:100,000 1:50,000). Use the menu checkboxes in the layer menu to set which feature layers should honor the reference scale.
How it works
- Get and set the reference scale property on the
Map
object. - Get and set the scale symbols property on each individual
FeatureLayer
object.
Relevant API
- FeatureLayer
- Map
Additional information
The map reference scale should normally be set by the map's author and not exposed to the end user like it is in this sample.
Tags
map, reference scale, scene
Sample Code
// Copyright 2019 Esri.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
// language governing permissions and limitations under the License.
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.Portal;
using System;
using System.Threading.Tasks;
namespace ArcGIS.WinUI.Samples.MapReferenceScale
{
[ArcGIS.Samples.Shared.Attributes.Sample(
name: "Map reference scale",
category: "Map",
description: "Set the map's reference scale and which feature layers should honor the reference scale.",
instructions: "Use the control at the top to set the map's reference scale (1:500,000 1:250,000 1:100,000 1:50,000). Use the menu checkboxes in the layer menu to set which feature layers should honor the reference scale.",
tags: new[] { "map", "reference scale", "scene" })]
[ArcGIS.Samples.Shared.Attributes.ClassFile("Converters\\DoubleToScaleStringConverter.cs")]
public partial class MapReferenceScale
{
// List of reference scale options.
private readonly double[] _referenceScales =
{
50000,
100000,
250000,
500000
};
public MapReferenceScale()
{
InitializeComponent();
_ = Initialize();
}
private async Task Initialize()
{
// Create a portal and an item; the map will be loaded from portal item.
ArcGISPortal portal = await ArcGISPortal.CreateAsync(new Uri("https://runtime.maps.arcgis.com"));
PortalItem mapItem = await PortalItem.CreateAsync(portal, "3953413f3bd34e53a42bf70f2937a408");
// Create the map from the item.
Map webMap = new Map(mapItem);
// Display the map.
MyMapView.Map = webMap;
// Populate the reference scale choices.
ReferenceScaleBox.ItemsSource = _referenceScales;
// NOTE: this sample uses binding, so explicit control of reference scale isn't seen here.
// See the iOS or Android samples for an implementation that does not rely on data binding.
}
}
}