# new IGSVectorTileLayer(options)
IGS矢量瓦片图层
支持IGS1.0和2.0两个服务版本,目前二维和三维上支持4326(包括4490,4214以及4610),3857,会自动读取元信息上的坐标系,不需要用户指定,
[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') {
// 你的业务逻辑
}
注意:三维上,不支持简单Marker样式设定;二维上,简单Marker的颜色,外边线样式,旋转角度无法在图层初始化和初始化后修改,须在制作数据时进行指定
参数:
名称 | 类型 | 默认值 | 描述 |
---|---|---|---|
options |
Object | 构造参数 |
|
url |
String | 服务基地址, |
|
minScale |
Number | null | 最小比例尺,只有当地图视图的比例尺大于最小比例尺时显示矢量瓦片图层 |
maxScale |
Number | null | 最大比例尺,只有当地图视图的比例尺小于最大比例尺时显示矢量瓦片图层 |
opacity |
Number | 1 | 图层透明度,0到1之间的值,0为完全透明,1为不透明,参考示例:[设置图层透明度] |
tokenKey |
String | 'token' | token名 |
tokenValue |
String | token值,只有当tokenValue存在时,才会绑定token |
|
visible |
Boolean | true | 图层显示或隐藏,true则显示,false则隐藏,参考示例:[设置图层显隐] |
sublayers |
Array.<IGSVectorTileSubLayer> | [] | 子图层信息。指定的和服务器端获取图层的交集, 默认不设置,加载全部图层。可设置子图层的可见性,以及专题图参数。 |
option.labelsRenderMode |
String | 'off-screen' | 指定矢量瓦片注记的渲染模式,仅在三维上有效。on-screen表示使用三维接口实时渲染注记;off-screen表示通过先将注记渲染到图片上,再通过三维接口渲染到屏幕。 |
options.clippingArea |
Polygon | Extent | Circle | null | null | 图层空间裁剪范围,仅支持多边形裁剪、矩形裁剪、圆形裁剪
专题图参数仅支持IGS2.0服务,目前子图层支持的专题图如下: |
支持如下方法:
[1、根据子图层id查询图层][2、获取矢量瓦片样式]
[3、通过传入的json构造并返回一个新的几何对象]
4、导出为json对象
5、克隆几何对象
[6、获取图层布局属性][7、设置图层布局属性]
[8、获取图层绘制属性]
[9、设置图层绘制属性]
[10、获取图层]
[11、设置图层属性对象]
[12、删除图层]
[13、设置图层可见性]
[14、获取图层可见性]
[15、获取属性过滤条件]
[16、属性过滤]
[17、获取图层最小、最大层级]
[18、设置图层最小、最大层级]
示例
//初始化地图管理容器
// ES5引入方式
const { IGSVectorTileLayer } = Zondy.Layer
const { Map,MapView,SpatialReference } = Zondy
// ES6引入方式
import { IGSVectorTileLayer,Map,MapView } from "@mapgis/webclient-common"
const map = new Map();
//初始化地图引擎
const mapView = new MapView({
//指定视图id
viewId: "viewer-id",
//绑定地图管理容器
map: map
});
//添加矢量瓦片图层
const igsVectorTileLayer = new IGSVectorTileLayer({
url: 'http://{ip}:6163/igs/rest/mrms/tiles/{serviceName}',
spatialReference:new SpatialReference('EPSG:4326')
});
map.add(igsVectorTileLayer);
// ES5引入方式
const { IGSVectorTileLayer } = Zondy.Layer
const { Map,MapView } = Zondy
// ES6引入方式
import { IGSVectorTileLayer } from "@mapgis/webclient-common"
//初始化地图管理容器
const map = new Map();
//初始化地图引擎
const mapView = new MapView({
//指定视图id
viewId: "viewer-id",
//绑定地图管理容器
map: map
});
//添加矢量瓦片图层
const igsVectorTileLayer = new IGSVectorTileLayer({
url: 'http://{ip}:{port}/igs/rest/services/VectorTile/{serviceName}/VectorTileServer'
});
map.add(igsVectorTileLayer);
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/VectorTile/{serviceName}/VectorTileServer',
//默认不设置sublayers,加载全部图层
});
map.add(igsVectorTileLayer);
// ES5引入方式
const { IGSVectorTileLayer } = Zondy.Layer
// ES6引入方式
import { IGSVectorTileLayer } from "@mapgis/webclient-common"
// 添加图层
const igsVectorTileLayer = new IGSVectorTileLayer({
// 服务基地址
url: 'http://{ip}:{port}/igs/rest/services/VectorTile/{serviceName}/VectorTileServer',
// 根据id显示子图层
sublayers: [
{
// 子图层id
id: '子图层id',
// 显示子图层
visible: true
}
]
});
map.add(igsVectorTileLayer);
// ES5引入方式
const { IGSVectorTileLayer } = Zondy.Layer
// ES6引入方式
import { IGSVectorTileLayer } from "@mapgis/webclient-common"
// 添加图层
const igsVectorTileLayer = new IGSVectorTileLayer({
// 服务基地址
url: 'http://{ip}:{port}/igs/rest/services/VectorTile/{serviceName}/VectorTileServer'
});
map.add(igsVectorTileLayer);
igsVectorTileLayer.on('layerview-created', function (result) {
console.log("加载完毕:", result.layer)
// 根据id获取子图层
const subLayer = igsVectorTileLayer.findSublayerById('图层id')
// 设置子图层显隐
subLayer.visible = false
// 视点跳转
sceneView.flyTo({
extent: result.layer.extent
})
})
// 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/VectorTile/{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)
})
}]
})
}
]
});
map.add(igsVectorTileLayer);
// 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/VectorTile/{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
})
})
}]
})
}
]
});
map.add(igsVectorTileLayer);
// 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/VectorTile/{serviceName}/VectorTileServer'
});
map.add(igsVectorTileLayer);
// 根据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/VectorTile/{serviceName}/VectorTileServer',
// 设置渲染样式-统一专题图
renderer: new SimpleRenderer({
// 因为该数据的几何类型为区,因此设置区样式
symbol: new SimpleFillSymbol({
// 填充颜色
color: new Zondy.Color(255, 0, 0),
// 外边线样式
outline: new SimpleLineSymbol({
// 线颜色
color: new Color(0, 0, 0),
// 线宽度
width: 1
})
})
})
})
继承关系
成员变量
方法
# static fromJSON(jsonopt)
参数:
名称 | 类型 | 描述 |
---|---|---|
json |
Object | JSON对象 |
示例
// ES5引入方式
const { IGSVectorTileLayer } = Zondy.Layer
// ES6引入方式
import { IGSVectorTileLayer } from "@mapgis/webclient-common"
const json = {
// 服务基地址
url: 'http://{ip}:{port}/igs/rest/services/Tile/{serviceName}/TileServer'
}
const igsVectorTileLayer = new IGSVectorTileLayer.fromJSON(json)
# 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/VectorTile/{serviceName}/VectorTileServer'
});
map.add(igsVectorTileLayer);
// 根据id获取子图层
const subLayer = igsVectorTileLayer.findSublayerById('子图层id')
# getStyleLayer(layerId)
参数:
名称 | 类型 | 描述 |
---|---|---|
layerId |
String | 图层id |
图层对象。可以查看矢量瓦片json中layers属性对图层的定义或者查看mvt style文件标准。
# loadStyle()
返回mvtStyle
示例
// ES5引入方式
const { IGSVectorTileLayer } = Zondy.Layer
// ES6引入方式
import { IGSVectorTileLayer} from "@mapgis/webclient-common"
const igsVectorTileLayer = new IGSVectorTileLayer.({
// 服务基地址
url: 'http://{ip}:{port}/igs/rest/services/VectorTile/{serviceName}/VectorTileServer'
});
const style=igsVectorTileLayer.loadStyle()
# setStyleLayerFilter(layerId, filter)
参数:
名称 | 类型 | 描述 |
---|---|---|
layerId |
String | 图层ID |
filter |
Array.<String> | 过滤条件数组 |
# setStyleLayerZoomRange(layerId, minZoom, maxZoom)
参数:
名称 | 类型 | 描述 |
---|---|---|
layerId |
String | 图层id |
minZoom |
Number | 最小层级 |
maxZoom |
Number | 最大层级 |
# toJSON()
转换为json对象
json对象