View on GitHub Sample viewer app

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

Image of Set reference scale sample

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 map view.

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. When the map is zoomed out, that information shouldn’t scale with the map view but should instead remain scaled with the map.

How to use the sample

When the sample loads, tap or click the “Map Settings” button. Use the “Reference Scale” picker to set the map’s reference scale (1:500,000, 1:250,000, 1:100,000, or 1:50,000). Then tap or click the “Set to Reference Scale” button to set the map scale to the reference scale.

Tap or click “Layers” to show a list of the map’s feature layers. Tap or click a layer to toggle whether that layer should honor the reference scale. Tap or click Done to dismiss the settings view.

How it works

  1. Get and set the referenceScale property on the ArcGISMap object.
  2. Get and set the scaleSymbols property on individual FeatureLayer objects.

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

MainActivity.kt MainActivity.kt SetReferenceScaleViewModel.kt SetReferenceScaleScreen.kt
/* Copyright 2025 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.
*
*/
package com.esri.arcgismaps.sample.setreferencescale
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import com.arcgismaps.ApiKey
import com.arcgismaps.ArcGISEnvironment
import com.esri.arcgismaps.sample.sampleslib.theme.SampleAppTheme
import com.esri.arcgismaps.sample.setreferencescale.screens.SetReferenceScaleScreen
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// authentication with an API key or named user is
// required to access basemaps and other location services
ArcGISEnvironment.apiKey = ApiKey.create(BuildConfig.ACCESS_TOKEN)
setContent {
SampleAppTheme {
SetReferenceScaleApp()
}
}
}
@Composable
private fun SetReferenceScaleApp() {
Surface(color = MaterialTheme.colorScheme.background) {
SetReferenceScaleScreen(
sampleName = getString(R.string.set_reference_scale_app_name)
)
}
}
}