# new IGSVectorTileLayer(options)
IGS矢量瓦片图层
支持IGS1.0和2.0两个服务版本
支持通过如下三种方式来初始化矢量瓦片图层对象:
1、通过服务基地址来初始化矢量瓦片图层对象;
2、通过加载矢量瓦片样式文件的方式来初始化矢量瓦片图层对象;
3、通过设置矢量瓦片样式的方式来初始化矢量瓦片图层对象;
当加载MapGIS制作并由IGS发布的矢量瓦片时,如果矢量瓦片样式中有mapinfo参数,则子图层ID对应的是MapX中的图层索引;
如果没有mapinfo参数,则子图层ID对应的是矢量瓦片样式图层ID;
当加载第三方发布的矢量瓦片时,子图层ID对应的是矢量瓦片样式图层ID;
[ES5引入方式]:
zondy.layer.IGSVectorTileLayer()
[ES6引入方式]:
import { IGSVectorTileLayer } from "@mapgis/webclient-common"
针对图层的操作请在图层加载完毕事件中进行
Layer.on('layerview-created', function (result) {
console.log("加载完毕:", result.layer)
});
如果不想在该事件中放入业务代码,则请确认图层资源以加载完毕后再进行操作
if(layer.loadStatus === 'loaded') {
// 你的业务逻辑
}
同时也支持二次开发自定义业务逻辑,示例如下:
[自定义矢量瓦片业务逻辑-es5],[自定义矢量瓦片业务逻辑-es6]
注意:三维上,不支持简单Marker样式设定;二维上,简单Marker的颜色,外边线样式,旋转角度无法在图层初始化和初始化后修改,须在制作数据时进行指定
参数:
名称 | 类型 | 默认值 | 描述 |
---|---|---|---|
options |
Object | 构造参数 |
|
url |
String | null | 服务基地址,和style参数二者选其一: |
style |
Object | null | 矢量瓦片的mvt样式对象,默认从服务中获取,用户也可主动传入mvt样式对象来构造一个矢量瓦片图层,此时会忽略用户输入的url参数 |
sublayers |
Collection.<IGSVectorTileSubLayer> | 会通过该参数中指定的子图层列表对矢量瓦片服务中的子图层进行过滤,不在列表中的子图层将不会显示;如果没有指定该参数,则会按照矢量瓦片服务中的子图层的属性显示所有子图层;如果该参数为空数组,则矢量瓦片服务所有的子图层都不显示。 |
|
minScale |
Number | 0 | 最小显示比例尺,图层在视图中可见的最小比例尺。 |
maxScale |
Number | 0 | 最大显示比例尺,图层在视图中可见的最大比例尺。 |
opacity |
Number | 1 | 图层透明度,0到1之间的值,0为完全透明,1为不透明,参考示例:[设置图层透明度] |
tokenKey |
String | 'token' | token名 |
tokenValue |
String | null | token值,只有当tokenValue存在时,才会绑定token |
visible |
Boolean | true | 图层显示或隐藏,true则显示,false则隐藏,参考示例:[设置图层显隐] |
labelsRenderMode |
String | 'off-screen' | 指定矢量瓦片注记的渲染模式,仅在三维上有效 |
clippingArea |
Polygon | Extent | Circle | MultiPolygon | null | null | 图层空间裁剪范围,仅支持多多边形裁剪、多边形裁剪、矩形裁剪、圆形裁剪 |
replaceStyleURL |
Boolean | true | 初始化图层时,是否将样式中的基地址替换为图层的基地址 |
replaceStyleURLRegExp |
RegExp | '预定义的正则表达式' | 当replaceStyleURL设置为true时,将样式中的基地址替换为图层的基地址操作中使用的正则表达式 |
支持如下方法:
[1、根据子图层id查询图层][2、通过传入的json构造并返回一个新的IGSVectorTileLayer对象]
[3、导出为json对象]
4、通过矢量瓦片样式图层的id,找到对应的矢量瓦片样式图层对象
5、通过矢量瓦片样式图层的id,找到对应的矢量瓦片样式图层的序号
6、通过矢量瓦片样式图层的序号,找到对应的矢量瓦片样式图层的id
7、设置样式图层属性对象
8、删除样式图层
9、设置样式图层可见性
10、获取样式图层可见性
11、获取样式图层绘制属性
12、设置样式图层绘制属性
13、获取样式图层布局属性
14、设置样式图层布局属性
15、设置样式图层的额外属性
16、获取样式图层的额外属性
17、克隆图层
示例
//初始化地图管理容器
// ES5引入方式
const { IGSVectorTileLayer } = zondy.layer
const { SpatialReference } = zondy
// ES6引入方式
import { IGSVectorTileLayer, SpatialReference } from "@mapgis/webclient-common"
//初始化矢量瓦片图层
const igsVectorTileLayer = new IGSVectorTileLayer({
// 矢量瓦片基地址
url: '',
// 图层参考系
spatialReference:new SpatialReference('EPSG:4326')
});
// ES5引入方式
const { IGSVectorTileLayer } = zondy.layer
// ES6引入方式
import { IGSVectorTileLayer } from "@mapgis/webclient-common"
// 初始化矢量瓦片图层
const igsVectorTileLayer = new IGSVectorTileLayer({
// 矢量瓦片基地址
url: ''
});
// ES5引入方式
const { IGSVectorTileLayer } = zondy.layer
// ES6引入方式
import { IGSVectorTileLayer } from "@mapgis/webclient-common"
// 初始化矢量瓦片图层
const igsVectorTileLayer = new IGSVectorTileLayer({
// 矢量瓦片的mvt样式对象
style: {}
});
// ES5引入方式
const { IGSVectorTileLayer } = zondy.layer
// ES6引入方式
import { IGSVectorTileLayer } from "@mapgis/webclient-common"
// 初始化矢量瓦片图层
const igsVectorTileLayer = new IGSVectorTileLayer({
// 矢量瓦片基地址
url: ''
});
// 例如通过重写igsVectorTileLayer对象的covertCustomStyleToMVTStyle方法,来自定义矢量瓦片业务逻辑
igsVectorTileLayer.covertCustomStyleToMVTStyle = function(customStyle) {
// 自定义你的业务逻辑
// 此方法必须要返回一个符合MapBox标准的矢量瓦片
return mvtStyle
}
// 在ES5模式下,如果更改了图层的业务逻辑,则必须通过图层的load方法来加载元信息,之后再添加图层
igsVectorTileLayer.load().then(() => {
// 添加图层
map.add(igsVectorTileLayer)
})
// ES6引入方式
import { IGSVectorTileLayer } from "@mapgis/webclient-common"
// 在ES6模式下继承IGSVectorTileLayer,并重写其业务逻辑
class IGSVectorTileLayerCustom extends IGSVectorTileLayer {
constructor(options) {
super(options)
}
}
// 重写方法
IGSVectorTileLayerCustom.prototype.covertCustomStyleToMVTStyle = function (customStyle) {
// 自定义你的业务逻辑
// 此方法必须要返回一个符合MapBox标准的矢量瓦片
return mvtStyle
}
const customLayer = new IGSVectorTileLayerCustom({
// 矢量瓦片基地址
url: ''
})
// ES5引入方式
const { LabelClass } = zondy
const { IGSVectorTileLayer } = zondy.layer
// ES6引入方式
import { IGSVectorTileLayer, LabelClass } from "@mapgis/webclient-common"
// 初始化一个额外的图标DOM对象
const iconImage = new Image()
iconImage.src = '图片地址或者base64字符串'
// 初始化矢量瓦片图层
const igsVectorTileLayer = new IGSVectorTileLayer({
// 矢量瓦片基地址
url: '',
// 开启三维注记
labelsRenderMode: 'on-screen',
// 设置要应用三维主句的子图层
sublayers: [{
// 矢量瓦片子图层id
id: '矢量瓦片子图层id',
// 注记参数,目前仅用填写一个
labelingInfo: [
new LabelClass({
symbol: {
// 填充颜色 rgba or 16进制颜色
color: 'rgba(255,255,255,1)',
// 描边颜色
haloColor: 'rgba(0,0,0,0.5)',
// 描边宽度
haloSize: 2,
// 行高
lineHeight: 1.1,
// 文本间距
letterSpacing: 2,
// 字体样式 参考css
font: {
size: 14,
family: '微软雅黑',
weight: 'normal',
style: 'normal'
},
// 额外的图标
textExtraIcon: iconImage,
// 图标的大小
textExtraIconSize:20,
// 图标方位
textExtraIconAnchor:'left'
},
// 渲染方式 1.canvas 2.label 3.ground
renderMode: 'canvas',
// 最大可见范围
minScale: 60000000,
// 最小可见范围
maxScale: 1,
// 布局位置 可选 1.above-left 2.above-center 3.above-right 4.center-left 5.center-center 6.center-right 7.below-left 8.below-center 9.below-right
labelPlacement: 'above-center',
// 高程采样参数
elevationInfo: {
mode: 'OnTheGround',
offset: 0
}
})
]
}]
});
// 矢量瓦片渲染模式
igsVectorTileLayer.labelsRenderMode = 'off-screen'
// Cesium三维渲染模式
igsVectorTileLayer.labelsRenderMode = 'on-screen'
igsVectorTileLayer.opacity = 0.5
igsVectorTileLayer.visible = !igsVectorTileLayer.visible
map.remove(igsVectorTileLayer)
// ES5引入方式
const { IGSVectorTileLayer } = zondy.layer
// ES6引入方式
import { IGSVectorTileLayer } from "@mapgis/webclient-common"
// 添加图层
const igsVectorTileLayer = new IGSVectorTileLayer({
// 服务基地址
url: 'http://{ip}:{port}/igs/rest/services/{serviceName}/VectorTileServer',
//默认不设置sublayers,加载全部图层
});
// ES5引入方式
const { IGSVectorTileLayer } = zondy.layer
// ES6引入方式
import { IGSVectorTileLayer } from "@mapgis/webclient-common"
// 添加图层
const igsVectorTileLayer = new IGSVectorTileLayer({
// 服务基地址
url: 'http://{ip}:{port}/igs/rest/services/{serviceName}/VectorTileServer',
// 根据id显示子图层
sublayers: [
{
// 子图层id
id: '子图层id',
// 显示子图层
visible: true
}
]
});
// ES5引入方式
const { IGSVectorTileLayer } = zondy.layer
// ES6引入方式
import { IGSVectorTileLayer } from "@mapgis/webclient-common"
// 添加图层
const igsVectorTileLayer = new IGSVectorTileLayer({
// 服务基地址
url: 'http://{ip}:{port}/igs/rest/services/{serviceName}/VectorTileServer'
});
igsVectorTileLayer.on('layerview-created', function (result) {
console.log("加载完毕:", result.layer)
// 根据id获取子图层
const subLayer = igsVectorTileLayer.findSublayerById('图层id')
// 设置子图层显隐
subLayer.visible = false
})
// ES5引入方式
const { IGSVectorTileLayer } = zondy.layer
const { UniqueValueRenderer } = zondy.renderer
const { SimpleFillSymbol,SimpleLineSymbol } = zondy.symbol
const { Color } = zondy
// ES6引入方式
import { IGSVectorTileLayer,UniqueValueRenderer ,SimpleFillSymbol,SimpleLineSymbol,Color} from "@mapgis/webclient-common"
const igsVectorTileLayer = new IGSVectorTileLayer({
// 服务基地址,当不指定图层名称时,默认查询第一个子图层
url: 'http://{ip}:{port}/igs/rest/services/{serviceName}/VectorTileServer',
// 设置子图层专题图
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 { IGSVectorTileLayer } = zondy.layer
const { ClassBreakRenderer } = zondy.renderer
const { SimpleFillSymbol,SimpleLineSymbol } = zondy.symbol
const { Color } = zondy
// ES6引入方式
import { IGSVectorTileLayer,ClassBreakRenderer ,SimpleFillSymbol,SimpleLineSymbol,Color} from "@mapgis/webclient-commo
const igsVectorTileLayer = new IGSVectorTileLayer({
// 服务基地址,当不指定图层名称时,默认查询第一个子图层
url: 'http://{ip}:{port}/igs/rest/services/{serviceName}/VectorTileServer',
// 设置子图层专题图
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: [{
// 最大过滤范围,field对应的值小于maxValue
maxValue: "最大范围",
// 最小过滤范围,field对应的值大于等于minValue
minValue: "最小范围",
// 匹配到该值后的样式
// 因为该数据的几何类型为区,因此设置区样式
symbol: new SimpleFillSymbol({
// 填充颜色
color: 'rgba(1,1,252,1)',
// 线符号样式
outline: new SimpleLineSymbol({
//线符号颜色
color: new Color(255, 1, 0, 1),
//线宽
width: 1
})
})
}]
})
}
]
});
// ES5引入方式
const { IGSVectorTileLayer } = zondy.layer
const { ClassBreakRenderer } = zondy.renderer
const { SimpleFillSymbol,SimpleLineSymbol } = zondy.symbol
const { Color } = zondy
// ES6引入方式
import { IGSVectorTileLayer,ClassBreakRenderer ,SimpleFillSymbol,SimpleLineSymbol,Color} from "@mapgis/webclient-commo
const igsVectorTileLayer = new IGSVectorTileLayer({
// 服务基地址
url: 'http://{ip}:{port}/igs/rest/services/{serviceName}/VectorTileServer'
});
// 根据id获取子图层
const subLayer = igsVectorTileLayer.findSublayerById('子图层id')
// 设置渲染样式-分段专题图
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: [{
// 最大过滤范围,field对应的值小于maxValue
maxValue: "最大范围",
// 最小过滤范围,field对应的值大于等于minValue
minValue: "最小范围",
// 匹配到该值后的样式
// 因为该数据的几何类型为区,因此设置区样式
symbol: new SimpleFillSymbol({
// 填充颜色
color: 'rgba(1,1,252,1)',
// 线符号样式
outline: new SimpleLineSymbol({
//线符号颜色
color: new Color(255, 1, 0, 1),
//线宽
width: 1
})
})
}]
})
// ES5引入方式
const { IGSVectorTileLayer } = zondy.layer
const { SimpleRenderer } = zondy.renderer
const { SimpleFillSymbol,SimpleLineSymbol } = zondy.symbol
const { Color } = zondy
// ES6引入方式
import { IGSVectorTileLayer,SimpleRenderer ,SimpleFillSymbol,SimpleLineSymbol,Color} from "@mapgis/webclient-commo
const igsVectorTileLayer = new IGSVectorTileLayer({
// 服务基地址
url: 'http://{ip}:{port}/igs/rest/services/{serviceName}/VectorTileServer',
// 设置子图层专题图
sublayers: [{
// 子图层id
id: '子图层id',
// 设置渲染样式-统一专题图
renderer: new SimpleRenderer({
// 因为该数据的几何类型为区,因此设置区样式
symbol: new SimpleFillSymbol({
// 填充颜色
color: new zondy.Color(255, 0, 0),
// 外边线样式
outline: new SimpleLineSymbol({
// 线颜色
color: new Color(0, 0, 0),
// 线宽度
width: 1
})
})
})
}]
})
继承关系
成员变量
# readonly currentStyleInfo
当前的矢量瓦片样式信息,包含serviceUrl 、styleUrl 、spriteUrl 、glyphsUrl 以及style
- Inherited From:
# labelsRenderMode
指定矢量瓦片注记的渲染模式,仅在三维上有效; on-screen: 使用Cesium接口实时渲染注记; off-screen: 使用矢量瓦片来绘制注记; 请注意模式切换时,会造成性能损失,在显卡较弱的机器上会出现卡顿现象;
- Inherited From:
方法
# _updateMapInfoSubLayers(mapInfoSubLayers, clientSubLayers)
通过用户设置的子图层参数,更新MapInfo中的子图层参数, 遵循如下规则: 1、如果用户设置的子图层ID和MapInfo的子图层中ID相等,则将用户的设置覆盖服务端设置,同时打一个标签,表示该MapInfo的子图层可以被创建; 2、如果MapInfo的子图层没有和客户设置的子图层匹配上,也打一个标签,表示该MapInfo的子图层不可以被创建; 3、如果clientSubLayers的长度为0,则要创建显示所有子图层,此处clientSubLayers的长度为0表示客户未设置sublayers参数,或sublayers-undefined, 如果用户设置了sublayers=[],则会在_initSubLayers方法中的2.1步骤直接设置样式图层为空
参数:
名称 | 类型 | 描述 |
---|---|---|
mapInfoSubLayers |
Array.<Object> | MapInfo中的子图层参数,同时也是最终的构造参数 |
clientSubLayers |
Array.<Object> | 客户端获取的子图层参数 |
# covertCustomStyleToMVTStyle(customStyle)
将自定义的style转成矢量瓦片的mvtStyle,可有子类或初始化时自定义
参数:
名称 | 类型 | 描述 |
---|---|---|
customStyle |
Object | 自定义的style |
修改好的符合矢量瓦片规范的样式对象
# findSublayerById(sublayerID)
根据子图层id查询图层
参数:
名称 | 类型 | 描述 |
---|---|---|
sublayerID |
String | 图层ID |
示例
// ES5引入方式
const { IGSVectorTileLayer } = zondy.layer
// ES6引入方式
import { IGSVectorTileLayer} from "@mapgis/webclient-common"
const igsVectorTileLayer = new IGSVectorTileLayer({
// 服务基地址
url: 'http://{ip}:{port}/igs/rest/services/{serviceName}/VectorTileServer'
});
map.add(igsVectorTileLayer);
// 根据id获取子图层
const subLayer = igsVectorTileLayer.findSublayerById('子图层id')
# getExtendProperties(styleLayerId, key)
参数:
名称 | 类型 | 描述 |
---|---|---|
styleLayerId |
String | 样式图层id |
key |
String | 额外属性的属性名 |
- Inherited From:
额外属性的属性值
# getLayoutProperties(styleLayerId)
参数:
名称 | 类型 | 描述 |
---|---|---|
styleLayerId |
String | 样式图层id |
- Inherited From:
样式图层布局属性
# getPaintProperties(styleLayerId)
参数:
名称 | 类型 | 描述 |
---|---|---|
styleLayerId |
String | 样式图层id |
- Inherited From:
返回样式图层绘制属性
# getStyleLayer(styleLayerId)
参数:
名称 | 类型 | 描述 |
---|---|---|
styleLayerId |
String | 样式图层的id |
- Inherited From:
样式图层对象
# getStyleLayerIndex(styleLayerId)
参数:
名称 | 类型 | 描述 |
---|---|---|
styleLayerId |
String | 样式图层的id |
- Inherited From:
样式图层的序号
# getStyleLayerVisibility(styleLayerId)
参数:
名称 | 类型 | 描述 |
---|---|---|
styleLayerId |
String | 样式图层id |
- Inherited From:
样式图层可见性状态
# setExtendProperties(styleLayerId, key, value)
参数:
名称 | 类型 | 描述 |
---|---|---|
styleLayerId |
String | 样式图层id |
key |
String | 额外属性的属性名 |
value |
Any | 额外属性的属性值 |
- Inherited From:
# setLayoutProperties(styleLayerId, layout)
参数:
名称 | 类型 | 描述 |
---|---|---|
styleLayerId |
String | 样式图层id |
layout |
Object | 布局属性 |
- Overrides:
# setPaintProperties(styleLayerId, paint)
参数:
名称 | 类型 | 描述 |
---|---|---|
styleLayerId |
String | 样式图层id |
paint |
Object | 绘制属性 |
- Overrides:
# setStyleLayer(styleLayer, index)
参数:
名称 | 类型 | 描述 |
---|---|---|
styleLayer |
Object | 样式图层对象 |
index |
String | 样式图层顺序 |
- Inherited From:
# setStyleLayerVisibility(styleLayerId, visible)
参数:
名称 | 类型 | 描述 |
---|---|---|
styleLayerId |
String | 样式图层id |
visible |
Boolean | 可见性 |
- Inherited From: