new IGSVectorTileLayer(options)
支持如下方法:
[1、根据子图层id查询图层][2、通过传入的json构造并返回一个新的IGSVectorTileLayer对象]
[3、导出为json对象]
4、通过矢量瓦片样式图层的id,找到对应的矢量瓦片样式图层对象5、通过矢量瓦片样式图层的id,找到对应的矢量瓦片样式图层的序号6、通过矢量瓦片样式图层的序号,找到对应的矢量瓦片样式图层的id7、设置样式图层属性对象8、删除样式图层9、设置样式图层可见性10、获取样式图层可见性11、获取样式图层绘制属性12、设置样式图层绘制属性13、获取样式图层布局属性14、设置样式图层布局属性17、克隆图层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的颜色,外边线样式,旋转角度无法在图层初始化和初始化后修改,须在制作数据时进行指定
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
构造参数
|
Fires
- Layer#event:图层加载完毕事件
- Layer#event:图层销毁完毕事件
- Layer#event:图层更新完毕事件
- Layer#event:图层显隐更新完毕事件
- Layer#event:图层透明度更新完毕事件
Examples
//初始化地图管理容器
// ES5引入方式
const { IGSVectorTileLayer } = zondy.layer
const { SpatialReference } = zondy
// ES6引入方式
import { IGSVectorTileLayer, SpatialReference } 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({
// 矢量瓦片基地址
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
})
})
})
}]
})
Extends
Members
-
allSublayersCollection
-
所有子图层对象信息
-
clippingAreaPolygon Extent Circle MultiPolygon null
-
空间裁剪范围
-
currentStyleInfoObject
-
当前的矢量瓦片样式信息,包含serviceUrl 、styleUrl 、spriteUrl 、glyphsUrl 以及style
-
descriptionString
-
图层描述
- Default Value: IGS矢量瓦片图层
descriptionString
图层描述
- Default Value: IGS矢量瓦片图层
labelsRenderModeString
指定矢量瓦片注记的渲染模式,仅在三维上有效; on-screen: 使用Cesium接口实时渲染注记; off-screen: 使用矢量瓦片来绘制注记; 请注意模式切换时,会造成性能损失,在显卡较弱的机器上会出现卡顿现象;
mvtExtentNumber
mvt矢量瓦片相对坐标范围,默认为4096,表示矢量瓦片相对坐标的范围为0到4096
- Default Value: 4096
replaceStyleURLBoolean
初始化图层时,是否将样式中的基地址替换为图层的基地址
- Default Value: true
replaceStyleURLRegExpRegExp
当replaceStyleURL设置为true时,将样式中的基地址替换为图层的基地址操作中使用的正则表达式
sublayersCollection
子图层列表对象
tileDisplayStrategyTileDisplayStrategy
当瓦片图层的显示比例尺范围,超出瓦片数据自身的级别后的显示策略
tileInfoTileInfo
瓦片切图信息
titleString
图层名称
typeLayerType
图层类型
- Default Value: LayerType.IGSVectorTile
urlString
矢量瓦片服务地址
Methods
-
IGSVectorTileLayer.fromJSON(json){IGSVectorTileLayer}
document/layer/igserver/IGSVectorTileLayer.js, line 988 -
Name Type Description jsonObject JSON对象
Returns:
Type Description IGSVectorTileLayer 新的VectorTileLayer对象 -
inherited _initMapInfo(customStyle){*}
document/layer/baseLayer/VectorTileLayer.js, line 615 -
初始化mapInfo
Name Type Description customStyle* Returns:
Type Description * -
clone(){IGSVectorTileLayer}
document/layer/igserver/IGSVectorTileLayer.js, line 1008 -
克隆对象
Returns:
Type Description IGSVectorTileLayer IGS矢量瓦片对象 -
covertCustomStyleToMVTStyle(customStyle){Object}
document/layer/igserver/IGSVectorTileLayer.js, line 628 -
将自定义的style转成矢量瓦片的mvtStyle,可有子类或初始化时自定义
Name Type Description customStyleObject 自定义的style
Returns:
Type Description Object 修改好的符合矢量瓦片规范的样式对象 -
inherited deleteStyleLayer(styleLayerId)
document/layer/baseLayer/VectorTileLayer.js, line 460 -
Name Type Description styleLayerIdString 样式图层id
-
inherited findSublayerById(sublayerID){IGSVectorTileSubLayer}
document/layer/baseLayer/VectorTileLayer.js, line 894 -
根据子图层id查询图层
Name Type Description sublayerIDString 图层ID
Returns:
Type Description IGSVectorTileSubLayer 子图层 Example
根据子图层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') -
inherited getExtendProperties(styleLayerId, key){Any}
document/layer/baseLayer/VectorTileLayer.js, line 602 -
Name Type Description styleLayerIdString 样式图层id
keyString 额外属性的属性名
Returns:
Type Description Any 额外属性的属性值 -
inherited getLayoutProperties(styleLayerId){Object|null}
document/layer/baseLayer/VectorTileLayer.js, line 549 -
Name Type Description styleLayerIdString 样式图层id
Returns:
Type Description Object | null 样式图层布局属性 -
inherited getPaintProperties(styleLayerId){Object|null}
document/layer/baseLayer/VectorTileLayer.js, line 514 -
Name Type Description styleLayerIdString 样式图层id
Returns:
Type Description Object | null 返回样式图层绘制属性 -
inherited getStyleLayer(styleLayerId){Object}
document/layer/baseLayer/VectorTileLayer.js, line 379 -
Name Type Description styleLayerIdString 样式图层的id
Returns:
Type Description Object 样式图层对象 -
inherited getStyleLayerId(index){String}
document/layer/baseLayer/VectorTileLayer.js, line 407 -
Name Type Description indexNumber 样式图层的序号
Returns:
Type Description String 样式图层的id -
inherited getStyleLayerIndex(styleLayerId){Number}
document/layer/baseLayer/VectorTileLayer.js, line 395 -
Name Type Description styleLayerIdString 样式图层的id
Returns:
Type Description Number 样式图层的序号 -
inherited getStyleLayerVisibility(styleLayerId){Boolean}
document/layer/baseLayer/VectorTileLayer.js, line 500 -
Name Type Description styleLayerIdString 样式图层id
Returns:
Type Description Boolean 样式图层可见性状态 -
inherited setExtendProperties(styleLayerId, key, value)
document/layer/baseLayer/VectorTileLayer.js, line 585 -
Name Type Description styleLayerIdString 样式图层id
keyString 额外属性的属性名
valueAny 额外属性的属性值
-
inherited setLayoutProperties(styleLayerId, layout)
document/layer/baseLayer/VectorTileLayer.js, line 563 -
Name Type Description styleLayerIdString 样式图层id
layoutObject 布局属性
-
inherited setPaintProperties(styleLayerId, paint)
document/layer/baseLayer/VectorTileLayer.js, line 528 -
Name Type Description styleLayerIdString 样式图层id
paintObject 绘制属性
-
inherited setStyleLayer(styleLayer, index)
document/layer/baseLayer/VectorTileLayer.js, line 419 -
Name Type Description styleLayerObject 样式图层对象
indexString 样式图层顺序
-
inherited setStyleLayerVisibility(styleLayerId, visible)
document/layer/baseLayer/VectorTileLayer.js, line 487 -
Name Type Description styleLayerIdString 样式图层id
visibleBoolean 可见性
-
toJSON(){Object}
document/layer/igserver/IGSVectorTileLayer.js, line 996 -
转换为json对象
Returns:
Type Description Object json对象