# new IGSMapImageLayer(options)
IGS地图图片图层,
支持IGS1.0和2.0两个服务版本,支持自定义坐标系,当IGS版本是1.0时,需要手动设置图层坐标系,当IGS版本是2.0时,会自动读取元信息上的坐标系,不需要用户指定
[ES5引入方式]:
zondy.layer.IGSMapImageLayer()
[ES6引入方式]:
import { IGSMapImageLayer } from "@mapgis/webclient-common"
针对图层的操作请在图层加载完毕事件中进行
Layer.on('layerview-created', function (result) {
console.log("加载完毕:", result.layer)
});
如果不想在该事件中放入业务代码,则请确认图层资源已加载完毕后再进行操作
if(layer.loadStatus === 'loaded') {
// 你的业务逻辑
}
参数:
名称 | 类型 | 默认值 | 描述 |
---|---|---|---|
options |
Object | 构造参数 |
|
url |
String | 服务基地址,可以在末尾指定子图层id,若指定,则仅显示该子图层,例如:http://{服务基地址}/子图层id,[仅显示指定子图层] |
|
httpMethod |
String | "GET" | HTTP请求方式,默认为GET请求
IGS1.0的服务为:http://{ip}:6163/igs/rest/mrms/docs/{文件夹名(可选)}:{serviceName},暂时无法从元信息中获取坐标系,请自行指定图层坐标系,参考示例:[IGS1.0的地图图片图层示例] |
id |
String | 图层id,不给则给一个随机的id |
|
opacity |
Number | 1 | 图层透明度,0到1之间的值,0为完全透明,1为不透明,参考示例:[设置图层透明度] |
visible |
Boolean | true | 图层显示或隐藏,true则显示,false则隐藏,参考示例:[设置图层显示或隐藏] |
sublayers |
Array.<Object> | undefined | 会通过该参数中指定的子图层列表对地图服务中的子图层进行过滤,不在列表中的子图层将不会显示;如果没有指定该参数,则会按照地图服务中的子图层的属性显示所有子图层;如果该参数为空数组,则地图服务所有的子图层都不显示。
子图层顺序以及专题图参数仅支持IGS2.0服务,目前子图层支持的专题图如下: |
|
spatialReference |
SpatialReference | 图层坐标系,支持4326(包含4490,4214以及4610)、3857以及EPSG上的自定义坐标系,坐标系默认从元信息中获取,也可指定坐标系, 参考示例:[设置图层坐标系] |
|
imageWidth |
Number | 256 | 图片宽度,单位px,参考示例:[设置图片大小] |
imageHeight |
Number | 256 | 图片高度,单位px,参考示例:[设置图片大小] |
minScale |
Number | 0 | 最小显示比例尺,图层在视图中可见的最小比例尺(最缩小)。如果地图被缩小到超过这个比例,图层将不可见。默认值为0,0表示图层没有最小比例尺、可见性不受最小比例尺限制。minScale应该始终大于maxScale |
maxScale |
Number | 0 | 最大显示比例尺,图层在视图中可见的最大比例尺(最放大)。如果地图被放大到超过这个比例,图层将不可见。默认值为0,0表示图层没有最大比例尺、可见性不受最大比例尺限制。maxScale应该始终小于minScale |
tokenKey |
String | 'token' | token名 |
tokenValue |
String | token值,只有当tokenValue存在时,才会绑定token |
|
imageTransparency |
Boolean | true | 图片中没有数据的地方是否透明,默认为true,即透明 |
clippingArea |
Polygon | Extent | Circle | MultiPolygon | null | null | 图层空间裁剪范围,仅支持多多边形裁剪、多边形裁剪、矩形裁剪、圆形裁剪 |
renderMode |
String | 'tile' | 影像的展现形式。可选'tile' 、 'image'。默认为'tile',加载影像时以瓦片的方式平铺。当选项为'image'时,加载影像会请求一张覆盖当前屏幕的图像。 |
clientId |
String | 客户端id,用户的唯一标识;在地图服务中,调用接口时如果修改了地图的状态,包括设置动态投影、设置图层显示隐藏等,为了提升并发性能,服务端会根据clientId来生成临时地图,最佳做法是一个浏览器生成一个固定的唯一值;建议普通用户不要传该参数,webclient会根据当前浏览器生成一个固定的唯一值 |
|
isAntialiasing |
Boolean | null | 返回的图片时,是否开启服务端抗锯齿功能;启用抗锯齿功能后,显示效果会更清晰,但会导致出图速度变慢,true表示开启抗锯齿,false表示关闭抗锯齿,如果没有设置,则默认应用地图文档(MapX)上的设置参数 |
支持如下方法:
[1、加载图层资源][2、根据子图层id查询子图层]
3、刷新图层
[4、根据范围和大小获取image标签]
[5、根据参数获取图片的url]
[6、更新子图层]
[7、将图层转为json对象]
[8、克隆图层对象]
示例
// ES5引入方式
const { SpatialReference } = zondy
const { IGSMapImageLayer } = zondy.layer
// ES6引入方式
import { SpatialReference,IGSMapImageLayer } from "@mapgis/webclient-common"
// 添加图层
const igsMapImageLayer = new IGSMapImageLayer({
// 服务基地址
url: 'http://{ip}:6163/igs/rest/mrms/docs/{serviceName}',
// IGS1.0服务,暂时无法从元信息中获取坐标系,请自行指定图层坐标系
spatialReference: new SpatialReference({
wkid: 4326
})
});
// ES5引入方式
const { IGSMapImageLayer } = zondy.layer
// ES6引入方式
import { IGSMapImageLayer } from "@mapgis/webclient-common"
// 添加图层
const igsMapImageLayer = new IGSMapImageLayer({
// 服务基地址
url: 'http://{ip}:{port}/igs/rest/services/{serviceName}/MapServer'
});
// ES5引入方式
const { SpatialReference} = zondy
const { IGSMapImageLayer } = zondy.layer
// ES6引入方式
import { SpatialReference,IGSMapImageLayer } from "@mapgis/webclient-common"
// 添加图层
const igsMapImageLayer = new IGSMapImageLayer({
// 服务基地址
url: 'http://{ip}:{port}/igs/rest/services/{serviceName}/MapServer',
// 自定义坐标新
spatialReference: new SpatialReference({
// 指定的wkid号,可在https://epsg.io/网站查询
wkid: '指定的wkid号'
})
});
// ES5引入方式
const { IGSMapImageLayer } = zondy.layer
// ES6引入方式
import { IGSMapImageLayer } from "@mapgis/webclient-common"
// 添加图层
const igsMapImageLayer = new IGSMapImageLayer({
// 服务基地址
url: 'http://{ip}:{port}/igs/rest/services/{serviceName}/MapServer',
// 瓦片宽度
imageWidth: 512,
// 瓦片高度
imageHeight: 512
});
// ES5引入方式
const { IGSMapImageLayer } = zondy.layer
// ES6引入方式
import { IGSMapImageLayer } from "@mapgis/webclient-common"
// 添加图层
const igsMapImageLayer = new IGSMapImageLayer({
// 服务基地址
url: 'http://{ip}:{port}/igs/rest/services/{serviceName}/MapServer'
});
// ES5引入方式
const { IGSMapImageLayer } = zondy.layer
// ES6引入方式
import { IGSMapImageLayer } from "@mapgis/webclient-common"
// 添加图层
const igsMapImageLayer = new IGSMapImageLayer({
// 服务基地址
url: 'http://{ip}:{port}/igs/rest/services/{serviceName}/MapServer',
// 根据id显示子图层
sublayers: [
{
// 子图层id
id: 1,
// 显示子图层
visible: true
},
{
id: 2,
sublayers: [{
id: '2-23',
visible: true
}]
}
]
});
// ES5引入方式
const { IGSMapImageLayer } = zondy.layer
// ES6引入方式
import { IGSMapImageLayer } from "@mapgis/webclient-common"
// 添加图层
const igsMapImageLayer = new IGSMapImageLayer({
// 服务基地址
url: 'http://{ip}:{port}/igs/rest/services/{serviceName}/MapServer'
});
map.add(igsMapImageLayer);
// 通过方法设置子图层显隐
igsMapImageLayer.setSubLayer({
id: 0,
visible: false
})
// ES5引入方式
const { IGSMapImageLayer } = zondy.layer
// ES6引入方式
import { IGSMapImageLayer } from "@mapgis/webclient-common"
// 添加图层
const igsMapImageLayer = new IGSMapImageLayer({
// 服务基地址
url: 'http://{ip}:{port}/igs/rest/services/{serviceName}/MapServer'
});
// 根据id获取子图层
const subLayer = igsMapImageLayer.findSublayerById(0)
// 设置子图层显隐
subLayer.visible = false
// ES5引入方式
const { IGSMapImageLayer } = zondy.layer
// ES6引入方式
import { IGSMapImageLayer } from "@mapgis/webclient-common"
const igsMapImageLayer = new IGSMapImageLayer({
// 服务基地址
url: 'http://{ip}:{port}/igs/rest/services/{serviceName}/MapServer'
});
map.add(igsMapImageLayer);
// 根据id获取子图层
const subLayer = igsMapImageLayer.findSublayerById(0)
// 设置子图层顺序
subLayer.index = 2
// ES5引入方式
const { IGSMapImageLayer } = zondy.layer
const { UniqueValueRenderer } = zondy.renderer
const { SimpleFillSymbol,SimpleLineSymbol } = zondy.symbol
const { Color } = zondy
// ES6引入方式
import { IGSMapImageLayer,UniqueValueRenderer,SimpleFillSymbol,SimpleLineSymbol,Color } from "@mapgis/webclient-common"
igsMapImageLayer = new IGSMapImageLayer({
// 服务基地址
url: 'http://{ip}:{port}/igs/rest/services/{serviceName}/MapServer',
// 设置子图层专题图
sublayers: [
{
// 子图层id
id: '子图层id',
// 专题图参数
renderer: new UniqueValueRenderer({
//字段名
field: '你的字段名',
// 默认符号,不在专题图指定范围内的会采用该样式,可不设置
defaultSymbol: new SimpleFillSymbol({
// 填充颜色
color: 'rgba(1,1,252,0)',
// 外边线样式
outline: new SimpleLineSymbol({
//线颜色
color: new Color(255, 1, 0, 1),
//线宽
width: 1
})
}),
//单值专题图字段样式
uniqueValueInfos: [{
//指定字段值
value: "指定的值",
//匹配到该值后的样式
symbol: new SimpleFillSymbol({
// 填充颜色
color: 'rgba(1,1,252,1)',
// 外边线样式
outline: new SimpleLineSymbol({
//线符号颜色
color: new Color(255, 1, 0, 11),
//线宽
width: 1
})
})
},{
//指定字段值
value: "指定的值",
//匹配到该值后的样式
symbol: new SimpleFillSymbol({
// 填充颜色
color: new Color(211, 111, 11, 1)
})
}]
})
}
]
});
// ES5引入方式
const { IGSMapImageLayer } = zondy.layer
const { ClassBreakRenderer } = zondy.renderer
const { SimpleFillSymbol,SimpleLineSymbol } = zondy.symbol
const { Color } = zondy
// ES6引入方式
import { IGSMapImageLayer,ClassBreakRenderer,SimpleFillSymbol,SimpleLineSymbol,Color } from "@mapgis/webclient-common"
const igsMapImageLayer = new IGSMapImageLayer({
// 服务基地址
url: 'http://{ip}:{port}/igs/rest/services/{serviceName}/MapServer',
// 设置子图层专题图
sublayers: [
{
// 子图层id
id: '子图层id',
// 专题图参数
renderer: new ClassBreakRenderer({
//字段名
field: '你的字段名',
// 指定默认样式,不在专题图指定范围内的会采用该样式,可不设置
defaultSymbol: new SimpleFillSymbol({
// 填充颜色
color: 'rgba(222,1,252,1)',
// 线符号样式
outline: new SimpleLineSymbol({
//线符号颜色
color: new Color(255, 1, 0, 1),
//线宽
width: 1
})
}),
//单值专题图字段样式
classBreakInfos: [{
// 最大范围
maxValue: "最大范围",
// 最小范围
minValue: "最小范围",
//匹配到该值后的样式
symbol: new SimpleFillSymbol({
// 填充颜色
color: 'rgba(1,1,252,1)',
// 线符号样式
outline: new SimpleLineSymbol({
//线符号颜色
color: new Color(255, 1, 0, 1),
//线宽
width: 1
})
})
}]
})
}
]
});
// ES5引入方式
const { IGSMapImageLayer } = zondy.layer
const { ClassBreakRenderer } = zondy.renderer
const { SimpleFillSymbol,SimpleLineSymbol } = zondy.symbol
const { Color } = zondy
// ES6引入方式
import { IGSMapImageLayer,ClassBreakRenderer,SimpleFillSymbol,SimpleLineSymbol,Color } from "@mapgis/webclient-common"
const igsMapImageLayer = new zondy.layer.IGSMapImageLayer({
// 服务基地址
url: 'http://{ip}:{port}/igs/rest/services/{serviceName}/MapServer'
});
// 设置子图层专题图
igsMapImageLayer.setSubLayer({
// 子图层id
id: '子图层id',
// 专题图参数
renderer: new zondy.renderer.ClassBreakRenderer({
//字段名
field: '你的字段名',
// 指定默认样式,不在专题图指定范围内的会采用该样式,可不设置
defaultSymbol: new zondy.symbol.SimpleFillSymbol({
// 填充颜色
color: 'rgba(222,1,252,1)',
// 线符号样式
outline: new zondy.symbol.SimpleLineSymbol({
//线符号颜色
color: new zondy.Color(255, 1, 0, 1),
//线宽
width: 1
})
}),
//单值专题图字段样式
classBreakInfos: [{
// 最大范围
maxValue: "最大范围",
// 最小范围
minValue: "最小范围",
//匹配到该值后的样式
symbol: new zondy.symbol.SimpleFillSymbol({
// 填充颜色
color: 'rgba(1,1,252,1)',
// 线符号样式
outline: new zondy.symbol.SimpleLineSymbol({
//线符号颜色
color: new zondy.Color(255, 1, 0, 1),
//线宽
width: 1
})
})
}]
})
})
// ES5引入方式
const { IGSMapImageLayer } = zondy.layer
const { ClassBreakRenderer } = zondy.renderer
const { SimpleFillSymbol,SimpleLineSymbol } = zondy.symbol
const { Color } = zondy
// ES6引入方式
import { IGSMapImageLayer,ClassBreakRenderer,SimpleFillSymbol,SimpleLineSymbol,Color } from "@mapgis/webclient-common"
const igsMapImageLayer = new IGSMapImageLayer({
// 服务基地址
url: 'http://{ip}:{port}/igs/rest/services/{serviceName}/MapServer'
});
// 根据id获取子图层
const subLayer = igsMapImageLayer.findSublayerById(0)
// 设置子图专题图
subLayer.renderer = new ClassBreakRenderer({
//字段名
field: '你的字段名',
// 指定默认样式,不在专题图指定范围内的会采用该样式,可不设置
defaultSymbol: new SimpleFillSymbol({
// 填充颜色
color: 'rgba(222,1,252,1)',
// 线符号样式
outline: new SimpleLineSymbol({
//线符号颜色
color: new Color(255, 1, 0, 1),
//线宽
width: 1
})
}),
//单值专题图字段样式
classBreakInfos: [{
// 最大范围
maxValue: "最大范围",
// 最小范围
minValue: "最小范围",
//匹配到该值后的样式
symbol: new SimpleFillSymbol({
// 填充颜色
color: 'rgba(1,1,252,1)',
// 线符号样式
outline: new SimpleLineSymbol({
//线符号颜色
color: new Color(255, 1, 0, 1),
//线宽
width: 1
})
})
}]
})
// ES5引入方式
const { IGSMapImageLayer } = zondy.layer
// ES6引入方式
import { IGSMapImageLayer } from "@mapgis/webclient-common"
// 初始化时设置
const igsMapImageLayer = new IGSMapImageLayer({
// 服务基地址
url: 'http://{ip}:{port}/igs/rest/services/{serviceName}/MapServer',
// 设置透明度
opacity: 1.0
});
// 加载完成后设置
igsMapImageLayer.on('layerview-created', function (result) {
console.log("加载完毕:", result.layer)
// 视点跳转
igsMapImageLayer.opacity = 0.5
})
/ ES5引入方式
const { IGSMapImageLayer } = zondy.layer
// ES6引入方式
import { IGSMapImageLayer } from "@mapgis/webclient-common"
// 初始化时设置
const igsMapImageLayer = new IGSMapImageLayer({
// 服务基地址
url: 'http://{ip}:{port}/igs/rest/services/{serviceName}/MapServer',
// 显示或隐藏图层
visible: true
});
// 加载完成后设置
igsMapImageLayer.on('layerview-created', function (result) {
console.log("加载完毕:", result.layer)
// 显示或隐藏图层
igsMapImageLayer.visible = !igsMapImageLayer.visible
})
map.remove(igsMapImageLayer)
/ ES5引入方式
const { IGSMapImageLayer } = zondy.layer
// ES6引入方式
import { IGSMapImageLayer } from "@mapgis/webclient-common"
// 初始化时设置
const igsMapImageLayer = new IGSMapImageLayer({
// 服务基地址,可指定子图层id
url: 'http://{ip}:{port}/igs/rest/services/{serviceName}/MapServer/{子图层id}',
// 显示或隐藏图层
visible: true
});
// 初始化图层管理容器
/ ES5引入方式
const { SpatialReference} = zondy
const { IGSMapImageLayer} = zondy.layer
// ES6引入方式
import { SpatialReference, IGSMapImageLayer } from "@mapgis/webclient-common"
const arcgisMapImageLayer = new IGSMapImageLayer({
url: 'https://map.geoq.cn/arcgis/rest/services/ChinaOnlineStreetWarm/MapServer',
// 注意一个MapImage图层可能支持多个坐标系,这里指定4326坐标系
spatialReference: new SpatialReference({
wkid: 4326
})
});
// 图层加载完毕
igsMapImageLayer.on('layerview-created', function (result) {
console.log("加载完毕:", result.layer)
})
// 加载完毕后,更改图层顺序
map.reorder(igsMapImageLayer, '要移动到的index');
继承关系
成员变量
方法
# static clone(igsMapImageLayer)
克隆图层对象
参数:
名称 | 类型 | 描述 |
---|---|---|
igsMapImageLayer |
IGSMapImageLayer | 被克隆的对象 |
克隆后的图层对象
示例
// 添加图层
const igsMapImageLayer = new zondy.layer.IGSMapImageLayer({
// 服务基地址
url: 'http://{ip}:6163/igs/rest/mrms/docs/{serviceName}'
});
const newLayer = zondy.layer.IGSMapImageLayer.clone(igsMapImageLayer)
# static fromJSON(json)
通过json对象构造并返回一个IGSMapImageLayer对象
参数:
名称 | 类型 | 描述 |
---|---|---|
json |
Object | json对象 |
新的IGSMapImageLayer对象
# fetchImage(extent, widthopt, heightopt)
根据范围和大小获取image标签
参数:
名称 | 类型 | 默认值 | 描述 |
---|---|---|---|
extent |
Extent | 范围参数 |
|
width |
Number | 256 | 图片宽度,单位px |
height |
Number | 256 | 图片高度,单位px |
请求完毕的返回Promise
示例
igsMapImageLayer.fetchImage({
// 你的范围
extent: new zondy.geometry.Extent(),
// 图片宽度
width: 256,
// 图片高度
height: 256
}).then((image) => {
// 这里返回一个html的image标签
})
# getImageUrl(options)
根据参数获取图片的url
参数:
名称 | 类型 | 描述 |
---|---|---|
options |
||
extent |
Extent | 图片范围 |
width |
Number | 图片宽度 |
height |
Number | 图片高度 |
图片的url
示例
const url = igsMapImageLayer.getImageUrl({
// 你的范围
extent: new zondy.geometry.Extent(),
// 图片宽度
width: 256,
// 图片高度
height: 256
})
# load()
加载图层资源
示例
// 初始化图层
const igsMapImageLayer = new zondy.layer.IGSMapImageLayer({
// 服务基地址
url: 'http://{ip}:{port}/igs/rest/services/{serviceName}/MapServer',
});
igsMapImageLayer.load().then((result) => {
// 获取完图层信息
console.log(result)
})
事件
# 子图层显隐更新完毕事件
子图层显隐更新完毕事件,请注意该事件是图层更新事件(layerview-update)的子事件
属性:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
event |
Object | 事件对象 |
||
type |
String |
<optional> |
'layerview-update' | 图层更新完毕事件 |
message |
String |
<optional> |
null | 更新描述 |
updateContent |
Array.<UpdateContent> |
<optional> |
null | 更新详情对象 |
layer |
Layer |
<optional> |
null | 地图图层对象 |
layerView |
MapView |
<optional> |
null | 图层的视图对象 |
sourceTarget |
Layer |
<optional> |
null | 事件发起对象 |
target |
Map |
<optional> |
null | 事件接收对象 |
示例
子图层显隐更新完毕事件
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 === 'sublayerVisible'){
console.log("子图层显隐更新完毕事件:", event);
}
}
});