Class Viewpoint

java.lang.Object
com.esri.arcgisruntime.mapping.Viewpoint
All Implemented Interfaces:
JsonSerializable

public final class Viewpoint extends Object implements JsonSerializable
Defines the visible area of a GeoModel that is displayed in a GeoView on a user's screen.

In a MapView, the bounding extent of a geometry or the map's center point and scale can define the map view's two-dimensional Viewpoint.

In a SceneView, a Camera represents the observer's position and perspective within three dimensions and defines the scene view's three-dimensional Viewpoint. Each camera has the following properties:

  • Geographic location on the surface (longitude and latitude).
  • Altitude (height, in meters, above sea level).
  • Heading (angle about the z axis the camera is rotated, in degrees).
  • Pitch (angle the camera is rotated up or down, in degrees).
  • Roll (angle the camera is rotated side-to-side, in degrees).

When you publish or save a map or scene, as a web map, web scene, mobile map package, or mobile scene package, you define its initial Viewpoint. When you load a map or scene into your app, you can access and change the value with GeoModel.setInitialViewpoint(Viewpoint). If you add the map or scene to a GeoView, any change you make with GeoModel.setInitialViewpoint(Viewpoint) is ignored. To change the Viewpoint of a displayed map or scene, use view methods such as:

To determine the current visible area, call GeoView.getCurrentViewpoint(Type). Make sure that any user-initiated or programmatic navigation is complete before getting the current Viewpoint by calling GeoView.navigatingProperty().

