Class: Cluster

.Visuals.Custom. Cluster

聚合图层

new Cluster(options)

Parameters:
Name Type Description
options Object
Properties
Name Type Description
id String 图层id
data Array 数据,geojson格式
visibility Boolean 图层默认是否显示
markClusterMaxZoom Number 聚合标注最大层级
rendererOptions Object 渲染配置
Properties
Name Type Description
markPoint Object 标注
Properties
Name Type Description
nameField String 属性名动态选取,可缺省,缺省使用name属性字段
hoverable Boolean 是否启用鼠标悬浮
clickable Boolean 是否启用鼠标点击
symbol String 标注图形类型,可选为:'round' | 'icon'
symbolSrc String 标注图标文件路径
symbolSize Number 标注大小
symbolWidth Number 标注宽度
symbolHeight Number 标注高度
itemStyle Object 图形样式属性
Properties
Name Type Description
color String 标注颜色
lineWidth Number 外圈宽度
lineColor String 外圈颜色
shadowColor String 阴影颜色
shadowBlur Number 阴影模糊度
shadowOffsetX Number 阴影偏移量X
shadowOffsetY Number 阴影偏移量Y
markCluster Object 聚合标注
Properties
Name Type Description
hoverable Boolean 是否启用鼠标悬浮
clickable Boolean 是否启用鼠标点击
symbol String 聚合标注图形类型,可选为:'round' | 'icon'
symbolSrc String | Array 聚合标注图标文件路径,支持仅配置一张用来配色的白色样图,也支持配置直接使用的多张图片
symbolSize Array 聚合标注大小
itemStyle Object 图形样式属性
Properties
Name Type Description
color Array 聚合标注颜色
lineWidth Number 外圈宽度
lineColor String 外圈颜色
shadowColor String 阴影颜色
shadowBlur Number 阴影模糊度
shadowOffsetX Number 阴影偏移量X
shadowOffsetY Number 阴影偏移量Y
label Object 标签
Properties
Name Type Description
show Boolean 标签是否显示
color String 颜色
align String 水平对齐方式,可选为:'start' | 'end' | 'left' | 'right' | 'center'
baseline String 垂直对齐方式,可选为:'top' | 'hanging' | 'middle' | 'alphabetic' | 'ideographic' | 'bottom'
fontFamily String 字体系列
fontSize Number 字号 ,单位px
fontStyle String 样式,可选为:'normal' | 'italic' | 'oblique'
fontWeight String/Number 粗细,可选为:'normal' | 'bold' | 'bolder' | 'lighter' | 100 | 200 |... | 900
tooltip Object 悬浮提示
Properties
Name Type Description
show Boolean 是否显示悬浮提示框
backgroundColor String 背景颜色
borderColor String 边框颜色
borderRadius Number 边框圆角
borderWidth Number 边框宽度
padding Number 内边距
textStyle Object 文字样式
Properties
Name Type Description
color String 颜色
fontFamily String 字体系列
fontSize Number 字号 ,单位px
fontStyle String 样式,可选为:'normal' | 'italic' | 'oblique'
fontWeight String/Number 粗细,可选为:'normal' | 'bold' | 'bolder' | 'lighter' | 100 | 200 |... | 900
Author:
  • kz
Source:
View2D/Visuals/Custom/Cluster.js
Example
//构造地图对象
 var map = new GeoGlobe.Map({
    style: Cfg.style,
    container: 'map',
    zoom: 11,
    bearing: 0,
	pitch: 0,
    units: "degrees",
    center: [114.77402594421665, 30.28162351834304]
 });
 //构造可视化定制图层
 var custom = new GeoGlobe.Visuals.Custom();
 //添加到地图中
 custom.addTo(map);
 //构造聚合图层
 var cluster = new GeoGlobe.Visuals.Custom.Cluster({
    id: "cluster_1",
    data: data,
    visibility: true,
    markClusterMaxZoom: 18,
    rendererOptions: {
        markPoint: {
            symbol: 'round',
            symbolSize: 8,
            itemStyle: {
                color: '#f00',
                lineWidth: 1,
                lineColor: '#fff',
                shadowColor: '#000000',
                shadowBlur: 0,
                shadowOffsetX: 0,
                shadowOffsetY: 0
            }
        },
        markCluster: {
            symbol: 'round',
            // symbol: 'icon',
            // symbolSrc: 'http://' + Cfg.host + '/' + Cfg.projectName + '/JsCodeDemo_new/images/bubble.png',
            // symbolSrc: [
            //     [0, 'bubble1.png'],
            //     [9, 'bubble2.png'],
            //     [99, 'bubble3.png']
            // ],
            symbolSize: [
                [0, 40],
                [9, 60],
                [99, 80]
            ],
            itemStyle: {
                color: [
                    [0, 'rgba(0, 0, 255, 0.7)'],
                    [9, 'rgba(0, 255, 0, 0.7)'],
                    [99, 'rgba(255, 0, 0, 0.7)']
                ],
                lineWidth: 3,
                lineColor: '#fff',
                shadowColor: '#000',
                shadowBlur: 0,
                shadowOffsetX: 0,
                shadowOffsetY: 0
            },
            label: {
                show: true,
                color: '#fff',
                align: 'center',
                baseline: 'middle',
                fontFamily: 'serif',
                fontSize: 12,
                fontStyle: 'normal',
                fontWeight: 'normal'
            }
        },
        tooltip: {
            show: true,
            backgroundColor: '#fff',
            borderColor: '#333',
            borderRadius: 0,
            borderWidth: 0,
            padding: 10,
            textStyle: {
                color: "#000",
                fontFamily: 'serif',
                fontSize: 12,
                fontStyle: 'normal',
                fontWeight: 'normal'
            }
        }
    }
});
 //添加到可视化定制图层
 cluster.addTo(custom);
 //绘制
 custom.render();

