ol7源码学习之Map

Map类

参数:

NameTypeDescription
controlsCollection<Control> | Array<Control> | undefined

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

pixelRationumber (defaults to window.devicePixelRatio)

The ratio between physical pixels and device-independent pixels (dips) on the device.

interactionsCollection<Interaction> | Array<Interaction> | undefined

Interactions that are initially added to the map. If not specified, defaults is used.

keyboardEventTargetHTMLElement | Document | string | undefined

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.

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

maxTilesLoadingnumber (defaults to 16)

Maximum number tiles to load simultaneously.

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

overlaysCollection<Overlay> | Array<Overlay> | undefined

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

targetHTMLElement | string | undefined

The container for the map, either the element itself or the id of the element. If not specified at construction time, setTarget must be called for the map to be rendered. If passed by element, the container can be in a secondary document.

viewView | Promise<ViewOptions> | undefined

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

事件:

  • 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对象

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值