mirror of https://gitee.com/antv-l7/antv-l7
feat: add cluster demo
This commit is contained in:
parent
a661d35523
commit
bf1eb7d26b
|
@ -0,0 +1,65 @@
|
|||
import { Scene, PointLayer,Source } from '@antv/l7';
|
||||
import { GaodeMap } from '@antv/l7-maps';
|
||||
|
||||
const scene = new Scene({
|
||||
id: 'map',
|
||||
map: new GaodeMap({
|
||||
center: [ 120.19382669582967, 30.258134 ],
|
||||
pitch: 0,
|
||||
style: 'dark',
|
||||
zoom: 3
|
||||
})
|
||||
});
|
||||
scene.on('loaded', () => {
|
||||
const fontFamily = 'iconfont';
|
||||
const fontPath = '//at.alicdn.com/t/font_2534097_fcae9o2mxbv.woff2?t=1622200439140';
|
||||
scene.addFontFace(fontFamily, fontPath);
|
||||
scene.addIconFont('icon1', '');
|
||||
fetch('https://gw.alipayobjects.com/os/bmw-prod/87e40417-a5da-4fdb-8313-c796ea15f982.csv')
|
||||
.then(res => res.text())
|
||||
.then(data => {
|
||||
const dataSource = new Source(data,{
|
||||
parser:{
|
||||
type:'csv',
|
||||
x:'lng',
|
||||
y:'lat'
|
||||
|
||||
},
|
||||
cluster: true,
|
||||
})
|
||||
const pointLayer = new PointLayer({
|
||||
autoFit:true,
|
||||
})
|
||||
.source(dataSource)
|
||||
.shape('icon1','text')
|
||||
.scale('point_count', {
|
||||
type: 'quantile'
|
||||
})
|
||||
.size('point_count', [ 5, 10, 15, 20, 25 ])
|
||||
.active(true)
|
||||
.color('yellow')
|
||||
.style({
|
||||
opacity: 0.5,
|
||||
strokeWidth: 1,
|
||||
fontFamily,
|
||||
iconfont: true,
|
||||
});
|
||||
|
||||
const pointLayerText= new PointLayer({
|
||||
autoFit:false,
|
||||
})
|
||||
.source(dataSource)
|
||||
.shape('point_count','text')
|
||||
.size('point_count', [ 10,25 ])
|
||||
.active(true)
|
||||
.color('#fff')
|
||||
.style({
|
||||
opacity: 1,
|
||||
strokeWidth: 1,
|
||||
|
||||
});
|
||||
|
||||
scene.addLayer(pointLayer);
|
||||
scene.addLayer(pointLayerText);
|
||||
});
|
||||
});
|
|
@ -8,6 +8,11 @@
|
|||
"filename": "cluster.js",
|
||||
"title": "聚合图",
|
||||
"screenshot": "https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*paQsRKykjL4AAAAAAAAAAABkARQnAQ"
|
||||
},
|
||||
{
|
||||
"filename": "cluster2.js",
|
||||
"title": "充电桩",
|
||||
"screenshot": "https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*paQsRKykjL4AAAAAAAAAAABkARQnAQ"
|
||||
}
|
||||
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue