OpenLayers Api 中文文档 1Map

OpenLayers Api Doc

Map

ol/Map

import Map from 'ol/Map.js';

The map is the core component of OpenLayers. For a map to render, a view, one or more layers, and a target container are needed:

地图是OpenLayers的核心组件。为了渲染地图,需要一个视图、一个或多个图层和一个目标容器:

import Map from 'ol/Map.js';               	//地图
import View from 'ol/View.js';				//视图
import TileLayer from 'ol/layer/Tile.js';	//图层
import OSM from 'ol/source/OSM.js';			//目标容器

const map = new Map({
  view: new View({
    center: [0, 0],	// 中心点
    zoom: 1,		// 缩放比例
  }),
  layers: [			//图层
    new TileLayer({
      source: new OSM(),// OSM数据
    }),
  ],
  target: 'map',
});

The above snippet creates a map using a TileLayer to display OSM OSM data and render it to a DOM element with the id map.

上面的片段使用TileLayer创建了一个地图,以显示OSMOSM数据,并将其渲染为id为map的DOM元素。

The constructor places a viewport container (with CSS class name ol-viewport) in the target element (see getViewport()), and then two further elements within the viewport: one with CSS class name ol-overlaycontainer-stopevent for controls and some overlays, and one with CSS class name ol-overlaycontainer for other overlays (see the stopEvent option of Overlay for the difference). The map itself is placed in a further element within the viewport.

构造函数在目标元素中放置一个视口容器(CSS类名为ol-viewport)(见getViewport()),然后在视口中再放置两个元素:一个CSS类名为ol-overlaycontainer-stopevent,用于控件controls 和一些覆盖overlays,另一个CSS类名为ol-overlaycontainer,用于其他覆盖overlays(区别见OverlaystopEvent选项)。地图本身被放置在视口内的另一个元素中。

Layers are stored as a Collection in layerGroups. A top-level group is provided by the library. This is what is accessed by getLayerGroup and setLayerGroup. Layers entered in the options are added to this group, and addLayer and removeLayer change the layer collection in the group. getLayers is a convenience function for getLayerGroup().getLayers(). Note that LayerGroup is a subclass of BaseLayer, so layers entered in the options or added with addLayer can be groups, which can contain further groups, and so on.

图层以Collection的形式存储在layerGroups中。一个顶级的组由库提供。这是由getLayerGroupsetLayerGroup访问的。在选项中输入的图层被添加到这个组中,addLayerremoveLayer改变组中的图层集合。getLayersgetLayerGroup().getLayers()的一个便利函数。注意,LayerGroupBaseLayer的子类,所以在选项中输入的图层或用addLayer添加的图层可以是组,组中可以包含进一步的组,以此类推。

实例化Map的options选项new Map(options)

controls
  • Type

Collection< Control>

Array< Control>

undefined

  • Description

Controls initially added to the map. If not specified, defaults is used.

最初添加到地图上的控件。如果没有指定,则使用默认值。

pixelRatio
  • Type

number (defaults to window.devicePixelRatio)

数字(默认为window.devicePixelRatio)。

  • Description

设备上的物理像素和与设备无关的像素(凹点)之间的比率。

interactions
  • Type

Collection< Interaction >

Array (Interaction)

undefined

  • Description

最初被添加到地图上的互动关系。如果没有指定,则使用默认值。

keyboardEventTarget
  • Type

HTMLElement | Document | string | undefined

  • Description

The element to listen to keyboard events on. This determines when the KeyboardPan and KeyboardZoom interactions trigger. For example, if this option is set to document the keyboard interactions will always trigger. If this option is not specified, the element the library listens to keyboard events on is the map target (i.e. the user-provided div for the map). If this is not document, the target element needs to be focused for key events to be emitted, requiring that the target element has a tabindex attribute.

聆听键盘事件的元素。这决定了KeyboardPan和KeyboardZoom交互的触发时间。例如,如果这个选项被设置为文档,那么键盘交互将总是被触发。如果没有指定这个选项,库监听键盘事件的元素是地图目标(即用户为地图提供的div)。如果这不是文档,目标元素需要被聚焦才能发出键盘事件,要求目标元素有一个tabindex属性。

layers
  • Type

Array< BaseLayer > |

< BaseLayer > |

LayerGroup |

undefined

  • Description

Layers. If this is not defined, a map with no layers will be rendered. Note that layers are rendered in the order supplied, so if you want, for example, a vector layer to appear on top of a tile layer, it must come after the tile layer.

