View on GitHub Sample viewer app

Scale feature labels and symbols according to the system text-size setting.

Use case

Use this pattern to improve map readability for users who increase text size in their operating system’s accessibility settings. Enable MapView.useSystemTextScale to scale feature labels automatically.

How to use the sample

Change the text size in the operating system’s accessibility settings to see the restaurant labels and symbols resize. On iOS, open Settings > Accessibility > Display & Text Size > Larger Text. On Linux (GNOME), open Settings > Accessibility > Seeing > Large Text.

Clear Apply system text size to labels to stop labels from following the system text size, then select it again to restore system text scaling. Restaurant symbols continue to follow the system text size independently of this setting. The legend and current values show how labels and symbols are scaled.

Select a restaurant to show its name and WGS 84 coordinates in a callout. Select elsewhere to clear the callout.

How it works

  1. Create a Map and add a FeatureLayer.
  2. Load the restaurant symbol from Esri2DPointSymbolsStyle and apply it with a SimpleRenderer.
  3. Load the feature layer, then add a LabelDefinition with a TextSymbol.
  4. To scale labels, enable MapView.useSystemTextScale.
  5. To scale symbols, read SystemTextScaleMonitor::textScale() and connect to its textScaleChanged signal. This sample helper monitors the platform’s system text-size setting. Set MultilayerPointSymbol::setSize() to the base symbol size multiplied by the system text-scale factor.
  6. Use the checkbox to toggle system text scaling for labels without changing symbol scaling.
  7. Identify a restaurant with GeoView::identifyLayerAsync and show its name and WGS 84 coordinates in a callout.

Relevant API

  • GeoView.useSystemTextScale

About the data

This sample uses a Redlands restaurants feature layer covering food establishments in Redlands, California. Each feature represents a single restaurant.

The restaurant symbol comes from Esri’s 2D point symbol web style.

Additional information

GeoView.useSystemTextScale is supported on iOS, Android, Windows, and Linux (GNOME desktop environments only). It is not supported on macOS.

Tags

accessibility, label, readability, scale, symbol, text, visual impairment

Sample code

UpdateLabelsAndSymbolsToScaleForVisualAccessibility.cppUpdateLabelsAndSymbolsToScaleForVisualAccessibility.cppUpdateLabelsAndSymbolsToScaleForVisualAccessibility.hUpdateLabelsAndSymbolsToScaleForVisualAccessibility.qml
// [WriteFile Name=UpdateLabelsAndSymbolsToScaleForVisualAccessibility, Category=Accessibility]
// [Legal]
// Copyright 2026 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.
// [Legal]
#ifdef PCH_BUILD
#include "pch.hpp"
#endif // PCH_BUILD
// sample headers
#include "UpdateLabelsAndSymbolsToScaleForVisualAccessibility.h"
// ArcGIS Maps SDK headers
#include "AttributeListModel.h"
#include "CalloutData.h"
#include "Error.h"
#include "Feature.h"
#include "FeatureLayer.h"
#include "GeometryEngine.h"
#include "IdentifyLayerResult.h"
#include "LabelDefinition.h"
#include "LabelDefinitionListModel.h"
#include "LabelingTypes.h"
#include "LayerListModel.h"
#include "Map.h"
#include "MapQuickView.h"
#include "MapTypes.h"
#include "MultilayerPointSymbol.h"
#include "Point.h"
#include "ServiceFeatureTable.h"
#include "SimpleLabelExpression.h"
#include "SimpleRenderer.h"
#include "SpatialReference.h"
#include "SymbolStyle.h"
#include "TextSymbol.h"
#include "Viewpoint.h"
// qt_common headers
#include "SystemTextScaleMonitor/SystemTextScaleMonitor.h"
// Qt headers
#include <QBuffer>
#include <QFuture>
#include <QImage>
#include <QMouseEvent>
using namespace Esri::ArcGISRuntime;
UpdateLabelsAndSymbolsToScaleForVisualAccessibility::UpdateLabelsAndSymbolsToScaleForVisualAccessibility(QObject* parent /* = nullptr */) :
QObject(parent),
m_map(new Map(BasemapStyle::ArcGISLightGray, this))
{
m_systemTextScaleMonitor = AccessibilitySample::SystemTextScaleMonitor::sharedInstance();
connect(m_systemTextScaleMonitor.get(), &AccessibilitySample::SystemTextScaleMonitor::textScaleChanged, this, [this](float)
{
updateSymbolSize();
});
updateSymbolSize();
m_map->setInitialViewpoint(Viewpoint(Point(-117.1793, 34.0556, SpatialReference::wgs84()), 2500));
// Create a feature layer of restaurants in Redlands and add it to the map
ServiceFeatureTable* restaurantsTable =
new ServiceFeatureTable(QUrl("https://services2.arcgis.com/ZQgQTuoyBrtmoGdP/arcgis/rest/services/redlands_food/FeatureServer/0"), this);
m_restaurantsLayer = new FeatureLayer(restaurantsTable, this);
m_map->operationalLayers()->append(m_restaurantsLayer);
// Once the feature layer has loaded, label the restaurants with their names
connect(m_restaurantsLayer, &FeatureLayer::doneLoading, this, [this](const Error& error)
{
if (error.isEmpty())
{
addLabels();
}
});
loadRestaurantSymbol();
}
UpdateLabelsAndSymbolsToScaleForVisualAccessibility::~UpdateLabelsAndSymbolsToScaleForVisualAccessibility() = default;
void UpdateLabelsAndSymbolsToScaleForVisualAccessibility::init()
{
// Register the map view for QML
qmlRegisterType<MapQuickView>("Esri.Samples", 1, 0, "MapView");
qmlRegisterType<UpdateLabelsAndSymbolsToScaleForVisualAccessibility>("Esri.Samples", 1, 0,
"UpdateLabelsAndSymbolsToScaleForVisualAccessibilitySample");
}
MapQuickView* UpdateLabelsAndSymbolsToScaleForVisualAccessibility::mapView() const
{
return m_mapView;
}
// Set the view (created in QML)
void UpdateLabelsAndSymbolsToScaleForVisualAccessibility::setMapView(MapQuickView* mapView)
{
if (!mapView || mapView == m_mapView)
{
return;
}
m_mapView = mapView;
m_mapView->setMap(m_map);
connect(m_mapView, &MapQuickView::mouseClicked, this, &UpdateLabelsAndSymbolsToScaleForVisualAccessibility::identifyRestaurant);
emit mapViewChanged();
}
QUrl UpdateLabelsAndSymbolsToScaleForVisualAccessibility::symbolSwatchUrl() const
{
return m_symbolSwatchUrl;
}
void UpdateLabelsAndSymbolsToScaleForVisualAccessibility::setSymbolSize(double symbolSize)
{
if (symbolSize <= 0 || qFuzzyCompare(m_symbolSize, symbolSize))
{
return;
}
m_symbolSize = symbolSize;
if (m_restaurantSymbol)
{
m_restaurantSymbol->setSize(m_symbolSize);
}
}
void UpdateLabelsAndSymbolsToScaleForVisualAccessibility::updateSymbolSize()
{
const double textScale = m_systemTextScaleMonitor->textScale();
setSymbolSize(24.0 * textScale);
}
void UpdateLabelsAndSymbolsToScaleForVisualAccessibility::loadRestaurantSymbol()
{
// Get the restaurant symbol from Esri's 2D point symbol web style
SymbolStyle* symbolStyle = new SymbolStyle("Esri2DPointSymbolsStyle", nullptr, this);
symbolStyle->fetchSymbolAsync({"restaurant"}, this)
.then(this, [this](Symbol* symbol)
{
MultilayerPointSymbol* restaurantSymbol = qobject_cast<MultilayerPointSymbol*>(symbol);
if (!restaurantSymbol)
{
return;
}
m_restaurantSymbol = restaurantSymbol;
restaurantSymbol->setSize(m_symbolSize);
// Display the restaurants with the symbol
m_restaurantsLayer->setRenderer(new SimpleRenderer(restaurantSymbol, this));
restaurantSymbol->createSwatchAsync().then(this, [this](const QImage& swatch)
{
QByteArray swatchBytes;
QBuffer buffer(&swatchBytes);
buffer.open(QIODevice::WriteOnly);
swatch.save(&buffer, "PNG");
m_symbolSwatchUrl = QUrl("data:image/png;base64," + swatchBytes.toBase64());
emit symbolSwatchUrlChanged();
});
});
}
void UpdateLabelsAndSymbolsToScaleForVisualAccessibility::addLabels()
{
// Create a text symbol for the labels
TextSymbol* textSymbol = new TextSymbol(this);
textSymbol->setColor(QColor(31, 35, 40));
textSymbol->setHaloColor(Qt::white);
textSymbol->setHaloWidth(2);
textSymbol->setSize(12);
// Label each restaurant with its name, above the restaurant symbol
LabelDefinition* labelDefinition = new LabelDefinition(new SimpleLabelExpression("[name]", this), textSymbol, this);
labelDefinition->setDeconflictionStrategy(LabelDeconflictionStrategy::None);
labelDefinition->setPlacement(LabelingPlacement::PointAboveCenter);
m_restaurantsLayer->labelDefinitions()->append(labelDefinition);
m_restaurantsLayer->setLabelsEnabled(true);
}
void UpdateLabelsAndSymbolsToScaleForVisualAccessibility::identifyRestaurant(const QMouseEvent& mouseEvent)
{
// Clear any previous selection and callout
m_restaurantsLayer->clearSelection();
m_mapView->calloutData()->setVisible(false);
// Identify at most one restaurant near the selected screen position
m_mapView->identifyLayerAsync(m_restaurantsLayer, mouseEvent.position(), 12, false, 1, this)
.then(this, [this](IdentifyLayerResult* result)
{
if (!result)
{
return;
}
result->deleteLater();
if (result->geoElements().isEmpty())
{
return;
}
Feature* restaurant = static_cast<Feature*>(result->geoElements().constFirst());
const QString name = restaurant->attributes()->attributeValue("name").toString().trimmed();
// Project the restaurant location to WGS 84 to get its latitude and longitude
const Point location(restaurant->geometry());
const Point wgs84Location(GeometryEngine::project(location, SpatialReference::wgs84()));
// Select the restaurant and show its name and coordinates in a callout
m_restaurantsLayer->selectFeature(restaurant);
CalloutData* calloutData = m_mapView->calloutData();
calloutData->setLocation(location);
calloutData->setTitle(name.isEmpty() ? tr("Restaurant") : name);
calloutData->setDetail(tr("Lat: %1, Lon: %2").arg(wgs84Location.y(), 0, 'f', 5).arg(wgs84Location.x(), 0, 'f', 5));
calloutData->setVisible(true);
});
}