View on GitHub Sample viewer app

Display dimension features from a mobile map package.

Image showing the Display Dimensions sample

Use case

Dimensions show specific lengths or distances on a map. A dimension may indicate the length of a side of a building or land parcel, or the distance between two features, such as a fire hydrant and the corner of a building.

How to use the sample

When the sample loads, it will automatically display the map containing dimension features from the mobile map package. The name of the dimension layer containing the dimension features is displayed in the controls box. Control the visibility of the dimension layer with the “Dimension Settings” button, and apply a definition expression to show dimensions of greater than or equal to 450m in length using the “Definition Expression” switch.

How it works

  1. Create a MobileMapPackage specifying the path to the .mmpk file.
  2. Load the mobile map package with mobileMapPackage.load().
  3. After it successfully loads, get the first map from the mmpk and set it to the map view: mapView.map = mobileMapPackage.maps[0].
  4. Loop through the map’s layers to create a DimensionLayer.
  5. Control the dimension layer’s visibility with dimensionLayer.isVisible and set a definition expression with dimensionLayer.definitionExpression.

Relevant API

  • DimensionLayer
  • MobileMapPackage

About the data

This sample shows a subset of the Edinburgh, Scotland network of pylons, substations, and powerlines within an Edinburgh Pylon Dimensions mobile map package, digitized from satellite imagery. Note the data is intended as illustrative of the network only.

Additional information

Dimension layers can be taken offline from a feature service hosted on ArcGIS Enterprise 10.9 or later, using the GeodatabaseSyncTask. Dimension layers are also supported in mobile map packages or mobile geodatabases created in ArcGIS Pro 2.9 or later.

Tags

dimension, layer, mmpk, mobile map package, utility

Sample Code

DownloadActivity.kt DownloadActivity.kt MainActivity.kt
/* Copyright 2023 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.displaydimensions
import android.content.Intent
import android.os.Bundle
import com.esri.arcgismaps.sample.sampleslib.DownloaderActivity
class DownloadActivity : DownloaderActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
downloadAndStartSample(
Intent(this, MainActivity::class.java),
// get the app name of the sample
getString(R.string.display_dimensions_app_name),
listOf(
// ArcGIS Portal item containing the mmpk file which is a section of the
// high-voltage electricity transmission network around Edinburgh, Scotland.
"https://www.arcgis.com/home/item.html?id=f5ff6f5556a945bca87ca513b8729a1e"
)
)
}
}