View on GitHub Sample viewer app

Set the map’s reference scale and which feature layers should honor the reference scale.

Image of map reference scale

Use case

Setting a reference scale on an ArcGISMap 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 ArcGISMap.

How to use the sample

Use the drop box at the top to set the map’s reference scale (1:500,000 1:250,000 1:100,000 1:50,000). Click the ‘Set Map Scale to Reference Scale’ button to set the map scale to the reference scale. Use the menu checkboxes in the layer menu to set which feature layers should honor the reference scale.

How it works

  1. Get and set the reference scale property of the ArcGISMap.
  2. Get and set the scale symbols property on each individual FeatureLayer.

Relevant API

  • ArcGISMap
  • FeatureLayer

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

module-info.java module-info.java MapReferenceScaleController.java MapReferenceScaleSample.java
/*
* Copyright 2022 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.
*/
module com.esri.samples.map_reference_scale {
// require ArcGIS Maps SDK for Java module
requires com.esri.arcgisruntime;
// handle SLF4J http://www.slf4j.org/codes.html#StaticLoggerBinder
requires org.slf4j.nop;
// require JavaFX modules that the application uses
requires javafx.graphics;
requires javafx.controls;
requires javafx.fxml;
// make all annotated @FXML objects reflectively accessible to the javafx.fxml module
opens com.esri.samples.map_reference_scale to javafx.fxml;
exports com.esri.samples.map_reference_scale;
}