Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 缩放器新增显示实时 zoom 数值功能 #183

Merged
merged 2 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/Control/ZoomControl/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ nav:
| zoomOutText | 缩小按钮的展示内容 | `ReactNode` | - |
| zoomOutTitle | 缩小按钮的 `title` 属性 | `string` | `'Zoom out'` |
| position | 控件被添加到地图中的位置以及排列方式,详情可见 [控件插槽](https://l7.antv.antgroup.com/api/component/control/control#插槽) | [Position](#position) | `'bottomright'` |
| showZoom | 是否展示地图当前实时 zoom 数值,默认向下取整 | `boolean` | `false` |
| className | 自定义样式名 | `string` | - |
| style | 自定义样式 | `CSSProperties` | - |
| onAdd | 组件被添加时的回调 | `(this) => void` | - |
Expand Down
4 changes: 3 additions & 1 deletion src/components/Control/ZoomControl/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const ZoomControl: React.FC<ZoomControlProps> = ({
zoomOutText,
zoomInTitle,
zoomOutTitle,
showZoom,
}) => {
const scene = useScene();
const [control, setControl] = useState<L7Zoom | undefined>();
Expand All @@ -34,11 +35,12 @@ export const ZoomControl: React.FC<ZoomControlProps> = ({
className,
zoomInTitle,
zoomOutTitle,
showZoom,
style: styleText,
zoomInText: zoomInTextDOM,
zoomOutText: zoomOutTextDOM,
};
}, [position, name, className, styleText, zoomInTitle, zoomOutTitle, zoomInTextDOM, zoomOutTextDOM]);
}, [position, name, className, styleText, zoomInTitle, zoomOutTitle, zoomInTextDOM, zoomOutTextDOM, showZoom]);

useEffect(() => {
const zoom = new L7Zoom(omitBy(controlOptions, (value) => value === undefined));
Expand Down
Loading