Class: MapImageLayer

MapImageLayer

new MapImageLayer(options)

document/layer/baseLayer/MapImageLayer.js, line 10

地图图片图层基类

Name Type Description
options Object

构造参数

Name Type Default Description
minScale Number 0 可选

最小显示比例尺,图层在视图中可见的最小比例尺。

maxScale Number 0 可选

最大显示比例尺,图层在视图中可见的最大比例尺。

tokenKey String 可选

token名

tokenValue String 可选

token值

url String '' 可选

服务基地址

mapName String '' 可选

地图名称

documentInfo String 可选

服务基地址

renderMode String 'tile' 可选

渲染模式,分为瓦片渲染'tile'和图像渲染'image'

imageWidth Number 'tile' 可选

瓦片化显示时,瓦片宽度

imageHeight Number 'tile' 可选

瓦片化显示时,瓦片高度

imageFormat String 'png' 可选

图片格式

imageTransparency Boolean true 可选

图片中没有数据的地方是否透明

dynamicProjectionEnabled Boolean false 可选

是否开启动态投影

clippingArea Polygon | Extent | Circle | MultiPolygon | null null 可选

图层空间裁剪范围,仅支持多多边形裁剪、多边形裁剪、矩形裁剪、圆形裁剪

renderMode String 'tile' 可选

影像的展现形式。可选'tile' 、 'image'。默认为'tile',加载影像时以瓦片的方式平铺。当选项为'image'时,加载影像会请求一张覆盖当前屏幕的图像。

Extends

Members

capabilitiesObject

图层支持能力。图层支持能力分为客户端能力和服务端能力,其中客户端能力包含cesium、leaflet、mapboxgl引擎能力。默认图层客户端能力:所有引擎支持图层加载;默认图层服务端能力为空。

版权所有

descriptionString

图层描述

documentInfoObject

地图文档信息

dynamicProjectionEnabledBoolean

是否开启动态投影

extendPropsObject

额外属性,当前图层对象上不支持的属性,二次开发用户希望挂在图层对像上的属性可以存储到该属性中

Default Value:
{}

extensionOptionsObject

初始化图层的额外参数,可以通过该参数传入引擎原生的构造参数

Default Value:
{}

extentExtent null

图层的范围。从元信息或数据中获取,默认为null表示取不到范围。

headersObject

设置服务请求头

httpMethodFetchMethod

http请求方式

idString

图层id

imageFormatString

图片格式

imageFormatsArray

图片格式数组,表示服务支持的所有图片格式

imageHeightNumber

瓦片化显示时,瓦片高度

imageTransparencyBoolean

图片中没有数据的地方是否透明

imageWidthNumber

瓦片化显示时,瓦片宽度

loadedBoolean

是否加载完毕

Default Value:
false

loadErrorObject

请求失败后的错误信息,toJSON方法不会导出该属性

Default Value:
null

loadStatusString

图层加载状态

Default Value:
not-loaded

mapNameString

地图名称

maxScaleNumber

最大显示比例尺,图层在视图中可见的最大比例尺(最放大)。如果地图被放大到超过这个比例,图层将不可见。默认值为0,如果图层是瓦片类型,maxScale、minScale的默认值能和tileInfo上的保持一致,如果图层是动态图层,则和地图视图保持一致。maxScale应该始终小于minScale。

Default Value:
0

minScaleNumber

最小显示比例尺,图层在视图中可见的最小比例尺(最缩小)。如果地图被缩小到超过这个比例,图层将不可见。默认值为0,如果图层是瓦片类型,maxScale、minScale的默认值能和tileInfo上的保持一致,如果图层是动态图层,则和地图视图保持一致。minScale应该始终大于maxScale。

Default Value:
0

opacityNumber

图层透明度,0到1之间的值,0为完全透明,1为不透明,会触发图层更新完毕事件。IGSSceneLayer图层类型为地形时,不支持该属性。

spatialReferenceSpatialReference null

图层坐标系对象

titleString

图层名称

tokenAttachTypeTokenAttachType