图层。如果没有定义,就会渲染出一个没有图层的地图。请注意,图层是按照提供的顺序渲染的,所以如果你想让一个矢量图层出现在一个瓦片图层之上,它必须在瓦片图层之后出现。

maxTilesLoading
  • Type

number (defaults to 16)

  • Description

Maximum number tiles to load simultaneously.

同时加载的最大瓦片数。

moveTolerance
  • Type

number (defaults to 1)

  • Description

The minimum distance in pixels the cursor must move to be detected as a map move event instead of a click. Increasing this value can make it easier to click on the map.

光标必须移动的最小距离(像素),以便被检测为地图移动事件而不是点击。增加这个值可以使地图上的点击更容易。

overlays
  • Type

Collection< Overlay > | Array< Overlay > | undefined

  • Description

Overlays initially added to the map. By default, no overlays are added.

最初添加到地图上的覆盖层。默认情况下,不添加覆盖物。

target
  • Type

HTMLElement | string | undefined

  • Description

地图的容器,可以是元素本身或元素的id。如果在构建时没有指定,必须调用setTarget来渲染地图。如果通过元素传递,容器可以是在一个二级文档中。注意:对目标元素的CSS变换支持只限于缩放。

view
  • Type

View | Promise< ViewOptions > | undefined

  • Description

The map’s view. No layer sources will be fetched unless this is specified at construction time or through setView.

地图的视图。除非在构造时或通过setView指定,否则不会获取图层源。

NameTypeDescription
controls Collection< Control>|Array< Control>|undefined最初添加到地图上的控件。如果没有指定,则使用默认值。
pixelRationumber(默认为window.devicePixelRatio)设备上的物理像素和与设备无关的像素(凹点)之间的比率
interactions Collection< Interaction >|Array (Interaction)|undefined最初被添加到地图上的互动关系。如果没有指定,则使用默认值。
keyboardEventTargetHTMLElement |Document |string |undefined聆听键盘事件的元素。这决定了KeyboardPan和KeyboardZoom交互的触发时间。
layersArray< BaseLayer >|Collection < BaseLayer > | LayerGroup |undefined图层。如果没有定义,就会渲染出一个没有图层的地图。请注意,图层是按照提供的顺序渲染的,所以如果你想让一个矢量图层出现在一个瓦片图层之上,它必须在瓦片图层之后出现。
maxTilesLoadingnumber (defaults to 16)同时加载的最大瓦片数。
moveTolerancenumber (defaults to 1)光标必须移动的最小距离(像素),以便被检测为地图移动事件而不是点击。增加这个值可以使地图上的点击更容易。
overlaysCollection< Overlay > |Array< Overlay > |undefined最初添加到地图上的覆盖层。默认情况下,不添加覆盖物。
targetHTMLElement | string |undefined地图的容器,可以是元素本身或元素的id。如果在构建时没有指定,必须调用setTarget来渲染地图。如果通过元素传递,容器可以是在一个二级文档中。注意:对目标元素的CSS变换支持只限于缩放。
view View | Promise< ViewOptions > | undefined地图的视图。除非在构造时或通过setView指定,否则不会获取图层源。

事件Fires

  • change (BaseEvent) - Generic change event. Triggered when the revision counter is increased.通用的改变事件。当修订计数器增加时触发。
  • change:layerGroup (ObjectEvent)
  • change:size (ObjectEvent)
  • change:target (ObjectEvent)
  • change:view (ObjectEvent)
  • click (MapBrowserEvent) - A click with no dragging. A double click will fire two of this.一个没有拖动的点击。双击会引发两个这样的事件。
  • dblclick (MapBrowserEvent) - A true double click, with no dragging.一个真正的双击,没有拖动。
  • error (BaseEvent) - Generic error event. Triggered when an error occurs.通用的错误事件。当一个错误发生时触发。
  • loadend (MapEvent) - Triggered when loading of additional map data has completed.当加载额外的地图数据完成后触发的事件。
  • loadstart (MapEvent) - Triggered when loading of additional map data (tiles, images, features) starts.当开始加载额外的地图数据(瓦片、图像、特征)时触发。
  • moveend (MapEvent) - Triggered after the map is moved.在地图被移动后触发。
  • movestart (MapEvent) - Triggered when the map starts moving.当地图开始移动时触发。
  • pointerdrag (MapBrowserEvent) - Triggered when a pointer is dragged.指针被拖动时触发。
  • pointermove (MapBrowserEvent) - Triggered when a pointer is moved. Note that on touch devices this is triggered when the map is panned, so is not the same as mousemove.指针被移动时触发。注意,在触摸设备上,当地图被平移时触发,所以与mousemove不一样。
  • postcompose (RenderEvent) - Triggered after layers are composed. When dispatched by the map, the event object will not have a context set. When dispatched by a layer, the event object will have a context set. Only WebGL layers currently dispatch this event.在图层组成后被触发。当由地图派发时,事件对象将没有上下文设置。当由图层派发时,事件对象将有一个上下文设置。目前只有WebGL图层派发了这个事件。
  • postrender (MapEvent) - Triggered after a map frame is rendered.在地图帧被渲染后触发。
  • precompose (RenderEvent) - Triggered before layers are composed. When dispatched by the map, the event object will not have a context set. When dispatched by a layer, the event object will have a context set. Only WebGL layers currently dispatch this event.在图层组成之前被触发。当由地图派发时,事件对象将没有一个上下文设置。当由图层派发时,事件对象将有一个上下文设置。目前只有WebGL图层派发了这个事件。
  • propertychange (ObjectEvent) - Triggered when a property is changed.当一个属性被改变时触发。
  • rendercomplete (RenderEvent) - Triggered when rendering is complete, i.e. all sources and tiles have finished loading for the current viewport, and all tiles are faded in. The event object will not have a context set.渲染完成后触发,即当前视口的所有源和瓦片都加载完毕,所有瓦片都淡入。该事件对象将不会有一个上下文设置。
  • singleclick (MapBrowserEvent) - A true single click with no dragging and no double click. Note that this event is delayed by 250 ms to ensure that it is not a double click.一个真正的单次点击,没有拖动,没有双击。请注意,这个事件被延迟了250毫秒,以确保它不是一个双击。

拓展Extends

可观察的属性Observable Properties

NameTypeSettable可结算ObjectEvent type对象事件类型Description描述翻译
layerGroupLayerGroupyeschange:layergroupA layer group containing the layers in this map.一个包含该地图中各层的图层组。
sizeSize | undefinedyeschange:sizeThe size in pixels of the map in the DOM.DOM中地图的尺寸,以像素为单位。
targetHTMLElement | string | undefinedyeschange:targetThe Element or id of the Element that the map is rendered in.渲染地图的元素或元素的id。
viewViewyeschange:viewThe view that controls this map.控制该地图的视图。

方法Methods

addControl(control)

将给定的控件添加到地图上。

参数

NameTypeDescription
controlControlControl.
addInteraction(interaction)

Add the given interaction to the map. If you want to add an interaction at another point of the collection use getInteractions() and the methods available on Collection. This can be used to stop the event propagation from the handleEvent function. The interactions get to handle the events in the reverse order of this collection.

将给定的交互添加到地图上。如果你想在集合的另一点添加一个交互,请使用getInteractions()和Collection上可用的方法。这可以用来停止来自handleEvent函数的事件传播。交互以这个集合的相反顺序得到处理事件。

参数

NameTypeDescription
interactionInteractionInteraction to add.
addLayer(layer)

Adds the given layer to the top of this map. If you want to add a layer elsewhere in the stack, use getLayers() and the methods available on Collection.

将给定的图层添加到该地图的顶部。如果你想在堆栈的其他地方添加一个图层,可以使用getLayers()和Collection上的方法。

参数

NameTypeDescription
layerBaseLayerLayer
addOverlay(overlay)

Add the given overlay to the map.

在地图上添加给定的覆盖层。

参数

NameTypeDescription
overlayOverlayOverlay.
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.

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

参数

NameTypeDescription
eventBaseEvent | stringEvent object.

返回值 Returns:

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

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

forEachFeatureAtPixel

forEachFeatureAtPixel(pixel, callback, options){T | undefined}

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.

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

参数

NameTypeDescription
pixelPixel像素。
callbackfunction特征回调。该回调将被调用,有两个参数。第一个参数是像素处的一个featurerender feature,第二个参数是该特征的layer,对于未管理的层,将为空。为了停止检测,回调函数可以返回一个真值。
optionsOptional options.见下表

Optional options.

