OpenLayers Api 中文文档4 View

OpenLayers Api Doc

View

ol/View

import View from 'ol/View.js';

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

这是用来改变地图的中心、分辨率和旋转的对象。

A 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 Web Mercator (EPSG:3857).

一个视图有一个 “投影”。投影决定了中心的坐标系,其单位决定了分辨率的单位(每像素的投影单位)。默认投影是Web Mercator(EPSG:3857)。

视图状态The view states

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

一个视图由三种状态决定: center',resolution’, 和 rotation'。每个状态都有一个相应的getter和setter,例如getCentersetCenter用于center`状态。

The zoom state is actually not saved on the view: all computations internally use the resolution state. Still, the setZoom and getZoom methods are available, as well as getResolutionForZoom and getZoomForResolution to switch from one system to the other.

缩放 "状态实际上不保存在视图上:所有的计算都在内部使用 "分辨率 "状态。但是,setZoomgetZoom方法,以及getResolutionForZoomgetZoomForResolution都可以从一个系统切换到另一个系统。

限制因素The constraints

setCenter, setResolution and setRotation can be used to change the states of the view, but any constraint defined in the constructor will be applied along the way.

setCenter,setResolutionsetRotation可以用来改变视图的状态,但是在构造函数中定义的任何约束都会被沿用。

A View object can have a resolution constraint, a rotation constraint and a center constraint.

一个视图对象可以有一个分辨率约束,一个旋转约束和一个中心约束

The resolution constraint typically restricts min/max values and 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. By default, the view only has a min/max restriction and allow intermediary zoom levels when pinch-zooming for example.

分辨率约束*通常限制最小/最大值,并锁定在特定的分辨率上。它是由以下选项决定的: resolutions, maxResolution, maxZoomzoomFactor。如果resolutions被设置,其他三个选项将被忽略。更多信息请参见每个选项的文档。默认情况下,视图只有最小/最大的限制,例如在捏合缩放的时候,允许中间的缩放级别。

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

转动限制锁定在特定的角度上。它是由以下选项决定的: enableRotationconstrainRotation。默认情况下,旋转是允许的,当接近水平面时,它的值被捕捉为零。

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

中心约束*是由 "范围 "选项决定的。默认情况下,视图中心完全不受约束。

改变视图状态

[Changing the view state]

It is important to note that setZoom, setResolution, setCenter and setRotation are subject to the above mentioned constraints. As such, it may sometimes not be possible to know in advance the resulting state of the View. For example, calling setResolution(10) does not guarantee that getResolution() will return 10.

需要注意的是,setZoomsetResolutionsetCentersetRotation都受到上述约束。因此,有时可能不可能事先知道视图的结果状态。例如,调用setResolution(10)并不能保证getResolution()会返回10

A consequence of this is that, when applying a delta on the view state, one should use adjustCenter, adjustRotation, adjustZoom and adjustResolution rather than the corresponding setters. This will let view do its internal computations. Besides, the adjust* methods also take an anchor argument which allows specifying an origin for the transformation.

这样做的后果是,当对视图状态应用delta时,应该使用adjustCenteradjustRotationadjustZoomadjustResolution,而不是相应的setters。这将让视图做它的内部计算。此外,adjust*方法也有一个anchor参数,可以为转换指定一个原点。

视图交互对象

[Interacting with the view]

View constraints are usually only applied when the view is at rest, meaning that no interaction or animation is ongoing. As such, if the user puts the view in a state that is not equivalent to a constrained one (e.g. rotating the view when the snap angle is 0), an animation will be triggered at the interaction end to put back the view to a stable state;

视图约束通常只在视图处于静止状态时应用,这意味着没有交互或动画正在进行。因此,如果用户将视图置于不等同于约束的状态(例如,当捕捉角度为0时旋转视图),在交互结束时将会触发一个动画,使视图回到稳定状态;

new View(options)
NameTypeDescription
centerCoordinateundefinedThe initial center for the view. If a user projection is not set, the coordinate system for the center is specified with the projection option. Layer sources will not be fetched if this is not set, but the center can be set later with #setCenter.
constrainRotationbooleannumber (defaults to true)Rotation constraint. false means no constraint. true means no constraint, but snap to zero near zero. A number constrains the rotation to that number of values. For example, 4 will constrain the rotation to 0, 90, 180, and 270 degrees.
enableRotationboolean (defaults to true)Enable rotation. If false, a rotation constraint that always sets the rotation to zero is used. The constrainRotation option has no effect if enableRotation is false.
extentExtentundefinedThe extent that constrains the view, in other words, nothing outside of this extent can be visible on the map.
constrainOnlyCenterboolean (defaults to false)If true, the extent constraint will only apply to the view center and not the whole extent.
smoothExtentConstraintboolean (defaults to true)If true, the extent constraint will be applied smoothly, i.e. allow the view to go slightly outside of the given extent.
maxResolutionnumberundefinedThe maximum resolution used to determine the resolution constraint. It is used together with minResolution (or maxZoom) and zoomFactor. If unspecified it is calculated in such a way that the projection’s validity extent fits in a 256x256 px tile. If the projection is Spherical Mercator (the default) then maxResolution defaults to 40075016.68557849 / 256 = 156543.03392804097.
minResolutionnumberundefinedThe minimum resolution used to determine the resolution constraint. It is used together with maxResolution (or minZoom) and zoomFactor. If unspecified it is calculated assuming 29 zoom levels (with a factor of 2). If the projection is Spherical Mercator (the default) then minResolution defaults to 40075016.68557849 / 256 / Math.pow(2, 28) = 0.0005831682455839253.
maxZoomnumber (defaults to 28)The maximum zoom level used to determine the resolution constraint. It is used together with minZoom (or maxResolution) and zoomFactor. Note that if minResolution is also provided, it is given precedence over maxZoom.
minZoomnumber (defaults to 0)The minimum zoom level used to determine the resolution constraint. It is used together with maxZoom (or minResolution) and zoomFactor. Note that if maxResolution is also provided, it is given precedence over minZoom.
multiWorldboolean (defaults to false)If false the view is constrained so only one world is visible, and you cannot pan off the edge. If true the map may show multiple worlds at low zoom levels. Only used if the projection is global. Note that if extent is also provided it is given precedence.
constrainResolutionboolean (defaults to false)If true, the view will always animate to the closest zoom level after an interaction; false means intermediary zoom levels are allowed.
smoothResolutionConstraintboolean (defaults to true)If true, the resolution min/max values will be applied smoothly, i. e. allow the view to exceed slightly the given resolution or zoom bounds.
showFullExtentboolean (defaults to false)Allow the view to be zoomed out to show the full configured extent. By default, when a view is configured with an extent, users will not be able to zoom out so the viewport exceeds the extent in either dimension. This means the full extent may not be visible if the viewport is taller or wider than the aspect ratio of the configured extent. If showFullExtent is true, the user will be able to zoom out so that the viewport exceeds the height or width of the configured extent, but not both, allowing the full extent to be shown.
projectionProjectionLike (defaults to ‘EPSG:3857’)The projection. The default is Spherical Mercator.
resolutionnumberundefinedThe initial resolution for the view. The units are projection units per pixel (e.g. meters per pixel). An alternative to setting this is to set zoom. Layer sources will not be fetched if neither this nor zoom are defined, but they can be set later with #setZoom or #setResolution.
resolutionsArray.undefinedResolutions that determine the zoom levels if specified. The index in the array corresponds to the zoom level, therefore the resolution values have to be in descending order. It also constrains the resolution by the minimum and maximum value. If set the maxResolution, minResolution, minZoom, maxZoom, and zoomFactor options are ignored.
rotationnumber (defaults to 0)The initial rotation for the view in radians (positive rotation clockwise, 0 means North).
zoomnumberundefinedOnly used if resolution is not defined. Zoom level used to calculate the initial resolution for the view.
zoomFactornumber (defaults to 2)The zoom factor used to compute the corresponding resolution.
paddingArray. (defaults to [0, 0, 0, 0])Padding (in css pixels). If the map viewport is partially covered with other content (overlays) along its edges, this setting allows to shift the center of the viewport away from that content. The order of the values is top, right, bottom, left.

翻译

NameTypeDescription
centerCoordinateundefined视图的初始中心。如果没有设置用户投影,中心的坐标系由投影选项指定。如果没有设置,将不会获取图层源,但中心可以在以后用#setCenter来设置。
constrainRotationbooleannumber (defaults to true)旋转约束。false "表示没有约束。true表示没有约束,但在零点附近扣到零。一个数字将旋转限制在该数字的范围内。例如,4将约束旋转到0、90、180和270度。
enableRotationboolean (defaults to true)Enable rotation.如果是 “false”,就会使用一个旋转约束,该约束总是将旋转设置为零。如果enableRotationfalseconstrainRotation选项没有作用。
extentExtentundefined约束视图的范围,换句话说,在这个范围之外的东西都不能在地图上看到。
constrainOnlyCenterboolean (defaults to false)如果为真,范围约束将只适用于视图中心,而不是整个范围。
smoothExtentConstraintboolean (defaults to true)如果为真,范围约束将被平滑地应用,即允许视图稍微超出给定的 “范围”。
maxResolutionnumberundefined用来确定分辨率约束的最大分辨率。它与minResolution(或maxZoom)和zoomFactor一起使用。如果没有指定,它的计算方式是使投影的有效范围适合256x256 px瓦片。如果投影是球面墨卡托(默认),那么maxResolution默认为40075016.68557849 / 256 = 156543.03392804097
minResolutionnumberundefined用来确定分辨率约束的最小分辨率。它与maxResolution(或minZoom)和zoomFactor一起使用。如果没有指定,它的计算是假设29个缩放级别(系数为2)。如果投影是球面墨卡托(默认),那么minResolution默认为40075016.68557849 / 256 / Math.pow(2, 28) = 0.0005831682455839253
maxZoomnumber (defaults to 28)用于确定分辨率约束的最大缩放级别。它与minZoom(或maxResolution)和zoomFactor一起使用。注意,如果还提供了minResolution,它将优先于maxZoom
minZoomnumber (defaults to 0)用于确定分辨率约束的最小缩放级别。它与maxZoom(或minResolution)和zoomFactor一起使用。注意,如果maxResolution'也被提供,它将优先于minZoom’。
multiWorldboolean (defaults to false)如果 “false”,视图会被限制,所以只有一个世界是可见的,而且你不能从边缘平移。如果 “true”,地图在低缩放级别时可以显示多个世界。只在 "投影 "是全局的情况下使用。请注意,如果同时提供extent,它将被优先考虑。
constrainResolutionboolean (defaults to false)如果是true,视图在交互后将总是动画化到最接近的缩放级别;false意味着允许中间的缩放级别。
smoothResolutionConstraintboolean (defaults to true)如果为真,分辨率的最小/最大值将被平滑应用,即允许视图稍微超过给定的分辨率或缩放界限。
showFullExtentboolean (defaults to false)允许视图被放大以显示全部配置的范围。默认情况下,当一个视图被配置为一个范围时,用户将不能放大,使视口在任何一个维度上都超过该范围。这意味着如果视口比配置的范围的长宽比更高或更宽,则可能无法看到整个范围。如果showFullExtent为true,用户就可以放大,使视口超过配置的范围的高度或宽度,但不能同时超过,这样就可以显示完整的范围。
projectionProjectionLike (defaults to ‘EPSG:3857’)投影。默认是球面墨卡托。
resolutionnumberundefined视图的初始分辨率。单位是每像素的投影单位(例如,每像素米)。设置这个的另一个方法是设置zoom'。如果没有定义这个和zoom’,将不会获取图层资源,但可以在以后用#setZoom#setResolution来设置。
resolutionsArray.undefined如果指定的话,决定缩放级别的分辨率。数组中的索引与缩放级别相对应,因此分辨率值必须按降序排列。它还通过最小值和最大值来约束分辨率。如果设置了maxResolution, minResolution, minZoom,maxZoom, 和zoomFactor选项,则忽略不计。
rotationnumber (defaults to 0)视图的初始旋转,单位是弧度(顺时针正向旋转,0表示北)。
zoomnumberundefined只在没有定义resolution时使用。用于计算视图的初始分辨率的缩放级别。
zoomFactornumber (defaults to 2)用来计算相应分辨率的变焦系数。
paddingArray. (defaults to [0, 0, 0, 0])填充(以css像素为单位)。如果地图视口的边缘部分被其他内容(覆盖物)覆盖,这个设置可以使视口的中心远离这些内容。数值的顺序是上、右、下、左。
Fires:
  • change (BaseEvent) - Generic change event. Triggered when the revision counter is increased.通用的改变事件。当修订计数器增加时触发。
  • change:center (ObjectEvent)
  • change:resolution (ObjectEvent)
  • change:rotation (ObjectEvent)
  • error (BaseEvent) - Generic error event. Triggered when an error occurs.通用的错误事件。当一个错误发生时被触发。
  • propertychange (ObjectEvent) - Triggered when a property is changed.当一个属性被改变时触发。

扩展Extends

可观察的属性

[Observable Properties]

NameTypeSettableObjectEvent typeDescription
centerCoordinateundefinedyeschange:center视图中心点
resolutionnumberundefinedyeschange:resolution视图的分辨率。
rotationnumberyeschange:rotation视图的旋转,单位是弧度。

成员 Members

padding

padding{Array.} {undefined}

Padding (in css pixels). If the map viewport is partially covered with other content (overlays) along its edges, this setting allows to shift the center of the viewport away from that content. The order of the values in the array is top, right, bottom, left. The default is no padding, which is equivalent to [0, 0, 0, 0].

填充(以css像素为单位)。如果地图视口的边缘被其他内容(覆盖物)部分覆盖,这个设置可以使视口的中心远离这些内容。数组中的值的顺序是上、右、下、左。默认是没有填充,相当于[0, 0, 0, 0]

方法Methods

adjustCenter

adjustCenter(deltaCoordinates)

Adds relative coordinates to the center of the view. Any extent constraint will apply.

将相对坐标添加到视图的中心。任何范围约束都适用。

NameTypeDescription
deltaCoordinatesCoordinate相对价值的增加。
adjustResolution

adjustResolution(ratio, anchor)

Multiply the view resolution by a ratio, optionally using an anchor. Any resolution constraint will apply.

将视图的分辨率乘以一个比率,可以选择使用一个锚点。任何分辨率的约束都将适用。

NameTypeDescription
rationumber在视图分辨率上应用的比率。
anchorCoordinateundefined转化的起源。
adjustRotation

adjustRotation(delta, anchor)

Adds a value to the view rotation, optionally using an anchor. Any rotation constraint will apply.

为视图的旋转添加一个值,可以选择使用一个锚点。任何旋转约束都将适用。

NameTypeDescription
deltanumber要添加到缩放旋转的相对值,单位是弧度。
anchorCoordinateundefined旋转中心。
adjustZoom

adjustZoom(delta, anchor)

Adds a value to the view zoom level, optionally using an anchor. Any resolution constraint will apply.

为视图缩放级别添加一个值,可以选择使用锚点。任何分辨率的约束都将适用。

NameTypeDescription
deltanumber要添加到缩放级别的相对值。
anchorCoordinateundefined转化的起源。
animate

animate(var_args)

Animate the view. The view’s center, zoom (or resolution), and rotation can be animated for smooth transitions between view states. For example, to animate the view to a new zoom level:

对视图进行动画处理。视图的中心、缩放(或分辨率)和旋转可以用动画来实现视图状态之间的平滑过渡。例如,将视图动画化为一个新的缩放级别:

view.animate({zoom: view.getZoom() + 1});

By default, the animation lasts one second and uses in-and-out easing. You can customize this behavior by including duration (in milliseconds) and easing options (see ol/easing).

默认情况下,动画持续一秒钟,并使用进退式缓和。你可以通过加入duration(以毫秒为单位)和easing选项来定制这一行为(见ol/easing)。

To chain together multiple animations, call the method with multiple animation objects. For example, to first zoom and then pan:

要把多个动画连在一起,就用多个动画对象调用该方法。例如,要先缩放,再平移:

view.animate({zoom: 10}, {center: [0, 0]});

If you provide a function as the last argument to the animate method, it will get called at the end of an animation series. The callback will be called with true if the animation series completed on its own or false if it was cancelled.

如果你提供一个函数作为animate方法的最后一个参数,它将在一个动画系列结束时被调用。如果动画系列自行完成,回调将以true被调用,如果被取消,则以false被调用。

Animations are cancelled by user interactions (e.g. dragging the map) or by calling view.setCenter(), view.setResolution(), or view.setRotation() (or another method that calls one of these).

动画可以通过用户交互(例如拖动地图)或调用view.setCenter(), view.setResolution(), 或view.setRotation()(或其他调用这些方法之一)来取消。

NameTypeDescription
var_argsAnimation options.多个动画可以通过传递多个选项对象来串联运行。要并行地运行多个动画,请多次调用该方法。可以提供一个可选的回调作为最终参数。该回调将被调用,并带有一个布尔值,指示动画是否完成而没有被取消。

Animation options.

NameTypeDescription
centerCoordinateundefined动画结束时的视图中心。
zoomnumberundefined动画结束时视图的缩放级别。这比 "分辨率 "优先。
resolutionnumberundefined动画结束时视图的分辨率。如果同时提供zoom,这个选项将被忽略。
rotationnumberundefined动画结束时视图的旋转。
anchorCoordinateundefined可选的锚点,在旋转或分辨率动画中保持固定。
durationnumber (defaults to 1000)动画的持续时间,单位是毫秒。
easingfunctionundefined动画中使用的缓和函数(默认为inAndOut)。该函数将在每一帧被调用,数字代表动画持续时间的一部分。该函数应该返回一个介于0和1之间的数字,代表向目标状态的进展。
beginInteraction()

Notify the View that an interaction has started. The view state will be resolved to a stable one if needed (depending on its constraints).

通知视图,一个交互已经开始。如果需要的话,视图状态将被解析为一个稳定的状态(取决于其约束)。

calculateExtent

calculateExtent(size){Extent}

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().

计算当前视图状态下的范围和传递的大小。大小是计算出的范围应该适合的盒子的像素尺寸。在大多数情况下,你想得到整个地图的范围,也就是map.getSize()

NameTypeDescription
sizeSizeundefined箱子的像素大小。如果不提供,将使用使用该视图的地图的尺寸。
cancelAnimations()

Cancel any ongoing animations.取消任何正在运行的动画。

centerOn

centerOn(coordinate, size, position)

Center on coordinate and view position.

以坐标和视图位置为中心。

NameTypeDescription
coordinateCoordinateCoordinate.
sizeSizeBox pixel size.箱体像素大小。
positionPixel在视图上的位置,以其为中心。
changed

changed() [inherited](

Increases the revision counter and dispatches a ‘change’ event.

增加修订版计数器并发送一个 "更改 "事件。

dispatchEvent

dispatchEvent(event){boolean | undefined} inherited

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.

派遣一个事件并调用所有监听此类型事件的监听器。事件参数可以是一个字符串,也可以是一个带有type属性的对象。

NameTypeDescription
eventBaseEventstringEvent object.
  • Returns:

false if anyone called preventDefault on the event object or if any of the listeners returned false.

如果有人在事件对象上调用preventDefault,或者有任何监听器返回错误,则为 “false”。

endInteraction

endInteraction(duration, resolutionDirection, anchor)

Notify the View that an interaction has ended. The view state will be resolved to a stable one if needed (depending on its constraints).

通知视图,一个交互已经结束。如果需要的话,视图状态将被解析为一个稳定的状态(取决于其约束)。

NameTypeDescription
durationnumberundefined动画持续时间,单位为ms。
resolutionDirectionnumberundefined哪一个方向可以放大。
anchorCoordinateundefined转化的起源。
fit

fit(geometryOrExtent, options)

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.

根据给定的地图尺寸和边框,拟合给定的几何体或范围。尺寸是拟合范围的像素尺寸。在大多数情况下,你想使用地图尺寸,即map.getSize()。处理地图的角度问题。

NameTypeDescription
geometryOrExtentSimpleGeometryExtentThe geometry or extent to fit the view to.
optionsOptions.

Options

NameTypeDescription
sizeSizeundefined框的大小,以像素为单位,以适应范围。默认是DOM中第一个使用此视图的地图的当前大小,如果没有找到这样的地图,则为[100, 100]
paddingArray. (defaults to [0, 0, 0, 0])视图内部要清除的padding(单位:像素)。数组中的值是顶部、右侧、底部和左侧的padding。
nearestboolean (defaults to false)如果视图的 "constrainResolution "选项为 “true”,则获得最近的范围,而不是实际适合该视图的最近的。
minResolutionnumber (defaults to 0)我们放大到的最小分辨率。
maxZoomnumberundefined我们放大到的最大的缩放级别。如果给了minResolution,这个属性就会被忽略。
durationnumberundefined动画的持续时间,单位是毫秒。默认情况下,在目标范围内没有动画。
easingfunctionundefined动画中使用的缓和函数(默认为inAndOut)。该函数将在每一帧被调用,数字代表动画持续时间的一部分。该函数应该返回一个介于0和1之间的数字,代表向目标状态的进展。
callbackfunctionundefined当视图处于其最终位置时调用的函数。如果动画系列自行完成,回调将以true调用,如果被取消,则以false调用。
get(key)

get(key){*} inherited

Gets a value.

获取一个值。

NameTypeDescription
keystringKey name.
  • Returns:

Value.

getAnimating

getAnimating(){boolean}

Determine if the view is being animated.

确定视图是否正在被动画化。

  • Returns:

The view is being animated.

视图正在被动画化。

getCenter

getCenter(){Coordinate | undefined}

Get the view center.

获取视图中心。

  • Returns:

The center of the view.

景观的中心。

getInteracting(){boolean}

getInteracting(){boolean}

Determine if the user is interacting with the view, such as panning or zooming.

确定用户是否在与视图进行互动,如平移或缩放。

  • Returns:

The view is being interacted with.

视图正在被交互使用。

getKeys

getKeys(){Array.} inherited

Get a list of object property names.

获取一个对象属性名称的列表。

  • Returns:

List of property names.

对象属性名称的列表。

getMaxResolution

getMaxResolution(){number}

Get the maximum resolution of the view.

获取视图的最大分辨率。

  • Returns:

The maximum resolution of the view.

视图的最大分辨率。

getMaxZoom(){number}

Get the maximum zoom level for the view.

获得该视图的最大缩放级别。

  • Returns:

The maximum zoom level.

最大的缩放级别。

getMinResolution

getMinResolution(){number}。

Get the minimum resolution of the view.

获取视图的最小分辨率。

  • Returns:

The minimum resolution of the view.

视图的最小分辨率。

getMinZoom

getMinZoom(){number}

Get the minimum zoom level for the view.

获取该视图的最小缩放级别。

  • Returns:

The minimum zoom level.

最小的缩放级别。

getProjection

getProjection(){Projection}

Get the view projection.

获取视图投影。

  • Returns:

The projection of the view.

视图的投影。

getProperties

getProperties(){Object.<string, *>} inherited

Get an object of all property names and values.

获取一个所有属性名称和值的对象。

  • Returns:

Object.获取一个所有属性名称和值的对象。

getResolution

getResolution(){number | undefined}

Get the view resolution.

获取视图分辨率。

  • Returns:

The resolution of the view.

视图的分辨率。

getResolutionForExtent

getResolutionForExtent(extent, size){number}

Get the resolution for a provided extent (in map units) and size (in pixels).

获取所提供的范围(以地图单位)和大小(以像素为单位)的分辨率。

NameTypeDescription
extentExtent范围。
sizeSizeundefined箱体像素大小。
  • Returns:

The resolution at which the provided extent will render at the given size.

所提供的范围将在给定的尺寸下呈现的分辨率。

getResolutionForZoom

getResolutionForZoom(zoom){number}

Get the resolution for a zoom level.

获取一个缩放级别的分辨率。

NameTypeDescription
zoomnumberZoom level.缩放级别
  • Returns:

The view resolution for the provided zoom level.

所提供的缩放级别的视图分辨率。

getResolutions

getResolutions(){Array. | undefined}

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

获取该视图的分辨率。这将返回传递给视图构造函数的决议数组,如果没有给出,则返回未定义的决议数组。

  • Returns:

The resolutions of the view.

观点的决议。

getRevision

getRevision(){number} inherited

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

获取此对象的版本号。每当该对象被修改时,它的版本号将被递增。

  • Returns:

Revision. 修订版本号

getRotation

getRotation(){number}

Get the view rotation.

获取视图旋转。

  • Returns:

The rotation of the view in radians.视图的旋转,单位是弧度。

getZoom

getZoom(){number | undefined}

Get the current zoom level. This method may return non-integer zoom levels if the view does not constrain the resolution, or if an interaction or animation is underway.

获取当前的缩放级别。如果视图不限制分辨率,或者正在进行交互或动画,该方法可能返回非整数的缩放级别。

  • Returns:

Zoom.当前的缩放级别。

getZoomForResolution

getZoomForResolution(resolution){number | undefined}

Get the zoom level for a resolution.获取一个分辨率的缩放级别。

NameTypeDescription
resolutionnumberThe resolution.分别率
  • Returns:

The zoom level for the provided resolution.

提供的分辨率的缩放级别。

on(type, listener)

on(type, listener){EventsKey | Array< EventsKey >} inherited

Listen for a certain type of event.听取某种类型的事件。

NameTypeDescription
typestringArray.事件类型或事件类型的数组。
listenerfunction听众功能。
  • Returns:

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.

倾听者的唯一键。如果用一个事件类型的数组作为第一个参数来调用,返回将是一个键的数组。

once

once(type, listener){EventsKey | Array[EventsKey]()} inherited

Listen once for a certain type of event.

对某一类型的事件听一次。

NameTypeDescription
typestringArray.事件类型或事件类型的数组。
listenerfunction回调函数
  • Returns:

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.

倾听者的唯一键。如果用一个事件类型的数组作为第一个参数来调用,返回将是一个键的数组。

set(key, value, silent) inherited

set(key, value, silent) inherited

Sets a value.设置一个值。

NameTypeDescription
keystringKey name.
value*Value.
silentbooleanundefined更新而不触发一个事件。
setCenter(center)

Set the center of the current view. Any extent constraint will apply.

设置当前视图的中心。任何程度的约束都将适用。

NameTypeDescription
centerCoordinateundefined视图的中心。
setConstrainResolution

setConstrainResolution(enabled)

Set whether the view should allow intermediary zoom levels.

设置视图是否应该允许中间的缩放级别。

NameTypeDescription
enabledboolean分辨率是否受到限制。
setMaxZoom

setMaxZoom(zoom)

Set a new maximum zoom level for the view.为视图设置一个新的最大缩放级别。

NameTypeDescription
zoomnumber最大的缩放级别。
setMinZoom

setMinZoom(zoom)

Set a new minimum zoom level for the view.

为视图设置一个新的最小缩放级别。

NameTypeDescription
zoomnumber最小的缩放级别。
setProperties

setProperties(values, silent) inherited

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

设置一个键值对的集合。注意,这将改变任何现有的属性并添加新的属性(它不会删除任何现有的属性)。

NameTypeDescription
valuesObject.<string, *>Values.
silentbooleanundefined更新而不触发一个事件。
setResolution

setResolution(resolution)

Set the resolution for this view. Any resolution constraint will apply.

设置该视图的分辨率。任何分辨率的约束都将适用。

NameTypeDescription
resolutionnumberundefined视图的分辨率。
setRotation

setRotation(rotation)

Set the rotation for this view. Any rotation constraint will apply.

设置该视图的旋转。任何旋转约束都将适用。

NameTypeDescription
rotationnumber视图的旋转,单位是弧度。
setZoom(zoom)

setZoom(zoom)

Zoom to a specific zoom level. Any resolution constrain will apply.

缩放到一个特定的缩放级别。任何分辨率的限制都将适用。

NameTypeDescription
zoomnumber缩放级别。任
un

un(type, listener) inherited

Unlisten for a certain type of event.

为某种类型的事件取消收听。

NameTypeDescription
typestringArray.事件类型或事件类型的数组。
listenerfunction回调事件
unset

unset(key, silent) inherited

Unsets a property.

取消设置一个属性。

NameTypeDescription
keystringKey name.
silentbooleanundefined在不触发事件的情况下取消设置。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值