Skip to content

Commit

Permalink
fix: 修复聚合点不展示问题
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxingkang committed Aug 29, 2022
1 parent b57f10b commit d8c6cad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions docs/components/MarkerCluster/demos/default.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export default () => {
.then((list: ServiceData[]) => {
setData(list);
setTimeout(() => {
setData(list.slice(0, 50))
}, 2000)
setData((list) => list.slice(0, 50))
}, 10 * 1000)
})
}, []);

Expand Down
12 changes: 6 additions & 6 deletions src/MarkerCluster/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import type { MarkerClusterProps } from './types';

export const setterMap = {
data(val: any[] = [], ins: MarkerLayer, props: MarkerClusterProps) {
if (ins && isArray(val) && val.length) {
if(ins.points.length){
ins.points=[]
ins.clear()
if (ins.getMarkers().length > 0) {
// @ts-ignore
ins.points= [] ;
ins.clear();
}


if (ins && isArray(val) && val.length) {
val.forEach(item => {
const lng = props?.getLng(item) ?? item.lngLat.lng;
const lat = props?.getLat(item) ?? item.lngLat.lat;
Expand All @@ -26,7 +27,6 @@ export const setterMap = {
ins.addMarker(marker);
}
});

}
}
}
Expand Down

0 comments on commit d8c6cad

Please sign in to comment.