NameTypeDescription
layerFilterundefined | function层过滤功能。过滤函数将收到一个参数,即layer-candidate,它应该返回一个布尔值。只有可见且该函数返回 "true "的图层才会被测试出特征。默认情况下,所有可见图层都将被测试。
hitTolerancenumber (defaults to 0)以css像素为单位的命中检测公差。在给定位置周围半径内的像素将被检查出特征。
checkWrappedboolean (defaults to true)Check-Wrapped 将检查+/-1世界宽度范围内的包裹的几何图形。只有在使用可以被包裹的投影时才会起作用。

返回值 Returns:

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

回调结果,即最后一次回调执行的返回值,或第一个真实的回调返回值。

get(key)

get(key){*} inherited

Gets a value.

获取一个值。

NameTypeDescription
keystring关键名称。
  • Returns:

Value.

getAllLayers()

getAllLayers(){Array< Layer >}

Get all layers from all layer groups.

从所有图层组中获取所有图层。

  • Returns:

Layers.

层数。

getControls()

getControls(){Collection< Control >}

Get the map controls. Modifying this collection changes the controls associated with the map.

获取地图控件。修改这个集合可以改变与地图相关的控件。

  • Returns:

Controls.

控制。

getCoordinateFromPixel(pixel)

getCoordinateFromPixel(pixel){Coordinate}

Get the coordinate for a given pixel. This returns a coordinate in the user projection.

NameTypeDescription
pixelPixel地图视口中的像素位置。
  • Returns:

The coordinate for the pixel position.

像素位置的坐标。

getEventCoordinate

getEventCoordinate(event){Coordinate}

Returns the coordinate in user projection for a browser event.

返回一个浏览器事件的用户投影坐标。

NameTypeDescription
eventMouseEventEvent.
  • Returns:

Coordinate

协调坐标。

getEventPixel(event){Pixel}

getEventPixel(event){Pixel}

Returns the map pixel position for a browser event relative to the viewport.

返回一个浏览器事件相对于视口的地图像素位置。

NameTypeDescription
eventUIEvent | ObjectEvent.
  • Returns:

Pixel.

像素。

getFeaturesAtPixel

getFeaturesAtPixel(pixel, options){Array<FeatureLike>}

Get all features that intersect a pixel on the viewport.

获取视口上与一个像素相交的所有特征。

NameTypeDescription
pixelPixelPixel.
optionsOptional options.见下表

Optional options.

NameTypeDescription
layerFilterundefined | function层过滤功能。过滤函数将收到一个参数,即layer-candidate,它应该返回一个布尔值。只有可见且该函数返回 "true "的图层才会被测试出特征。默认情况下,所有可见图层都将被测试。
hitTolerancenumber (defaults to 0)以css像素为单位的命中检测公差。在给定位置周围半径内的像素将被检查出特征。
checkWrappedboolean (defaults to true)Check-Wrapped 将检查+/-1世界宽度范围内的包裹的几何图形。只有在使用可以被包裹的投影时才会起作用。
  • Returns:

The detected features or an empty array if none were found.

检测到的特征,如果没有发现,则为空数组。

getInteractions()

getInteractions(){Collection<Interaction>}

Get the map interactions. Modifying this collection changes the interactions associated with the map.

获取地图的交互。修改这个集合会改变与地图相关的交互。

Interactions are used for e.g. pan, zoom and rotate.

交互用于例如平移、缩放和旋转。

  • Returns:

Interactions.

交互作用

getKeys()

getKeys(){Array.} [inherited]

Get a list of object property names.

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

  • Returns:

List of property names.controls

属性名称列表。

getLayerGroup()

getLayerGroup(){LayerGroup}

Get the layergroup associated with this map.

获取与该地图相关的图层组。

  • Returns:

A layer group containing the layers in this map.

一个包含该地图中各层的图层组。

getLayers()

getLayers(){Collection<BaseLayer>}

Get the collection of layers associated with this map.

获取与该地图相关的图层集合。

  • Returns:

Layers.

层数。

getOverlayById

getOverlayById(id){Overlay}

Get an overlay by its identifier (the value returned by overlay.getId()). Note that the index treats string and numeric identifiers as the same. So map.getOverlayById(2) will return an overlay with id '2' or 2.