Members


cacheCanvas :Array

离屏画布集合
Type:
  • Array
Source:
View2D/Visuals/Custom/Cluster.js

cacheCanvasContext :Array

离屏画布的上下文集合
Type:
  • Array
Source:
View2D/Visuals/Custom/Cluster.js

canvas :Array

画布集合,使用分层画布分别绘制
Type:
  • Array
Source:
View2D/Visuals/Custom/Cluster.js

canvasContext :Array

画布的上下文集合
Type:
  • Array
Source:
View2D/Visuals/Custom/Cluster.js

MarkCluster :function

聚合标注类
Type:
  • function
Source:
View2D/Visuals/Custom/Cluster.js

markClusterMaxZoom :Number

聚合标注最大层级
Type:
  • Number
Source:
View2D/Visuals/Custom/Cluster.js

markClusterZoomMap :Array

聚合标注层级数据集合
Type:
  • Array
Source:
View2D/Visuals/Custom/Cluster.js

MarkPoint :function

标注类
Type:
  • function
Source:
View2D/Visuals/Custom/Cluster.js

markPoints :Array

标注对象集
Type:
  • Array
Source:
View2D/Visuals/Custom/Cluster.js

Methods


addTo(custom)

关联可视化定制图层对象
Parameters:
Name Type Description
custom GeoGlobe.Visuals.Custom 可视化定制图层对象
Source:
View2D/Visuals/Custom/Cluster.js

clearCanvas()

画布清空
Source:
View2D/Visuals/Custom/Cluster.js

destroy()

画布销毁
Source:
View2D/Visuals/Custom/Cluster.js

draw()

图层绘制
Source:
View2D/Visuals/Custom/Cluster.js

drawCanvas()

将标注或聚合标注到画布
Source:
View2D/Visuals/Custom/Cluster.js

drawCanvasFrame()

将标注或聚合标注动画帧绘制到画布
Source:
View2D/Visuals/Custom/Cluster.js

hideTooltip()

关闭悬浮提示
Source:
View2D/Visuals/Custom/Cluster.js

hover(x, y)

鼠标悬浮时触发
Parameters:
Name Type Description
x Number 鼠标在主画布上的位置(x轴方向)
y Number 鼠标在主画布上的位置(y轴方向)
Source:
View2D/Visuals/Custom/Cluster.js

initialize(options)

构造函数
Parameters:
Name Type Description
options Object 参数对象
Source:
View2D/Visuals/Custom/Cluster.js

onClick(event)

鼠标指针单击事件
Parameters:
Name Type Description
event Object 事件参数
Source:
View2D/Visuals/Custom/Cluster.js

onMouseMove(event)

鼠标指针悬停事件
Parameters:
Name Type Description
event Object 事件参数
Source:
View2D/Visuals/Custom/Cluster.js

onMove()

图层(地图)移动时触发
Source:
View2D/Visuals/Custom/Cluster.js

onMoveEnd()

图层(地图)移动结束时触发
Source:
View2D/Visuals/Custom/Cluster.js

onResize()

图层自适应
Source:
View2D/Visuals/Custom/Cluster.js

onZoomEnd()

图层(地图)缩放结束时触发
Source:
View2D/Visuals/Custom/Cluster.js

onZoomStart()

图层(地图)缩放开始时触发
Source:
View2D/Visuals/Custom/Cluster.js

redraw()

图层重绘
Source:
View2D/Visuals/Custom/Cluster.js

render()

渲染图层
Source:
View2D/Visuals/Custom/Cluster.js

setData(data)

数据的处理,构造标注和聚合标注对象层级数据集合
Parameters:
Name Type Description
data Array 数据
Source:
View2D/Visuals/Custom/Cluster.js

setVisible(visibility)

图层的显示与隐藏
Parameters:
Name Type Description
visibility Boolean 可见性
Source:
View2D/Visuals/Custom/Cluster.js

stopDraw()

停止绘制
Source:
View2D/Visuals/Custom/Cluster.js

updateMarkClusterXY(zoom)

更新聚合标注的屏幕坐标
Parameters:
Name Type Description
zoom Number 更新的层级
Source:
View2D/Visuals/Custom/Cluster.js

updateMarkPointXY()

更新标注的屏幕坐标
Source:
View2D/Visuals/Custom/Cluster.js

updateXY()

更新屏幕坐标
Source:
View2D/Visuals/Custom/Cluster.js