Skip to content

Commit

Permalink
docs: 更新文档示例
Browse files Browse the repository at this point in the history
  • Loading branch information
lvisei committed Dec 20, 2023
1 parent e6ef5bd commit 161c209
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 45 deletions.
2 changes: 1 addition & 1 deletion docs/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default () => {
style: 'light',
center: [120.210792, 30.246026],
zoom: 9,
// token: 'xxxx - token',
// token: '你的 token',
},
};
const APP = React.createElement(LarkMap, {
Expand Down
1 change: 0 additions & 1 deletion src/components/Control/LogoControl/demos/default.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const config: LarkMapProps = {
style: 'light',
center: [120.210792, 30.246026],
zoom: 9,
// token: 'xxxx - token',
},
style: {
height: '200px',
Expand Down
4 changes: 2 additions & 2 deletions src/components/LarkMap/demos/default.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React from 'react';
import type { LarkMapProps } from '@antv/larkmap';
import { LarkMap } from '@antv/larkmap';
import React from 'react';

const config: LarkMapProps = {
mapType: 'Gaode',
mapOptions: {
style: 'light',
center: [120.210792, 30.246026],
zoom: 9,
// token: 'xxxx - token',
// token: '你申请的 Key',
},
};

Expand Down
40 changes: 0 additions & 40 deletions src/components/LarkMap/demos/map-instance.tsx

This file was deleted.

39 changes: 38 additions & 1 deletion src/components/LarkMap/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,44 @@ LarkMap 是地图容器组件,相关地图组件与 Hooks 需放到容器组

#### 通过实例生成地图

<code src="./demos/map-instance.tsx" compact defaultShowCode></code>
```tsx | pure
import AMapLoader from '@amap/amap-jsapi-loader';
import { GaodeMap } from '@antv/l7';
import { LarkMap } from '@antv/larkmap';
import React from 'react';

/**
* 实例化
*/
// const mapInstance = new GaodeMap({
// style: 'dark',
// center: [120.210792, 30.246026],
// zoom: 10,
// // token: '你申请的 Key',
// });

/**
* 或者通过 AMapLoader
*/
const getMapInstance = () => {
return AMapLoader.load({
key: '你申请的 Key', // 申请好的 Web 端开发者 Key,首次调用 load 时必填
version: '2.0', // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
plugins: [], // 需要使用的的插件列表,如比例尺'AMap.Scale'等
}).then((AMap) => {
return new GaodeMap({
mapInstance: new AMap.Map('container', {
zoom: 16, //初始化地图层级
center: [116.397428, 39.90923], //初始化地图中心点
}),
});
});
};

export default () => {
return <LarkMap id="container" map={getMapInstance} style={{ height: '300px' }} />;
};
```

### API

Expand Down

0 comments on commit 161c209

Please sign in to comment.