绘制等值线色块图
使用示例
下载示例中的:geojsonData
下载示例中的:breaks
const layer = hnsdk.drawChoropleth(geojsonData, {
breaks,
zProperty: "break",
created(feature, layer) {
layer.on("mouseover", () => {
layer.setStyle({
fillOpacity: 0.9,
});
});
layer.on("mouseout", () => {
layer.setStyle({
fillOpacity: 0.4,
});
});
},
});
layer.addTo(map)
Creation
| 构造函数 | 说明 |
|---|---|
| hnsdk.drawChoropleth(geojsonData , options) | 给出一个Layer对象,通过传递 geojson 格式的矩阵数据得到计算好等值面的 Layer 对象 |
Options 选项
| 选项 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| breaks | Array | 必填 | 计算等值线的分级数组,每个选项是对象 break 为参与计算的属性,并可以添加 PathOptions 属性来设置不同级别的等值面样式 |
| zProperty | String | 必填 | 函数第一个入参 geojsonData 内 properties 属性中参与等值线计算的属性 |
| created | Function | * | 在每个等值面的 Layer 对象被创建后执行的函数,有两个参数: feature , layer;feature 为每个等值面的 geojson 数据,layer 为等值面图层实例对象 |
Events 事件
Methods 方法
| 方法名 | 返回值 | 说明 |
|---|---|---|
addData(data) | this | 将一个 GeoJSON 对象添加到图层中。 |
resetStyle(layer?) | this | 将给定的矢量图层的样式重置为原始的 GeoJSON 样式,对于在悬停事件后重置样式很有用。如果省略了 |
setStyle(style) | this | 用给定的样式函数改变 GeoJSON 矢量图层的样式。 |
| 方法名 | 返回值 | 说明 |
|---|---|---|
bringToFront() | this | 将图层组置于所有其他图层的顶部。 |
bringToBack() | this | 将图层组置于所有其他图层的底部。 |
getBounds() | LatLngBounds | 返回要素组的 LatLngBounds(由其子节点的边界和坐标创建)。 |
| 方法名 | 返回值 | 说明 |
|---|---|---|
toGeoJSON(precision?) | Object | 坐标值使用具有指定 |
addLayer(layer) | this | 将给定的图层添加到组中。 |
removeLayer(layer) | this | 将给定的图层从组中移除。 |
removeLayer( id) | this | 将具有给定内部ID的图层从组中移除。 |
hasLayer(layer) | Boolean | 如果给定的图层当前被添加到组中,则返回 |
hasLayer( id) | Boolean | 如果给定的内部 ID 当前被添加到组中,则返回 |
clearLayers() | this | 移除组中的所有图层。 |
invoke( methodName, …) | this | 对该组中包含的每个图层调用 |
eachLayer( fn, context?) | this | 遍历该组的各图层,可以选择指定迭代器函数的上下文。 |
getLayer( id) | Layer | 返回具有给定内部 ID 的图层。 |
getLayers() | Layer[] | 返回所有添加到组中的图层的数组。 |
setZIndex( zIndex) | this | 对包含在该组中的每个图层调用 |
getLayerId(layer) | Number | 返回一个图层的内部 ID |