通过标识符(overlay.getId()返回的值)获取一个覆盖层。注意,索引对字符串和数字标识符的处理是一样的。所以map.getOverlayById(2)会返回一个id为'2'的覆盖层或者2`。

NameTypeDescription
idstring | numberOverlay identifier.覆盖的标识符。
  • Returns:

Overlay.覆盖层.

getOverlays

getOverlays(){Collection<Overlay>}

Get the map overlays. Modifying this collection changes the overlays associated with the map.

获取地图的覆盖层。修改这个集合可以改变与地图相关的覆盖层。

  • Returns:

Overlays.

覆盖物。

getPixelFromCoordinate

getPixelFromCoordinate(coordinate){Pixel}

Get the pixel for a coordinate. This takes a coordinate in the user projection and returns the corresponding pixel.

获取一个坐标的像素。这需要一个用户投影中的坐标并返回相应的像素。

NameTypeDescription
coordinateCoordinate一个地图坐标。
  • Returns:

A pixel position in the map viewport.

地图视口中的一个像素位置。

getProperties

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

Get an object of all property names and values.

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

  • Returns:

Object.

对象

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.修订。

getSize()

getSize(){Size | undefined}

Get the size of this map.

获取该地图的大小。

  • Returns:

The size in pixels of the map in the DOM.

DOM中地图的尺寸,以像素为单位。

getTarget

getTarget(){HTMLElement | string | undefined}

Get the target in which this map is rendered. Note that this returns what is entered as an option or in setTarget: if that was an element, it returns an element; if a string, it returns that.

获取渲染该地图的目标。注意,这将返回作为选项或在setTarget中输入的内容:如果是一个元素,它将返回一个元素;如果是一个字符串,它将返回该元素。

  • Returns:

The Element or id of the Element that the map is rendered in.

渲染地图的元素或元素的id。

getTargetElement

getTargetElement(){HTMLElement}

Get the DOM element into which this map is rendered. In contrast to getTarget this method always return an Element, or null if the map has no target.

获取该地图所渲染的DOM元素。与getTarget'相反,该方法总是返回一个Element’,如果地图没有目标,则返回null

  • Returns:

The element that the map is rendered in.

地图被渲染的元素。

getView

getView(){View}

Get the view associated with this map. A view manages properties such as center and resolution.

获取与该地图相关的视图。视图管理着诸如中心和分辨率等属性。

  • Returns:

The view that controls this map.

控制该地图的视图。

getViewport

getViewport(){HTMLElement}

Get the element that serves as the map viewport.

获取作为地图视口的元素。

  • Returns:

Viewport.视口。

hasFeatureAtPixel

hasFeatureAtPixel(pixel, options){boolean}

Detect if features intersect a pixel on the viewport. Layers included in the detection can be configured through the layerFilter option.

检测特征是否与视口上的像素相交。检测中包含的图层可以通过layerFilter选项进行配置。

NameTypeDescription
pixelPixel像素
optionsOptional options.见下表

Optional options.

NameTypeDescription
layerFilterundefined | functionLayer filter function. The filter function will receive one argument, the layer-candidate and it should return a boolean value. Only layers which are visible and for which this function returns true will be tested for features. By default, all visible layers will be tested.
hitTolerancenumber (defaults to 0)Hit-detection tolerance in css pixels. Pixels inside the radius around the given position will be checked for features.
checkWrappedboolean (defaults to true)Check-Wrapped Will check for wrapped geometries inside the range of +/- 1 world width. Works only if a projection is used that can be wrapped.
  • Returns:

Is there a feature at the given pixel?

在给定的像素处是否有一个特征?

on

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

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

NameTypeDescription
typestring | Array.事件类型或事件类型的阵列。
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
typestring | Array.事件类型或事件类型的数组。
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.

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

removeControl

removeControl(control){Control | undefined}

Remove the given control from the map.

从地图上删除给定的控件。

NameTypeDescription
controlControlControl.
  • Returns:

The removed control (or undefined if the control was not found).

被删除的控件(如果没有找到该控件,则未定义)。

removeInteraction

removeInteraction(interaction){Interaction | undefined}https://github.com/openlayers/openlayers/blob/v7.3.0/src/ol/Map.js#L1477)

Remove the given interaction from the map.

从地图上删除给定的交互对象。

NameTypeDescription
interactionInteraction移除的交互对象。
  • Returns:

The removed interaction (or undefined if the interaction was not found).

被删除的交互对象(如果没有找到交互对象,则未定义)。

removeLayer

removeLayer(layer){BaseLayer | undefined}

Removes the given layer from the map.

从地图上删除给定的图层。

NameTypeDescription
layerBaseLayerLayer.
  • Returns:

The removed layer (or undefined if the layer was not found).

被移除的层(如果没有找到该层,则未定义)。

removeOverlay

removeOverlay(overlay){Overlay | undefined}

Remove the given overlay from the map.

从地图上删除给定的覆盖层。

NameTypeDescription
overlayOverlayOverlay.
  • Returns:

The removed overlay (or undefined if the overlay was not found).移除的覆盖层(如果没有找到覆盖层,则未定义)。

render()

Request a map rendering (at the next animation frame).

要求进行地图渲染(在下一个动画帧)。

renderSync()

Requests an immediate render in a synchronous manner.

要求以同步的方式立即渲染。

set

set(key, value, silent) inherited

Sets a value.设置一个值。

NameTypeDescription
keystringKey name.关键名称。
value*Value.
silentboolean | undefinedUpdate without triggering an event.更新而不触发一个事件。
setLayerGroup

setLayerGroup(layerGroup)

Sets the layergroup of this map.

设置该地图的图层组。

NameTypeDescription
layerGroupLayerGroup一个包含该地图中各层的图层组。
setLayers(layers)

Clear any existing layers and add layers to the map.

清除任何现有图层,并向地图添加图层。

NameTypeDescription
layersArray< BaseLayer > | Collection< BaseLayer >要添加到地图上的图层。
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.
silentboolean | undefined更新而不触发一个事件。
setSize(size)

Set the size of this map.

设置该地图的大小。

NameTypeDescription
sizeSize | undefinedDOM中地图的尺寸,以像素为单位。
setTarget

setTarget(target)

Set the target element to render this map into.设置目标元素来渲染这个地图。

NameTypeDescription
targetHTMLElement | string | undefined渲染地图的元素或元素的id。
setView(view)

Set the view for this map.设置该地图的视图。

NameTypeDescription
viewView | Promise< ViewOptions >控制这个地图的视图。也可以传递一个承诺,该承诺可解析为构建视图的选项。这种方式允许视图属性被源或其他加载视图相关元数据的组件解析。
un

un(type, listener) inherited

Unlisten for a certain type of event.为某种类型的事件取消收听。

NameTypeDescription
typestring | Array.事件类型或事件类型的数组。
listenerfunction响应该事件的回调函数。
unset

unset(key, silent) inherited

Unsets a property.取消设置一个属性。

NameTypeDescription
keystringKey name.
silentboolean | undefined在不触发事件的情况下取消设置。
updateSize()

Force a recalculation of the map viewport size. This should be called when third-party code changes the size of the map viewport.

强制重新计算地图视口的大小。当第三方代码改变地图视口的大小时,应该调用这个功能。

AtPixelOptions{Object}
  • Properties:
NameTypeArgumentDefaultDescription
layerFilterundefined | function层过滤功能。过滤函数将收到一个参数,即layer-candidate,它应该返回一个布尔值。只有可见且该函数返回 "true "的图层才会被测试出特征。默认情况下,所有可见图层都将被测试。
hitTolerancenumber0以css像素为单位的命中检测公差。在给定位置周围半径内的像素将被检查出特征。
checkWrappedbooleantrueCheck-Wrapped 将检查+/-1世界宽度范围内的包裹的几何图形。只有在使用可以被包裹的投影时才会起作用。
FrameState{Object}

State of the current frame. Only pixelRatio, time and viewState should be used in applications.

  • Properties:
NameTypeDescription
pixelRationumber画面的像素比。
timenumber要求渲染该帧的时间。
viewStateState当前视图的状态。
animateboolean动画。
coordinateToPixelTransformTransform坐标到像素的转换。
declutterTreemodule:rbushDeclutterTree.整理树
extentnull | Extent范围。
nextExtentExtent 可选在一个动画系列中的下一个程度。
indexnumber索引。
layerStatesArrayArray< State >图层状态数组
layerIndexnumber图层索引。
pixelToCoordinateTransformTransform像素到坐标的转换。
postRenderFunctionsArray< PostRenderFunction >渲染后的功能。
sizeSize大小
tileQueueTileQueue瓦片队列。
usedTilesObject.<string, Object.<string, boolean>>使用的瓦片。
viewHintsArray.查看提示
wantedTilesObject.<string, Object.<string, boolean>>WantedTiles.想要的瓦派你
mapIdstring地图的ID。
renderTargetsObject.<string, boolean>先前呈现的元素的标识符。
  • 6
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值