Summary
Methods:
fromHMapPlatform |
通过空间信息服务平台元数据创建图层 |
addFilter |
添加图层过滤行为。从特定的数据图层中筛选符合设置条件的要素,并对其进行可见性设置。 |
destroy |
销毁自定义矢量瓦片图层。 |
getAllDataLayers |
获取所有数据图层。 |
getDataLayer |
根据数据图层标识获取数据图层。 |
getFeaturesByAttribute |
根据属性获取要素数组。 |
getLabelOn |
获取注记启用状态。 |
getLayerFields |
获取指定数据图层的输出字段。 |
getLayerType |
获取自定义矢量瓦片图层的图层类型。 |
getLineLableVisibility |
获取线注记(比如道路名称)的可见性。 |
getLinePainterVisible |
用于切换拉高及不拉高的线painter进行显示 |
getMarkerVisibility |
获取图标注记(比如POI点图标)的可见性。 |
getPointLableVisibility |
获取点文字注记(比如POI点的名称)的可见性。 |
setAdminCode |
设置行政区划编码。该行政区划将作为范围,只请求该范围内的数据。 |
setAdminLevel |
设置要展示的行政区划级别。设置后将只显示该行政级别对应的数据。 |
setClampMode |
设置贴地模式 |
setDataLayerVisibility |
设置指定数据图层的可见性。 |
setLabelOn |
开启或者关闭指定类型的注记。自定义矢量瓦片注记分为三种:a)、图标:比如POI(兴趣点)的图标。b)、线文字,比如道路注记。c)、点|面文字,比如兴趣点或者兴趣面的名称。 |
setLineLableVisibility |
设置线注记(比如道路名称)的可见性。 |
setMarkerVisibility |
设置图标注记(比如POI点图标)的可见性。 |
setOpacity |
设置图层不透明度。0表示完全透明,1表示完全不透明。从0到1,越来越不透明。 |
setPointLableVisibility |
设置点文字注记(比如POI点的名称)的可见性。 |
updateIcons |
更新图标。 |
updateLayerStyle |
单个数据图层样式的更新。注意,该接口只在当前会话周期里有效,不会持久化。 |
updateStyle |
更新自定义矢量瓦片图层的样式文件,不更新字体和图标。 |
updateTheme |
更新自定义矢量瓦片图层的主题风格,同时更新字体和图标文件。 |
Constructor
new VectorTileJSONLayer(name, url, options)
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
String | 自定义矢量瓦片图层的名称。 |
||||||||||||||||||||||||||||||||||||
url |
String | 自定义矢量瓦片的服务地址。 |
||||||||||||||||||||||||||||||||||||
options |
Object |
|
Example
//自定义矢量瓦片服务地址
const serviceUrl="https://hmap.hikvision.com.cn/hmappublish/service/rs/v1/vector_tile/geojson_tile/hmapdemo_xihu_geojsontile/";
//自定义矢量瓦片的样式地址,style.json为入口文件,其同级需包含字体样式和图标样式
const styleUrl="../public/style/hvj/style.json";
let layer = new hmap.layer.VectorTileJSONLayer('geojsonTile', serviceUrl, {
dataFormat: "json",//数据类型
labelOn:true,//显示注记
styleUrl: styleUrl
});
Members
-
clampToGround
-
设置贴地状态
-
depthTest
-
获取图层的深度测试属性
return {Boolean} 深度测试属性- Overrides:
Methods
-
static fromHMapPlatform(metadataUrl, options) → {Promise}
-
通过空间信息服务平台元数据创建图层
Parameters:
Name Type Description metadataUrl
String 空间信息服务平台服务对应的元数据地址
options
options 可选项,对空间信息服务平台元数据不包含的可选项进行补充,若传入的可选项与元数据中重复,以元数据为准。
Returns:
Promise -图层创建的promise,resolve返回图层实例
-
addFilter(layerId, name, value, visibility) -
添加图层过滤行为。从特定的数据图层中筛选符合设置条件的要素,并对其进行可见性设置。
Parameters:
Name Type Default Description layerId
String 数据图层标识。
name
String 要素属性名。
value
String 要素属性值。
visibility
String false 过滤到的要素,设置可见性,缺省false,隐藏要素。
- Deprecated:
- Yes
-
destroy()
-
销毁自定义矢量瓦片图层。
-
getAllDataLayers() → {Array.<Object>}
-
获取所有数据图层。
Returns:
Array.<Object> -所有数据图层对象构成的数组。图层对象的键值包括id(数据图层唯一标识)、name(数据图层名称)、fields(数据图层的输出字段)、style(样式)、dispaly(可见性)。
Example
gjtLayer.getAllDataLayers()
-
getDataLayer(layerId) → {Object|null}
-
根据数据图层标识获取数据图层。
Parameters:
Name Type Description layerId
String 数据图层标识。
Returns:
Object | null -返回图层的部分属性,键值为id、name、fields、style、display。
-
getFeaturesByAttribute(layerid, attrName, attrValue) → {Array.<module:feature~Vector>}
-
根据属性获取要素数组。
Parameters:
Name Type Description layerid
String 数据图层标识。
attrName
String 属性名称。
attrValue
String 属性值。
Example
let features = vectorLayer.getFeaturesByAttribute("755038bf-fcd7-4ca5-9a2e-61c5f1adad2d","name", 205);//从数据图层标识为"755038bf-fcd7-4ca5-9a2e-61c5f1adad2d"的数据图层上,得到name值为205的要素数组
-
getLabelOn() → {Boolean}
-
获取注记启用状态。
Returns:
Boolean -注记启用状态。
-
getLayerFields(layerid) → {Array.<String>}
-
获取指定数据图层的输出字段。
Parameters:
Name Type Description layerid
String 数据图层标识,空间信息服务平台构建数据集时生成。
Returns:
Array.<String> -返回数据图层的输出字段。
-
getLayerType() → {String}
-
获取自定义矢量瓦片图层的图层类型。
Returns:
String -图层类型。
-
getLineLableVisibility() → {Boolean}
-
获取线注记(比如道路名称)的可见性。
Returns:
Boolean -线注记的可见性。
-
getLinePainterVisible(painter)
-
用于切换拉高及不拉高的线painter进行显示
Parameters:
Name Type Description painter
* 传入的painter,判断painter是否为线painter,并根据min3DLevel判断当前是否需要显示
-
getMarkerVisibility() → {Boolean}
-
获取图标注记(比如POI点图标)的可见性。
Returns:
Boolean -图标类注记的可见性。
-
getPointLableVisibility() → {Boolean}
-
获取点文字注记(比如POI点的名称)的可见性。
Returns:
Boolean -点文字注记的可见性。
-
setAdminCode(code)
-
设置行政区划编码。该行政区划将作为范围,只请求该范围内的数据。
Parameters:
Name Type Description code
String 行政区划编码。
-
setAdminLevel(level)
-
设置要展示的行政区划级别。设置后将只显示该行政级别对应的数据。
Parameters:
Name Type Description level
String 行政区划级别 取值分别为'PROVINCE'、'CITY'、'COUNTY'、'TOWN',分别代表省、市、县、乡镇四级行政区划级别。
-
setClampMode(mode)
-
设置贴地模式
Parameters:
Name Type Description mode
String 贴地模式,具体说明见构造函数ClampMode可选项
-
setDataLayerVisibility(layerId, visibility)
-
设置指定数据图层的可见性。
Parameters:
Name Type Description layerId
String 数据图层的标识。
visibility
Boolean 图层的可见性。
-
setLabelOn(flag, tag, autoDraw)
-
开启或者关闭指定类型的注记。自定义矢量瓦片注记分为三种:a)、图标:比如POI(兴趣点)的图标。b)、线文字,比如道路注记。c)、点|面文字,比如兴趣点或者兴趣面的名称。
Parameters:
Name Type Default Description flag
Boolean 是否启用地图注记。
tag
Number 7 要调整的注记类型,是一个3位的二进制数转换而来的十进制,取值范围为[0,7],这个3位的二进制,从右往左分别代表三种注记类型。
第一位表示点图标,第二位表示线文字,第三位表示点|面文字。
每一位的二进制的值可取0或1,1表示当前位代表的注记类型参与本次注记开关,0表示不参加。
eg:tag为3,对应的二进制为011,代表点图标,线文字参与本次注记的开关,状态调整为flag,点|面文字保持现状。autoDraw
Boolean true 调整完后是否主动重绘,默认值为true。
-
setLineLableVisibility(visibility, autoDraw)
-
设置线注记(比如道路名称)的可见性。
Parameters:
Name Type Default Description visibility
Boolean 是否可见。
autoDraw
Boolean true 是否自动重绘,默认为true,自动重绘。
-
setMarkerVisibility(visibility, autoDraw)
-
设置图标注记(比如POI点图标)的可见性。
Parameters:
Name Type Default Description visibility
Boolean 是否可见。
autoDraw
Boolean true 是否重绘,默认为true,自动重绘。
-
setOpacity(opacity)
-
设置图层不透明度。0表示完全透明,1表示完全不透明。从0到1,越来越不透明。
Parameters:
Name Type Default Description opacity
Number 1 图层不透明度,介于0~1之间。
-
setPointLableVisibility(visibility, autoDraw)
-
设置点文字注记(比如POI点的名称)的可见性。
Parameters:
Name Type Default Description visibility
Boolean 是否可见。
autoDraw
Boolean true 是否重绘,默认为true,自动重绘。
-
updateIcons(url, callback, updateTexture)
-
更新图标。
Parameters:
Name Type Default Description url
String 图标的路径或地址:该路径下需要包括命名为icons.png和命名为icons.json的两个文件。
callback
function 更新操作之后的回调函数。
updateTexture
Boolean true 是否立即更新。
Example
//图标路径 const url="../../hmap/geoJsonTileStyle/"; tileJsonLayer.updateIcons(url,function(){console.log("图标样式已更新!")});
-
updateLayerStyle(layerId, style)
-
单个数据图层样式的更新。注意,该接口只在当前会话周期里有效,不会持久化。
Parameters:
Name Type Description layerId
* 数据图层标识。
style
* 更新的样式,规格标准见空间信息服务平台地图服务中的自定义矢量瓦片服务。
Example
//设置数据图层标识为'485ec9f0-4991-4200-944b-25b71d525a77'的数据图层的样式 vectorTileJSONLayer.updateLayerStyle('485ec9f0-4991-4200-944b-25b71d525a77',{ "markerSymbols": [{ "unicode": "", "fontSize": 50, "fillColor": "#0000FF", "outlineWidth": 0, "display": true }, { "unicode": "", "fontSize": 50, "fillColor": "#FF0000", "outlineColor": "#00FF00", "outlineWidth": 6, "display": true }] })
-
updateStyle(styleUrl, callback)
-
更新自定义矢量瓦片图层的样式文件,不更新字体和图标。
Parameters:
Name Type Default Description styleUrl
String 样式文件地址。
callback
function null 样式风格更新后的回调函数。
Example
tileJsonlayer.updateStyle("http://10.20.84.15:8080/mapStyle.json",function(){});
-
updateTheme(styleUrl, callback)
-
更新自定义矢量瓦片图层的主题风格,同时更新字体和图标文件。
Parameters:
Name Type Default Description styleUrl
String 样式文件地址。
callback
function null 自定义矢量瓦片图层主题更新后的回调。
Example
//主题或样式地址,该样式文件(例mapStyle.json)同级目录下需包含字体文件(命名为chars.png、chars.json)和图标文件(命名为icons.png、icons.json)。 const styleUrl="http://10.20.84.15:8080/mapStyle.json"; tileJsonlayer.updateTheme(styleUrl,function(){console.log("主题已更新!")});