token附加类型。默认psot请求优先附加到body,get请求优先附加到url末尾

tokenKeyString

token名

Default Value:
token

tokenValueString

token值

typeLayerType

图层类型

urlString

服务基地址

visibleNumber

图层显示或隐藏,true则显示,false则隐藏,会触发图层更新完毕事件

Events

inherited 图层加载完毕事件

document/layer/baseLayer/Layer.js, line 46

图层加载完毕事件

Properties:
Name Type Description
event Object

事件对象

Properties
Name Type Default Description
type String 'layerview-created' 可选

图层加载完毕事件

message String null 可选

更新描述

UpdateContent Array.<UpdateContent> null 可选

更新详情对象

layer Layer null 可选

地图图层对象

layerView MapView null 可选

图层的视图对象

sourceTarget Layer null 可选

事件发起对象

target Map null 可选

事件接收对象

Example

图层加载完毕事件

Layer.on('layerview-created', function (result) {
  console.log("加载完毕:", result.layer)
});

inherited 图层显隐更新完毕事件

document/layer/baseLayer/Layer.js, line 90

图层显隐更新完毕事件,请注意该事件是图层更新事件(layerview-update)的子事件

Properties:
Name Type Description
event Object

事件对象

Properties
Name Type Default Description
type String 'layerview-update' 可选

图层更新完毕事件

message String null 可选

更新描述

updateContent Array.<UpdateContent> null 可选

更新详情对象

layer Layer null 可选

地图图层对象

layerView MapView null 可选

图层的视图对象

sourceTarget Layer null 可选

事件发起对象

target Map null 可选

事件接收对象

Example

图层显隐更新完毕事件

Layer.on('layerview-update', function (event) {
  // 获取更新事件对象
  console.log("更新完毕:", event)
  // 获取更新详情数组
  const updateContent = event.updateContent
  // 循环数组,根据事件名进行后续操作
  for (let i = 0; i < updateContent.length; i++) {
    // 图层显隐事件
    if(updateContent[i].name === 'visible'){
      console.log("图层显隐更新事件:", event);
    }
  }
});

inherited 图层比例尺显示隐藏状态更新事件。当前仅支持非组图层以及场景子图层

document/layer/baseLayer/Layer.js, line 144

图层刷新完毕事件,请注意该事件是图层更新事件(layerview-update)的子事件

Properties:
Name Type Description
event Object

事件对象

Properties
Name Type Default Description
type String 'layerview-update' 可选

图层更新完毕事件

message String null 可选

更新描述

updateContent Array.<UpdateContent> null 可选

更新详情对象

layer Layer null 可选

地图图层对象

layerView MapView null 可选

图层的视图对象

sourceTarget Layer null 可选

事件发起对象

target Map null 可选

事件接收对象

event LayerViewScaleVisibleEvent

事件对象 layer.on('layerview-scale-visible', (event) => { console.log("图层比例尺显示隐藏状态更新事件:", event) })

Example

图层刷新完毕事件

Layer.on('layerview-update', function (event) {
  // 获取更新事件对象
  console.log("更新完毕:", event)
  // 获取更新详情数组
  const updateContent = event.updateContent
  // 循环数组,根据事件名进行后续操作
  for (let i = 0; i < updateContent.length; i++) {
    // 图层刷新完毕事件
    if(updateContent[i].name === 'refresh'){
      console.log("图层刷新完毕事件:", event);
    }
  }
});

