Map类
参数:
Name | Type | Description |
---|---|---|
controls | Collection<Control> | Array<Control> | undefined | Controls initially added to the map. If not specified, |
pixelRatio | number (defaults to window.devicePixelRatio) | The ratio between physical pixels and device-independent pixels (dips) on the device. |
interactions | Collection<Interaction> | Array<Interaction> | undefined | Interactions that are initially added to the map. If not specified, |
keyboardEventTarget | HTMLElement | Document | string | undefined | The element to listen to keyboard events on. This determines when the |
layers | Array<BaseLayer> | Collection<BaseLayer> | LayerGroup | undefined | 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 | number (defaults to 16) | Maximum number tiles to load simultaneously. |
moveTolerance | number (defaults to 1) | 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 | Collection<Overlay> | Array<Overlay> | undefined | Overlays initially added to the map. By default, no overlays are added. |
target | HTMLElement | string | undefined | The container for the map, either the element itself or the |
view | View | Promise<ViewOptions> | undefined | The map's view. No layer sources will be fetched unless this is specified at construction time or through |
事件:
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) - 拖动指针时触发。pointermove
(MapBrowserEvent) - 当指针移动时触发。(包括拖动?)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.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.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.
方法:
on(type, listener) 监听特定类型的事件
返回MapBrowserEvent对象
getEventCoordinate(event) 返回浏览器事件的用户投影中的坐标
返回Coordinate对象