Skip to content

Commit

Permalink
chore: mock 数据替换
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxingkang committed Jan 19, 2024
1 parent 6ec86b9 commit 40d15bd
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions stories/examples/ClusterPro.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,37 @@
import React, { useRef, useEffect, useState } from 'react';
import React, { useRef, useState } from 'react';
import { Avatar } from 'antd';
import { Map, Marker, StyleLoadFinish, MarkerCluster } from '../../src';

import type { Meta, StoryObj } from '@storybook/react';
import type { Supercluster, MarkerClusterProps } from '../../src';

const randomLnglat = () => [100 + Math.random() * 20, 30 + Math.random() * 20];

const getFeatures = (len = 10): MarkerClusterProps['data'] =>
Array(len)
.fill(true)
.map((item, index) => {
return {
type: 'Feature',
geometry: {
type: 'Point',
coordinates: randomLnglat(),
},
properties: [
{
id: index,
name: `name${index}`,
},
],
};
});

const meta = {
title: '示例/ClusterPro',
render: () => {
const [features, setFeatures] = useState<MarkerClusterProps['data']>([]);
const [features, setFeatures] = useState<MarkerClusterProps['data']>(getFeatures());
const clusterRef = useRef<Supercluster>(null);

useEffect(() => {
fetch('https://docs.mapbox.com/mapbox-gl-js/assets/earthquakes.geojson')
.then((res) => res.json())
.then((data) => {
setFeatures(data.features);
});
}, []);

return (
<Map
zoom={3}
Expand Down

0 comments on commit 40d15bd

Please sign in to comment.