-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
169 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { LarkMap, Scale } from '@antv/larkmap'; | ||
import React from 'react'; | ||
|
||
export default () => { | ||
return ( | ||
<LarkMap mapType="GaodeV1" style={{ height: '300px' }}> | ||
<Scale position="bottomleft" /> | ||
</LarkMap> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
toc: content | ||
group: | ||
title: 控件组件 | ||
order: 2 | ||
nav: | ||
title: 组件 | ||
path: /components | ||
--- | ||
|
||
# 比例尺 - Scale | ||
|
||
## 介绍 | ||
|
||
地图比例尺组件 | ||
|
||
## 使用场景 | ||
|
||
## 代码演示 | ||
|
||
### 默认示例 | ||
|
||
<code src="./demos/default.tsx" defaultShowCode></code> | ||
|
||
<API></API> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Scale as L7Scale } from '@antv/l7'; | ||
import { useUpdateEffect } from 'ahooks'; | ||
import type React from 'react'; | ||
import { useEffect, useRef } from 'react'; | ||
import { useScene } from '../LarkMap/hooks/use-scene'; | ||
import type { ScaleProps } from './types'; | ||
|
||
export type { ScaleProps }; | ||
|
||
export const Scale: React.FC<ScaleProps> = (props) => { | ||
const scene = useScene(); | ||
const scaleRef = useRef<L7Scale>(); | ||
const { position } = props; | ||
|
||
useEffect(() => { | ||
const scale = new L7Scale({ | ||
...props, | ||
}); | ||
scaleRef.current = scale; | ||
scene.addControl(scale); | ||
return () => { | ||
scaleRef.current = undefined; | ||
scene.removeControl(scale); | ||
}; | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); | ||
|
||
useUpdateEffect(() => { | ||
if (scaleRef.current) { | ||
//@ts-ignore | ||
scaleRef.current.setPosition(position); | ||
} | ||
}, [position]); | ||
|
||
return null; | ||
}; | ||
|
||
Scale.defaultProps = { position: 'bottomleft' }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import type { IScaleControlOption } from '@antv/l7-component/es/control/scale'; | ||
|
||
/** | ||
* 组件类型定义 | ||
*/ | ||
export type ScaleProps = Partial<IScaleControlOption> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { Template } from '@antv/larkmap'; | ||
import React from 'react'; | ||
|
||
export default () => <Template title="First Demo" />; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { LarkMap, Zoom } from '@antv/larkmap'; | ||
import React from 'react'; | ||
|
||
export default () => { | ||
return ( | ||
<LarkMap mapType="GaodeV1" style={{ height: '300px' }}> | ||
<Zoom position="bottomright" /> | ||
</LarkMap> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
toc: content | ||
group: | ||
title: 控件组件 | ||
order: 2 | ||
nav: | ||
title: 组件 | ||
path: /components | ||
--- | ||
|
||
# 缩放器 - Zoom | ||
|
||
## 介绍 | ||
|
||
地图缩放器组件 | ||
|
||
## 使用场景 | ||
|
||
## 代码演示 | ||
|
||
### 默认示例 | ||
|
||
<code src="./demos/default.tsx" defaultShowCode></code> | ||
|
||
<API></API> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Zoom as L7Zoom } from '@antv/l7'; | ||
import { useUpdateEffect } from 'ahooks'; | ||
import type React from 'react'; | ||
import { useEffect, useRef } from 'react'; | ||
import { useScene } from '../LarkMap/hooks/use-scene'; | ||
import type { ZoomProps } from './types'; | ||
|
||
export type { ZoomProps }; | ||
|
||
export const Zoom: React.FC<ZoomProps> = (props) => { | ||
const scene = useScene(); | ||
const zoomRef = useRef<L7Zoom>(); | ||
const { position } = props; | ||
|
||
useEffect(() => { | ||
const zoom = new L7Zoom({ | ||
...props, | ||
}); | ||
zoomRef.current = zoom; | ||
scene.addControl(zoom); | ||
return () => { | ||
zoomRef.current = undefined; | ||
scene.removeControl(zoom); | ||
}; | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); | ||
|
||
useUpdateEffect(() => { | ||
if (zoomRef.current) { | ||
//@ts-ignore | ||
zoomRef.current.setPosition(position); | ||
} | ||
}, [position]); | ||
|
||
return null; | ||
}; | ||
|
||
Zoom.defaultProps = { position: 'bottomright' }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import type { IZoomControlOption } from '@antv/l7-component/es/control/zoom'; | ||
|
||
/** | ||
* 组件类型定义 | ||
*/ | ||
export type ZoomProps = Partial<IZoomControlOption> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export default '0.0.1-alpha.3'; | ||
export default '0.0.1-alpha.4'; |