Change viewpoint

View inJavaKotlin
View on GitHub
Sample viewer app

Set the map view to a new viewpoint.

Image of change viewpoint

Use case

Programmatically navigate to a specified location in the map or scene. Use this to focus on a particular point or area of interest.

How to use the sample

The map view has several methods for setting its current viewpoint. Select a viewpoint from the UI to see the viewpoint changed using that method.

How it works

  1. Create a new ArcGISMap object and set it to the MapView object.
  2. Change the map's Viewpoint using one of the available methods:
  3. Use MapView.setViewpointAsync() to pan to a viewpoint over the specified length of time.
  4. Use MapView.setViewpointCenterAsync() to center the viewpoint on a Point and set a distance from the ground using a scale.
  5. Use MapView.setViewpointGeometryAsync() to set the viewpoint to a given Geometry.

Relevant API

  • ArcGISMap
  • Geometry
  • MapView
  • Point
  • Viewpoint

Additional information

Below are some other ways to set a viewpoint:

  • setViewpoint
  • setViewpointAsync
  • setViewpointCenterAsync
  • setViewpointGeometryAsync
  • setViewpointRotationAsync
  • setViewpointScaleAsync


animate, extent, pan, rotate, scale, view, zoom

Sample Code
/* Copyright 2016 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,
 * See the License for the specific language governing permissions and
 * limitations under the License.

package com.esri.arcgisruntime.sample.changeviewpoint;

import android.os.Bundle;
import android.view.View;

import com.esri.arcgisruntime.ArcGISRuntimeEnvironment;
import com.esri.arcgisruntime.geometry.Point;
import com.esri.arcgisruntime.geometry.PointCollection;
import com.esri.arcgisruntime.geometry.Polyline;
import com.esri.arcgisruntime.geometry.SpatialReferences;
import com.esri.arcgisruntime.mapping.ArcGISMap;
import com.esri.arcgisruntime.mapping.BasemapStyle;
import com.esri.arcgisruntime.mapping.Viewpoint;
import com.esri.arcgisruntime.mapping.view.MapView;

public class MainActivity extends AppCompatActivity {

  private static final int SCALE = 5000;
  private MapView mMapView;

  protected void onCreate(Bundle savedInstanceState) {

    // authentication with an API key or named user is required to access basemaps and other
    // location services

    // inflate MapView from layout
    mMapView = findViewById(;
    // create a map with an imagery base map
    ArcGISMap map = new ArcGISMap(BasemapStyle.ARCGIS_IMAGERY);
    // set the map to be displayed in this view
    mMapView.setViewpoint(new Viewpoint(new Point(-14093.0, 6711377.0, SpatialReferences.getWebMercator()), SCALE));

  public void onAnimateClicked(View view) {
    // create the London location point
    Point londonPoint = new Point(-14093.0, 6711377.0, SpatialReferences.getWebMercator());
    // create the viewpoint with the London point and scale
    Viewpoint viewpoint = new Viewpoint(londonPoint, SCALE);
    // set the map view's viewpoint to London with a seven second animation duration
    mMapView.setViewpointAsync(viewpoint, 7f);

  public void onCenterClicked(View view) {
    // create the Waterloo location point
    Point waterlooPoint = new Point(-12153.0, 6710527.0, SpatialReferences.getWebMercator());
    // set the map view's viewpoint centered on Waterloo and scaled
    mMapView.setViewpointCenterAsync(waterlooPoint, SCALE);

  public void onGeometryClicked(View view) {
    // create a collection of points around Westminster
    PointCollection westminsterPoints = new PointCollection(SpatialReferences.getWebMercator());
    westminsterPoints.add(new Point(-13823.0, 6710390.0));
    westminsterPoints.add(new Point(-13823.0, 6710150.0));
    westminsterPoints.add(new Point(-14680.0, 6710390.0));
    westminsterPoints.add(new Point(-14680.0, 6710150.0));
    Polyline geometry = new Polyline(westminsterPoints);

    // set the map view's viewpoint to Westminster

  protected void onPause() {

  protected void onResume() {

  protected void onDestroy() {