Classdesc

An ol.View object represents a simple 2D view of the map.

This is the object to act upon to change the center, resolution, and rotation of the map.

The view states

An ol.View is determined by three states: center, resolution, and rotation. Each state has a corresponding getter and setter, e.g. getCenter and setCenter for the center state.

An ol.View has a projection. The projection determines the coordinate system of the center, and its units determine the units of the resolution (projection units per pixel). The default projection is Spherical Mercator (EPSG:3857).

The constraints

setCenter, setResolution and setRotation can be used to change the states of the view. Any value can be passed to the setters. And the value that is passed to a setter will effectively be the value set in the view, and returned by the corresponding getter.

But an ol.View object also has a resolution constraint, a rotation constraint and a center constraint.

As said above, no constraints are applied when the setters are used to set new states for the view. Applying constraints is done explicitly through the use of the constrain* functions (constrainResolution and constrainRotation and constrainCenter).

The main users of the constraints are the interactions and the controls. For example, double-clicking on the map changes the view to the "next" resolution. And releasing the fingers after pinch-zooming snaps to the closest resolution (with an animation).

The resolution constraint snaps to specific resolutions. It is determined by the following options: resolutions, maxResolution, maxZoom, and zoomFactor. If resolutions is set, the other three options are ignored. See documentation for each option for more information.

The rotation constraint snaps to specific angles. It is determined by the following options: enableRotation and constrainRotation. By default the rotation value is snapped to zero when approaching the horizontal.

The center constraint is determined by the extent option. By default the center is not constrained at all.

Param: opt_options

View options.

Api

stable

Hierarchy

Constructors

  • Parameters

    Returns View

    Classdesc

    An ol.View object represents a simple 2D view of the map.

    This is the object to act upon to change the center, resolution, and rotation of the map.

    The view states

    An ol.View is determined by three states: center, resolution, and rotation. Each state has a corresponding getter and setter, e.g. getCenter and setCenter for the center state.

    An ol.View has a projection. The projection determines the coordinate system of the center, and its units determine the units of the resolution (projection units per pixel). The default projection is Spherical Mercator (EPSG:3857).

    The constraints

    setCenter, setResolution and setRotation can be used to change the states of the view. Any value can be passed to the setters. And the value that is passed to a setter will effectively be the value set in the view, and returned by the corresponding getter.

    But an ol.View object also has a resolution constraint, a rotation constraint and a center constraint.

    As said above, no constraints are applied when the setters are used to set new states for the view. Applying constraints is done explicitly through the use of the constrain* functions (constrainResolution and constrainRotation and constrainCenter).

    The main users of the constraints are the interactions and the controls. For example, double-clicking on the map changes the view to the "next" resolution. And releasing the fingers after pinch-zooming snaps to the closest resolution (with an animation).

    The resolution constraint snaps to specific resolutions. It is determined by the following options: resolutions, maxResolution, maxZoom, and zoomFactor. If resolutions is set, the other three options are ignored. See documentation for each option for more information.

    The rotation constraint snaps to specific angles. It is determined by the following options: enableRotation and constrainRotation. By default the rotation value is snapped to zero when approaching the horizontal.

    The center constraint is determined by the extent option. By default the center is not constrained at all.

    Api

    stable

