Viewpoint Class

  • Viewpoint
  • class Esri::ArcGISRuntime::Viewpoint

    Defines the visible area of a GeoModel that is displayed in a GeoView on a user's screen. More...

    Header: #include <Viewpoint.h>
    Since: Esri::ArcGISRuntime 100.0
    Inherits: Esri::ArcGISRuntime::JsonSerializable

    Public Functions

    Viewpoint()
    Viewpoint(double latitude, double longitude, double scale)
    Viewpoint(double latitude, double longitude, double scale, const Esri::ArcGISRuntime::Camera &camera)
    Viewpoint(const Esri::ArcGISRuntime::Point &center, double scale)
    Viewpoint(const Esri::ArcGISRuntime::Point &center, double scale, const Esri::ArcGISRuntime::Camera &camera)
    Viewpoint(const Esri::ArcGISRuntime::Point &center, double scale, double rotation)
    Viewpoint(const Esri::ArcGISRuntime::Point &center, double scale, double rotation, const Esri::ArcGISRuntime::Camera &camera)
    Viewpoint(const Esri::ArcGISRuntime::Geometry &targetExtent)
    Viewpoint(const Esri::ArcGISRuntime::Geometry &targetExtent, const Esri::ArcGISRuntime::Camera &camera)
    Viewpoint(const Esri::ArcGISRuntime::Geometry &targetExtent, double rotation)
    Viewpoint(const Esri::ArcGISRuntime::Geometry &targetExtent, double rotation, const Esri::ArcGISRuntime::Camera &camera)
    Viewpoint(const Esri::ArcGISRuntime::Viewpoint &other)
    Viewpoint(Esri::ArcGISRuntime::Viewpoint &&other)
    virtual ~Viewpoint() override
    Esri::ArcGISRuntime::Camera camera() const
    bool isEmpty() const
    double rotation() const
    Esri::ArcGISRuntime::Geometry targetGeometry() const
    double targetScale() const
    Esri::ArcGISRuntime::ViewpointType viewpointType() const
    bool operator!=(const Esri::ArcGISRuntime::Viewpoint &other) const
    Esri::ArcGISRuntime::Viewpoint &operator=(const Esri::ArcGISRuntime::Viewpoint &other)
    Esri::ArcGISRuntime::Viewpoint &operator=(Esri::ArcGISRuntime::Viewpoint &&other)
    bool operator==(const Esri::ArcGISRuntime::Viewpoint &other) const

    Reimplemented Public Functions

    virtual QString toJson() const override
    virtual QJsonObject unknownJson() const override
    virtual QJsonObject unsupportedJson() const override

    Static Public Members

    Esri::ArcGISRuntime::Viewpoint fromJson(const QString &json)

    Detailed Description

    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 of this GeoModel::initialViewpoint. If you add the map or scene to a GeoView, any change you make to the GeoModel::initialViewpoint is ignored. To change the Viewpoint of a displayed map or scene, use view methods such as:

    • GeoView::setViewpoint(const Esri::ArcGISRuntime::Viewpoint&) to instantly change the visible area with no animation.
    • MapView::setViewpointAsync(const Esri::ArcGISRuntime::Viewpoint&, float, Esri::ArcGISRuntime::AnimationCurve) to animates the display of the map to a viewpoint using the provided animation curve.
    • SceneView::setViewpointCamera(const Esri::ArcGISRuntime::Camera&) to instantly moving the perspective in 3D scenes.

    To determine the current visible area, call GeoView::currentViewpoint(Esri::ArcGISRuntime::ViewpointType). Make sure that any user-initiated or programmatic navigation is complete before getting the current Viewpoint by calling GeoView::isNavigating.

    Example:

    Create a Viewpoint on a MapView based on an extent and zoom to the extent with animation:

    constexpr double xMin = -12338668.348591767;
    constexpr double yMin = 5546908.424239618;
    constexpr double xMax = -12338247.594362013;
    constexpr double yMax = 5547223.989911933;
    constexpr int wkid = 102100;
    Viewpoint vpSpring(Envelope(xMin, yMin, xMax, yMax, SpatialReference(wkid)));
    constexpr float duration = 4.0f;
    m_mapView->setViewpointAsync(vpSpring, duration, AnimationCurve::EaseInOutCubic);

    Note: This class is not default constructible internally, but a default constructor is provided for convenience. If the default constructor is used, the object will be empty. Calling any method on an empty object is undefined behavior and any values returned should not be relied upon.

    Relevant samples:

    See also isEmpty, Camera, MapView, and SceneView.

    Member Function Documentation

    Viewpoint::Viewpoint()

    Default constructor.

    Note: This is provided for convenience and produces an empty object.

    See also isEmpty.

    Viewpoint::Viewpoint(double latitude, double longitude, double scale)

    A constructor that creates a Viewpoint with latitude, longitude, and scale.

    The spatial reference for the defined point is WGS84.

    • latitude - The latitude coordinate for the viewpoint's center. Negative values are south of the equator.
    • longitude - The longitude coordinate for the viewpoint's center. Negative values are west of the prime meridian.
    • scale - The ratio between a distance on the map and the corresponding distance on the ground.

    Viewpoint::Viewpoint(double latitude, double longitude, double scale, const Esri::ArcGISRuntime::Camera &camera)

    A constructor that creates a Viewpoint using a map center expressed as latitude and longitude, map scale, and camera.

    The spatial reference for the defined point is WGS84.

    • latitude - The latitude coordinate for the viewpoint's center. Negative values are south of the equator.
    • longitude - The longitude coordinate for the viewpoint's center. Negative values are west of the prime meridian.
    • 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.

    Viewpoint::Viewpoint(const Esri::ArcGISRuntime::Point &center, double scale)

    A constructor that creates a Viewpoint with center point and scale.

    • center - The center of the visible area.
    • scale - The ratio between a distance on the map and the corresponding distance on the ground.

    Viewpoint::Viewpoint(const Esri::ArcGISRuntime::Point &center, double scale, const Esri::ArcGISRuntime::Camera &camera)

    A constructor that creates a Viewpoint with center point, scale, and Camera.

    • 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 for the scene.

    Viewpoint::Viewpoint(const Esri::ArcGISRuntime::Point &center, double scale, double rotation)

    A constructor that creates a Viewpoint with center point, scale, and rotation.

    • 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.

    Viewpoint::Viewpoint(const Esri::ArcGISRuntime::Point &center, double scale, double rotation, const Esri::ArcGISRuntime::Camera &camera)

    A constructor that creates a Viewpoint with center point, scale, rotation, and Camera.

    • 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.
    • camera - A Camera object that defines the observer for the scene.

    Viewpoint::Viewpoint(const Esri::ArcGISRuntime::Geometry &targetExtent)

    A constructor that creates a Viewpoint with a bounding extent.

    The spatial reference will be that same as the extent.

    • targetExtent - The geometry to use as the visible area.

    Viewpoint::Viewpoint(const Esri::ArcGISRuntime::Geometry &targetExtent, const Esri::ArcGISRuntime::Camera &camera)

    A constructor that creates a Viewpoint with a bounding extent and Camera.

    The spatial reference will be that same as the extent.

    • targetExtent - The geometry to use as the visible area.
    • camera - A Camera object that defines the observer for the scene.

    Viewpoint::Viewpoint(const Esri::ArcGISRuntime::Geometry &targetExtent, double rotation)

    A constructor that creates a Viewpoint with a bounding extent and rotation.

    • targetExtent - The geometry to use as the visible area.
    • rotation - The rotation angle in degrees between 0 and 360.

    Viewpoint::Viewpoint(const Esri::ArcGISRuntime::Geometry &targetExtent, double rotation, const Esri::ArcGISRuntime::Camera &camera)

    A constructor that creates a Viewpoint with a bounding extent, rotation, and Camera.

    • targetExtent - The geometry to use as the visible area.
    • rotation - The rotation angle in degrees between 0 and 360.
    • camera - A Camera object that defines the observer for the scene.

    Viewpoint::Viewpoint(const Esri::ArcGISRuntime::Viewpoint &other)

    Copy constructor from other Viewpoint.

    Viewpoint::Viewpoint(Esri::ArcGISRuntime::Viewpoint &&other)

    Move constructor from other Viewpoint.

    [override virtual] Viewpoint::~Viewpoint()

    Destructor.

    Esri::ArcGISRuntime::Camera Viewpoint::camera() const

    Gets the viewpoint's Camera.

    [static] Esri::ArcGISRuntime::Viewpoint Viewpoint::fromJson(const QString &json)

    Creates a Viewpoint from its JSON representation.

    Returns a Viewpoint created using the data in the json parameter.

    See also JsonSerializable.

    bool Viewpoint::isEmpty() const

    Returns true if this Viewpoint is empty.

    double Viewpoint::rotation() const

    Gets the viewpoint rotation angle in degrees between 0 and 360.

    See also Viewpoint.

    Esri::ArcGISRuntime::Geometry Viewpoint::targetGeometry() const

    Returns the viewpoint target geometry, if the viewpointType is ViewpointType::BoundingGeometry.

    See also Viewpoint and viewpointType.

    double Viewpoint::targetScale() const

    Returns the viewpoint's target scale, if the viewpointType is ViewpointType::CenterAndScale.

    See also Viewpoint.

    [override virtual] QString Viewpoint::toJson() const

    Reimplements: JsonSerializable::toJson() const.

    Returns this Viewpoint as its JSON representation.

    See also JsonSerializable.

    [override virtual] QJsonObject Viewpoint::unknownJson() const

    Reimplements: JsonSerializable::unknownJson() const.

    Returns the unknown data from the source JSON.

    Unknown JSON is a QJsonObject 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.

    [override virtual] QJsonObject Viewpoint::unsupportedJson() const

    Reimplements: JsonSerializable::unsupportedJson() const.

    Returns the unsupported data from the source JSON.

    Unsupported JSON is a QJsonObject 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.

    Esri::ArcGISRuntime::ViewpointType Viewpoint::viewpointType() const

    Gets the type of this Viewpoint.

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

    See also Viewpoint.

    [since Esri::ArcGISRuntime 200.2] bool Viewpoint::operator!=(const Esri::ArcGISRuntime::Viewpoint &other) const

    Inequality operator. Returns true if this object and other are not equal.

    This function was introduced in Esri::ArcGISRuntime 200.2.

    See also Viewpoint::operator==.

    Esri::ArcGISRuntime::Viewpoint &Viewpoint::operator=(const Esri::ArcGISRuntime::Viewpoint &other)

    Assignment operator from other Viewpoint.

    Esri::ArcGISRuntime::Viewpoint &Viewpoint::operator=(Esri::ArcGISRuntime::Viewpoint &&other)

    Move operator from other Viewpoint.

    [since Esri::ArcGISRuntime 200.1] bool Viewpoint::operator==(const Esri::ArcGISRuntime::Viewpoint &other) const

    Equivalency operator.

    Returns true if this object and other are equivalent.

    This function was introduced in Esri::ArcGISRuntime 200.1.

    Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.