ArcGIS Runtime SDK for Java

Distance Measurement Analysis

Demonstrates measuring 3D distances between two points in a scene.

The distance measurement analysis allows you to add the same measuring experience found in ArcGIS Pro, City Engine, and the ArcGIS API for JavaScript to your app. You can set the unit system of measurement (metric or imperial) and have the units automatically switch to one appropriate for the current scale. The rendering is handled internally so it doesn't interfere with other analyses like viewsheds.

How it works

To measure distances with the Location Distance Measurement analysis:

  1. Create an AnalysisOverlay and add it to your scene view's analysis overlay collection:sceneView.getAnalysisOverlays().add(analysisOverlay).
  2. Create a LocationDistanceMeasurement, specifying the startLocation and endLocation. These can be the same point to start with. Add the analysis to the analysis overlay: analysisOverlay.getAnalyses().add(LocationDistanceMeasurement). The measuring line will be drawn for you between the two points.
  3. The measurementChanged callback will fire if the distances change. You can get the new values for the directDistance, horizontalDistance, and verticalDistance from the MeasurementChangedEvent returned by the callback. The distance objects contain both a scalar value and a unit of measurement.


 * Copyright 2018 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
 * 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.samples.analysis.distance_measurement_analysis;


import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class DistanceMeasurementAnalysisSample extends Application {

  private static DistanceMeasurementAnalysisController controller;

  public void start(Stage stage) throws IOException {
    // set up the scene
    FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/distance_measurement_analysis.fxml"));
    Parent root = loader.load();
    controller = loader.getController();
    Scene scene = new Scene(root);

    // set up the stage
    stage.setTitle("Distance Measurement Analysis Sample");

   * Stops and releases all resources used in application.
  public void stop() {

   * Opens and runs application.
   * @param args arguments passed to this application
  public static void main(String[] args) {


In this topic
  1. How it works
  2. Code