Since:
100.0.0
  • Constructor Details

    • Viewpoint

      public Viewpoint(Point center, double scale)
      Creates a Viewpoint using a center point and scale.
      Parameters:
      center - the center of the visible area
      scale - the ratio between a distance on the map and the corresponding distance on the ground
      Throws:
      IllegalArgumentException - if the specified center point is null
      IllegalArgumentException - if the specified scale is less than or equal to zero
      Since:
      100.0.0
    • Viewpoint

      public Viewpoint(Point center, double scale, Camera camera)
      Creates a Viewpoint with center point, scale, and Camera.
      Parameters:
      center - the center of the visible area
      scale - the ratio between a distance on the map and the corresponding distance on the ground
      camera - a Camera object that defines the observer of the scene
      Throws:
      IllegalArgumentException - if center is null
      IllegalArgumentException - if scale is out of range
      IllegalArgumentException - if camera is null
      Since:
      100.0.0
    • Viewpoint

      public Viewpoint(Point center, double scale, double rotation)
      Creates a Viewpoint with center point, scale, and rotation. Scale factor must be greater than 0.
      Parameters:
      center - the center of the visible area
      scale - the ratio between a distance on the map and the corresponding distance on the ground
      rotation - the rotation angle in degrees between 0 and 360
      Throws:
      IllegalArgumentException - if the specified center point is null, if the specified scale is less than or equal to zero, or if the specified rotation is less than zero
      Since:
      100.0.0
    • Viewpoint

      public Viewpoint(Point center, double scale, double rotation, Camera camera)
      Creates a Viewpoint with center point, scale, rotation, and Camera.
      Parameters:
      center - the center point of the visible area
      scale - the ratio between a distance on the map and the corresponding distance on the ground
      rotation - the rotation angle in degrees between 0 and 360
      camera - a Camera object that defines the observer for the scene
      Throws:
      IllegalArgumentException - if center is null
      IllegalArgumentException - if scale is out of range
      IllegalArgumentException - if camera is null
      Since:
      100.0.0
    • Viewpoint

      public Viewpoint(Geometry targetExtent)
      Creates a viewpoint with a bounding extent.
      Parameters:
      targetExtent - the geometry to use as the visible area. The targetExtent parameter cannot be null.
      Throws:
      IllegalArgumentException - if the targetExtent is null
      Since:
      100.0.0
    • Viewpoint

      public Viewpoint(Geometry targetExtent, Camera camera)
      Creates a viewpoint with a bounding extent and a Camera.
      Parameters:
      targetExtent - the geometry to use as the visible area. The targetExtent parameter cannot be null.
      camera - a Camera object that defines the observer for the scene
      Throws:
      IllegalArgumentException - if the targetExtent is null
      IllegalArgumentException - if the camera is null
      Since:
      100.0.0
    • Viewpoint

      public Viewpoint(Geometry targetExtent, double rotation)
      Creates a Viewpoint with a bounding extent and rotation.
      Parameters:
      targetExtent - the geometry to use as the visible area. The targetExtent parameter cannot be null.
      rotation - the rotation angle in degrees between 0 and 360
      Throws:
      IllegalArgumentException - if the targetExtent is null or if the rotation is less than zero
      Since:
      100.0.0
    • Viewpoint

      public Viewpoint(Geometry targetExtent, double rotation, Camera camera)
      Creates a Viewpoint with a bounding extent, rotation, and a Camera.
      Parameters:
      targetExtent - the geometry to use as the visible area. The targetExtent parameter cannot be null.
      rotation - the rotation angle in degrees between 0 and 360
      camera - a Camera object that defines the observer of the scene
      Throws:
      IllegalArgumentException - if the targetExtent is null
      IllegalArgumentException - if the rotation is less than zero
      IllegalArgumentException - if the camera is null
      Since:
      100.0.0
      See Also:
    • Viewpoint

      public Viewpoint(double latitude, double longitude, double scale)
      Creates a Viewpoint with latitude, longitude, and scale. The spatial reference for the defined point is WGS84.
      Parameters:
      latitude - the latitude coordinate for the viewpoint. Negative values are south of the equator.
      longitude - the longitude coordinate for the viewpoint. Negative values are west of the prime meridian.
      scale - the ratio between a distance on the map and the corresponding distance on the ground
      Throws:
      IllegalArgumentException - if the specified scale is less than or equal to zero
      Since:
      100.0.0
    • Viewpoint

      public Viewpoint(double latitude, double longitude, double scale, Camera camera)
      Creates a Viewpoint with latitude, longitude, scale and Camera. The spatial reference for the defined point is WGS84.
      Parameters:
      latitude - the latitude coordinate for the viewpoint. Negative values are south of the equator
      longitude - the longitude coordinate for the viewpoint. Negative values are west of the prime meridian.
      scale - the scale the ratio between a distance on the map and the corresponding distance on the ground
      camera - a Camera object that defines the observer for the scene
      Throws:
      IllegalArgumentException - if camera is null
      IllegalArgumentException - if scale is out of range
      Since:
      100.0.0
  • Method Details

    • getRotation

      public double getRotation()
      Gets the rotation angle of the viewpoint in degrees between 0 and 360.
      Returns:
      the rotation value.
      Since:
      100.0.0
    • getTargetGeometry

      public Geometry getTargetGeometry()
      Gets the viewpoint target geometry, if the getType() is Viewpoint.Type.BOUNDING_GEOMETRY.
      Returns:
      the geometry used by this viewpoint. The target geometry will have a non-null spatial reference.
      Since:
      100.0.0
      See Also:
    • getTargetScale

      public double getTargetScale()
      Gets the viewpoint's target scale, if the getType() is Viewpoint.Type.CENTER_AND_SCALE.
      Returns:
      the target scale used for this viewpoint
      Since:
      100.0.0
    • getCamera

      public Camera getCamera()
      Gets the viewpoint's Camera, if it has one.
      Returns:
      the viewpoint's Camera
      Since:
      100.0.0
    • getType

      public Viewpoint.Type getType()
      Gets the viewpoint's type.

      This will be defined by a geometry or a Point geometry and scale.

      Returns:
      the type of Viewpoint
      Since:
      100.0.0
      See Also:
    • fromJson

      public static Viewpoint fromJson(String json)
      Creates a Viewpoint instance from a JSON string.
      Parameters:
      json - a JSON string that represents a Viewpoint
      Returns:
      a Viewpoint instance
      Throws:
      IllegalArgumentException - if json is null or empty
      Since:
      100.0.0
    • toJson

      public String toJson()
      Description copied from interface: JsonSerializable
      Serializes this object to a JSON string. Note that unknown JSON is omitted from the serialized string.
      Specified by:
      toJson in interface JsonSerializable
      Returns:
      a JSON string
    • getUnknownJson

      public Map<String,Object> getUnknownJson()
      Description copied from interface: JsonSerializable
      Gets unknown data from the source JSON.

      Unknown JSON is a Map of values not defined in the ArcGIS specification used to create this object but found in the source JSON. If the object is written back to JSON, any unknown JSON data is not persisted. The ArcGIS specification may be for a web map, web scene, REST API, and so on.

      Specified by:
      getUnknownJson in interface JsonSerializable
      Returns:
      an unmodifiable Map containing unknown data from the source JSON
    • getUnsupportedJson

      public Map<String,Object> getUnsupportedJson()
      Description copied from interface: JsonSerializable
      Gets unsupported data from the source JSON.

      Unsupported JSON is a Map of values defined in the ArcGIS specification used to create this object but not currently used in this API. If the object is written back to JSON, any unsupported JSON data is persisted. The ArcGIS specification may be from a web map, web scene, REST API, and so on.

      Specified by:
      getUnsupportedJson in interface JsonSerializable
      Returns:
      an unmodifiable Map containing unsupported data from the source JSON