/**

inherited 图层视图更新事件

document/layer/baseLayer/Layer.js, line 80

图层视图更新事件

Properties:
Name Type Description
event LayerViewUpdateEvent

事件对象

Example

图层更新完毕事件

Layer.on('layerview-update', function (result) {
  console.log("更新完毕:", result.layer)
});

inherited 图层透明度更新完毕事件

document/layer/baseLayer/Layer.js, line 117

图层透明度更新完毕事件,请注意该事件是图层更新事件(layerview-update)的子事件

Properties:
Name Type Description
event Object

事件对象

Properties
Name Type Default Description
type String 'layerview-update' 可选

图层更新完毕事件

message String null 可选

更新描述

updateContent Array.<UpdateContent> null 可选

更新详情对象

layer Layer null 可选

地图图层对象

layerView MapView null 可选

图层的视图对象

sourceTarget Layer null 可选

事件发起对象

target Map null 可选

事件接收对象

Example

图层透明度更新完毕事件

Layer.on('layerview-update', function (event) {
  // 获取更新事件对象
  console.log("更新完毕:", event)
  // 获取更新详情数组
  const updateContent = event.updateContent
  // 循环数组,根据事件名进行后续操作
  for (let i = 0; i < updateContent.length; i++) {
    // 图层透明度更新事件
    if(updateContent[i].name === 'opacity'){
      console.log("图层透明度更新事件:", event);
    }
  }
});

inherited 图层销毁完毕事件

document/layer/baseLayer/Layer.js, line 63

图层销毁完毕事件

Properties:
Name Type Description
event Object

事件对象

Properties
Name Type Default Description
type String 'layerview-remove' 可选

图层销毁完毕事件

message String null 可选

更新描述

updateContent Array.<UpdateContent> null 可选

更新详情对象

layer Layer null 可选

要销毁的地图图层对象

layerView MapView null 可选

图层的视图对象

sourceTarget Layer null 可选

事件发起对象

target Map null 可选

事件接收对象

Example

图层销毁完毕事件

Layer.on('layerview-remove', function (result) {
  console.log("销毁完毕:", result.layer)
});

Methods

MapImageLayer.fromJSON(json){MapImageLayer}

document/layer/baseLayer/MapImageLayer.js, line 278

通过json构造MapImageLayer对象

Name Type Description
json Object

json对象

Returns:
Type Description
MapImageLayer MapImageLayer

clone(){MapImageLayer}

document/layer/baseLayer/MapImageLayer.js, line 250

克隆方法

Returns:
Type Description
MapImageLayer 克隆的新图层

inherited destroy(){*}

document/layer/baseLayer/Layer.js, line 618
Returns:
Type Description
*

inherited getProperty(path){*}

document/layer/baseLayer/Layer.js, line 818

获取属性

Name Type Description
path String
Returns:
Type Description
* 属性值

inherited isLoaded(){Boolean}

document/layer/baseLayer/Layer.js, line 543

判断图层是否加载成功

Returns:
Type Description
Boolean 图层是否加载成功

inherited off(types, fn, context){Object}

base/Evented.js, line 328
Name Type Description
types string 可选

移除指定事件类型上绑定的回调函数
当类型为字符串时,可以移除单个或多个事件类型绑定的回调函数,单个事件:"click",多个事件:以空格分割:"click double-click";
当types为对象时,使用如下方式移除事件:{'click': onClickFun, 'mouse-move': onMouseMoveFun}

fn function 可选

事件回调函数,当types为字符串,且不指定要删除的回调函数时,删除该事件上的所有回调函数

context Object 可选

事件回调函数的this关键字将指向的对象

Returns:
Type Description
Object 当前实例
Examples

移除一个事件的指定回调函数

// 一个事件的回调函数
const clickFunction = function (event) {
  console.log("点击事件:", event)
}
// 调用MapView或SceneView的off方法移除一个事件的回调函数
view.off('click', clickFunction)

移除一个事件的所有回调函数

// 一个事件的回调函数1
const clickFunction1 = function (event) {
  console.log("点击事件1:", event)
}

// 一个事件的回调函数2
const clickFunction2 = function (event) {
  console.log("点击事件2:", event)
}

// 调用MapView或SceneView的off方法移除一个事件的所有回调函数
// 不指定回调函数,则移除该事件上的所有绑定的回调函数
view.off('click')

移除多个事件的同一个指定的回调函数

// 多个事件的同一个回调函数
const eventFunction = function (event) {
  console.log("事件:", event)
}
// 调用MapView或SceneView的off方法移除多个事件的同一个指定的回调函数
view.off('click double-click', eventFunction)

移除多个指定事件的回调函数

// 一个事件的回调函数
const clickFunction = function (event) {
  console.log("click事件:", event)
}
// 调用MapView或SceneView的off方法移除多个指定事件的回调函数
view.off({
   // 移除click事件上一个指定的函数
  "click": clickFunction,
  // 移除double-click上所有指定的函数
  "double-click": undefined
})

删除时指定上下文 - types类型为字符串

// 一个事件的回调函数
const clickFunction = function (event) {
  console.log("点击事件:", event)
}
// 调用MapView或SceneView的off方法移除一个事件的回调函数
view.off('click', clickFunction, view)
// 调用MapView或SceneView的off方法移除一个事件的所有回调函数
view.off('click', undefined, view)

删除时指定上下文 - types类型为对象

// 一个事件的回调函数
const clickFunction = function (event) {
  console.log("click事件:", event)
}
// 调用MapView或SceneView的off方法移除多个指定事件的回调函数
view.off({
   // 移除click事件上一个指定的函数
  "click": clickFunction,
  // 移除double-click上所有指定的函数
  "double-click": undefined
}, view)

inherited on(types, fn, context){Object}

base/Evented.js, line 232
Name Type Default Description
types String | Object null 可选

事件类型
当types为字符串时,可以定义单个或多个事件,单个事件:"click",多个事件:以空格分割:"click double-click";
当types为对象时,使用如下方式指定事件:{'click': onClickFun, 'mouse-move': onMouseMoveFun}

fn function null 可选

事件回调函数

context Object null 可选

事件回调函数的this关键字将指向的对象

Returns:
Type Description
Object 当前实例
Examples

注册一个事件

// 初始化一个点击事件回调函数
const clickFunction = function (event) {
  console.log("点击事件:", event)
}
// 调用MapView或SceneView的on方法注册一个点击事件
view.on('click', clickFunction)

一次注册多个事件 - 同一个回调函数

// 初始化一个事件回调函数
const eventFunction = function (event) {
  console.log("事件:", event)
}

// 调用MapView或SceneView的on方法注册多个事件
// 多个事件类型使用同一个回调函数
view.on('click right-click-down', eventFunction)

一次注册多个事件 - 分别指回调应函数

// 初始化一个左键点击事件回调函数
const clickFunction = function (event) {
  console.log("click事件:", event)
}

// 初始化一个右键按下事件回调函数
const rightClickFunction = function (event) {
  console.log("right-click-down事件:", event)
}

// 调用MapView或SceneView的on方法注册多个事件
// 每一个事件类型,使用单独的回调函数
// 注意使用此种方式,一种类型的事件仅能指定一个回调函数
view.on({
  "click": clickFunction,
  "right-click-down": rightClickFunction
})

指定上下文 - types类型为字符串

// 初始化一个点击事件回调函数
const clickFunction = function (event) {
  console.log("点击事件:", event)
  console.log("上下文对象:", this)
}
// 调用MapView或SceneView的on方法注册一个点击事件
// 指定view为回调函数的上下文对象
view.on('click', clickFunction, view)

指定上下文 - types类型为对象

// 初始化一个点击事件回调函数
const clickFunction = function (event) {
  console.log("点击事件:", event)
  console.log("上下文对象:", this)
}
// 调用MapView或SceneView的on方法注册一个点击事件
// 指定view为回调函数的上下文对象
view.on({
  "click": clickFunction,
  "right-click-down": clickFunction
}, view)

inherited refresh()

document/layer/baseLayer/Layer.js, line 747

刷新图层

inherited setProperty(path, value){Boolean}

document/layer/baseLayer/Layer.js, line 778

设置属性值或者属性路径对应的值。由于当前仅支持第一级属性响应,无法解决多级属性响应机制,此方法支持属性路径响应机制。例如:path输入'tileInfo.startLevel',则会响应式更新startLevel。

Name Type Description
path String

属性路径,可以传入单个属性后者一个属性的路径

value *
Returns:
Type Description
Boolean 是否设置成功

toJSON(){Object}

document/layer/baseLayer/MapImageLayer.js, line 227

转换为json对象

Returns:
Type Description
Object json对象