
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-zoom-map
Advanced tools
An interactive map component with zoom, pan and pinch capabilities based on react-zoom-pan-pinch
基于react-zoom-pan-pinch的交互式地图组件,提供了图片缩放、平移和捏合功能的React组件。适用于需要在网页中展示可交互地图、图片或任何需要缩放平移功能的场景。
npm install react-zoom-map
# 或
yarn add react-zoom-map
import React from 'react';
import { ZoomPanPinch } from 'react-zoom-map';
function App() {
return (
<div style={{ width: '100vw', height: '100vh' }}>
<ZoomPanPinch backgroundPic="/path/to/your/background/image.jpg">
{/* 在这里添加您想要在地图上显示的内容 */}
<div style={{ position: 'absolute', top: '50%', left: '50%', transform: 'translate(-50%, -50%)' }}>
自定义内容
</div>
</ZoomPanPinch>
</div>
);
}
export default App;
import React from 'react';
import { ZoomPanPinch, useControls, getMinScale } from 'react-zoom-map';
function App() {
// 获取控制器
const { zoomIn, zoomOut, resetTransform } = useControls();
// 计算最小缩放比例
const minScale = getMinScale(1920, 1080);
return (
<div>
{/* 控制按钮 */}
<div className="controls">
<button onClick={() => zoomIn()}>放大</button>
<button onClick={() => zoomOut()}>缩小</button>
<button onClick={() => resetTransform()}>重置</button>
</div>
{/* 地图组件 */}
<ZoomPanPinch
backgroundPic="/path/to/your/background/image.jpg"
wrapperStyle={{ border: '1px solid #ccc' }}
transformWrapper={{
initialScale: minScale,
minScale: minScale,
maxScale: 5,
limitToBounds: false,
// 更多配置选项...
}}
>
{/* 自定义内容 */}
</ZoomPanPinch>
</div>
);
}
export default App;
| 属性 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
| backgroundPic | string | 是 | - | 背景图片的URL |
| children | ReactNode | 否 | - | 要在地图上显示的自定义内容 |
| wrapperStyle | React.CSSProperties | 否 | - | 应用于包装器的自定义样式 |
| transformWrapper | object | 否 | - | 传递给TransformWrapper组件的配置选项 |
计算图片在视口中适应所需的最小缩放比例。
| 参数 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
| imgWidth | number | 否 | 1920 | 图片原始宽度 |
| imgHeight | number | 否 | 1080 | 图片原始高度 |
返回值: number - 最小缩放比例
从react-zoom-pan-pinch导出的hook,用于获取控制缩放和平移的函数。
返回值: 包含以下方法的对象:
zoomIn(): 放大zoomOut(): 缩小resetTransform(): 重置变换从react-zoom-pan-pinch导出的组件,用于保持子元素的缩放比例。
支持所有现代浏览器和IE11+。
欢迎对本项目进行贡献!请查看贡献指南了解详细信息。
MIT
FAQs
An interactive map component with zoom, pan and pinch capabilities based on react-zoom-pan-pinch
The npm package react-zoom-map receives a total of 0 weekly downloads. As such, react-zoom-map popularity was classified as not popular.
We found that react-zoom-map demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.