Methods

  • Animate the view. The view's center, zoom (or resolution), and rotation can be animated for smooth transitions between view states.

    Parameters

    • Rest ...var_args: (AnimateOptions | AnimateCallback)[]

      Animation options.

    Returns void

    Api

    experimental

  • Calculate the extent for the current view state and the passed size. The size is the pixel dimensions of the box into which the calculated extent should fit. In most cases you want to get the extent of the entire map, that is map.getSize().

    Parameters

    • size: Size

      Box pixel size.

    Returns Extent

    Extent.

    Api

    stable

  • Center on coordinate and view position.

    Parameters

    • coordinate: Coordinate

      Coordinate.

    • size: Size

      Box pixel size.

    • position: Pixel

      Position on the view to center on.

    Returns void

    Api

  • Increases the revision counter and dispatches a 'change' event.

    Returns void

    Api

  • Get the constrained center of this view.

    Parameters

    Returns Coordinate

    Constrained center.

    Api

  • Get the constrained resolution of this view.

    Parameters

    • resolution: number

      Resolution.

    • Optional opt_delta: number

      Delta. Default is 0.

    • Optional opt_direction: number

      Direction. Default is 0.

    Returns number

    Constrained resolution.

    Api

  • Get the constrained rotation of this view.

    Parameters

    • rotation: number

      Rotation.

    • Optional opt_delta: number

      Delta. Default is 0.

    Returns number

    Constrained rotation.

    Api

  • Dispatches an event and calls all listeners listening for events of this type. The event parameter can either be a string or an Object with a type property.

    Parameters

    Returns void

    Function

    Api

  • Fit the given geometry or extent based on the given map size and border. The size is pixel dimensions of the box to fit the extent into. In most cases you will want to use the map size, that is map.getSize(). Takes care of the map angle.

    Parameters

    Returns void

    Api

  • Gets a value.

    Parameters

    • key: string

      Key name.

    Returns any

    Value.

    Api

    stable

  • Get the view center.

    Returns Coordinate

    The center of the view.

    Observable

    Api

    stable

  • Get a list of object property names.

    Returns string[]

    List of property names.

    Api

    stable

  • Get the maximum resolution of the view.

    Returns number

    The maximum resolution of the view.

    Api

  • Get the minimum resolution of the view.

    Returns number

    The minimum resolution of the view.

    Api

  • Get the view projection.

    Returns Projection

    The projection of the view.

    Api

    stable

  • Get an object of all property names and values.

    Returns {
        [k: string]: any;
    }

    Object.

    • [k: string]: any

    Api

    stable

  • Get the view resolution.

    Returns number

    The resolution of the view.

    Observable

    Api

    stable

  • Get the resolutions for the view. This returns the array of resolutions passed to the constructor of the {ol.View}, or undefined if none were given.

    Returns number[]

    The resolutions of the view.

    Api

    stable

  • Get the version number for this object. Each time the object is modified, its version number will be incremented.

    Returns number

    Revision.

    Api

  • Get the view rotation.

    Returns number

    The rotation of the view in radians.

    Observable

    Api

    stable

  • Get the current zoom level. Return undefined if the current resolution is undefined or not within the "resolution constraints".

    Returns number

    Zoom.

    Api

    stable

  • Listen for a certain type of event.

    Parameters

    • type: string | string[]

      The event type or array of event types.

    • listener: Function

      The listener function.

    • Optional opt_this: Object

      The object to use as this in listener.

    Returns Object | Object[]

    Unique key for the listener. If called with an array of event types as the first argument, the return will be an array of keys.

    Api

    stable

  • Listen once for a certain type of event.

    Parameters

    • type: string | string[]

      The event type or array of event types.

    • listener: Function

      The listener function.

    • Optional opt_this: Object

      The object to use as this in listener.

    Returns Object | Object[]

    Unique key for the listener. If called with an array of event types as the first argument, the return will be an array of keys.

    Api

    stable

  • Rotate the view around a given coordinate.

    Parameters

    • rotation: number

      New rotation value for the view.

    • Optional opt_anchor: Coordinate

      The rotation center.

    Returns void

    Api

    stable

  • Sets a value.

    Parameters

    • key: string

      Key name.

    • value: any

      Value.

    • Optional opt_silent: boolean

      Update without triggering an event.

    Returns void

    Api

    stable

  • Set the center of the current view.

    Parameters

    Returns void

    Observable

    Api

    stable

  • Sets a collection of key-value pairs. Note that this changes any existing properties and adds new ones (it does not remove any existing properties).

    Parameters

    • values: {
          [k: string]: any;
      }

      Values.

      • [k: string]: any
    • Optional opt_silent: boolean

      Update without triggering an event.

    Returns void

    Api

    stable

  • Set the resolution for this view.

    Parameters

    • resolution: number

      The resolution of the view.

    Returns void

    Observable

    Api

    stable

  • Set the rotation for this view.

    Parameters

    • rotation: number

      The rotation of the view in radians.

    Returns void

    Observable

    Api

    stable

  • Zoom to a specific zoom level.

    Parameters

    • zoom: number

      Zoom level.

    Returns void

    Api

    stable

  • Unlisten for a certain type of event.

    Parameters

    • type: string | string[]

      The event type or array of event types.

    • listener: Function

      The listener function.

    • Optional opt_this: Object

      The object which was used as this by the listener.

    Returns void

    Api

    stable

  • Removes an event listener using the key returned by on() or once(). Note that using the ol.Observable.unByKey static function is to be preferred.

    Parameters

    • key: Object | Object[]

      The key returned by on() or once() (or an array of keys).

    Returns void

    Function

    Api

    stable

  • Unsets a property.

    Parameters

    • key: string

      Key name.

    • Optional opt_silent: boolean

      Unset without triggering an event.

    Returns void

    Api

    stable

  • Removes an event listener using the key returned by on() or once().

    Parameters

    • key: Object | Object[]

      The key returned by on() or once() (or an array of keys).

    Returns void

    Api

    stable

Generated using TypeDoc