2.1.0 • Published 5 years ago

amap-cluster-canvas v2.1.0

Weekly downloads
4
License
ISC
Repository
github
Last release
5 years ago

amap-cluster-canvas

高德地图点聚合插件 canvas 版本

配置项

属性类型描述默认值
dataArray数据集null
coordinateCoordinate聚合策略Coordinate.AMAP
maxZoomNumber最大的聚合级别,大于该级别就不进行相应的聚合18
gridSizeNumber聚合计算时,网格的像素大小60
minClusterSizeNumber聚合的最小数量,小于该数量个点则不能成为一个聚合2
averageCenterBoolean是否取所有点的平均值作为聚合点中心true
zoomOnClickBoolean点击聚合点时,是否展开聚合true
zIndexNumbercanvas 图层的 zindex120
visibleBoolean是否显示true
getPositionFunction获取经纬度信息({location})=>location ? location.longitude,location.latitude : null
renderFunction绘制函数null
hoverRenderFunctionhover 状态下的绘制函数null
clickHandlerFunctionclick 事件null
mouseoutHandlerFunctionmouseout 事件null
mouseoverHandlerFunctionmouseover 事件null
mousemoveHandlerFunctionmousemove 事件null
normalPointStyleObject实体点的样式defaultStyle
clusterPointStyleObject聚合点的样式defaultStyle
hoverNormalPointStyleObjecthover 状态下实体点的样式defaultStyle
hoverClusterPointStyleObjecthover 状态下聚合点的样式defaultStyle
2.0 版本新增
offsetArray绘制的图形相对于 定位点 的偏移度null

实例方法

方法描述参数
setData设置数据data: 数据源,rebuild: 是否重新构建绘制(可选,默认:true
render立即重绘-
renderLaterthrottle 版本number
destroy销毁-

Coordinate

点的聚合策略:

  1. 根据点在 地图容器 上的相对坐标来判断是否需要聚合。
  2. 根据点在 墨卡托坐标系 上的绝对坐标进行聚合。
// cluster.js
export const Coordinate = {
  AMAP: 'AMAP',
  MERCATOR: 'MERCATOR',
}

defaultStyle

点的默认样式:因为时间紧迫,并没有提供内置的点绘制功能,样式配置主要是提供点的 width & height 属性;因为 canvas 事件中需要根据点的坐标与点的大小查找当前事件的触发对象。

// 默认的点样式
const defaultStyle = {
  width: 60,
  height: 69,
}

offset

绘制的图形相对于 定位点 的偏移度。

// 支持 百分比 || px
const offsetItem = Number | String
const offset = [offsetItem, offsetItem]

事件

直接使用参数的形式进行事件处理,简单暴力。

测试

1、git clone git@github.com:liuweiGL/amap-cluster-canvas.git
2、npm install
3、npm start

打包

npm run build
2.1.0

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.1.5

5 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago