Gathering detailed insights and metrics for @uiw/react-baidu-map-circle
Gathering detailed insights and metrics for @uiw/react-baidu-map-circle
npm install @uiw/react-baidu-map-circle
Typescript
Module System
Node Version
NPM Version
TypeScript (98.85%)
HTML (0.99%)
Less (0.14%)
Shell (0.03%)
Total Downloads
131,415
Last Day
695
Last Week
2,046
Last Month
8,372
Last Year
105,498
226 Stars
520 Commits
22 Forks
7 Watching
8 Branches
12 Contributors
Latest Version
2.7.2
Package Id
@uiw/react-baidu-map-circle@2.7.2
Unpacked Size
16.06 kB
Size
4.50 kB
File Count
12
NPM Version
8.19.4
Node Version
20.14.0
Publised On
24 Jun 2024
Cumulative downloads
Total Downloads
Last day
82.4%
695
Compared to previous day
Last week
-6.8%
2,046
Compared to previous week
Last month
12.5%
8,372
Compared to previous month
Last year
536.4%
105,498
Compared to previous year
表示地图上的圆覆盖物。
1import { Circle, useCircle } from '@uiw/react-baidu-map'; 2// 或者单独安装使用 3import Circle, { useCircle } from '@uiw/react-baidu-map-circle';
1import React, { useState } from 'react'; 2import { Map, Circle, APILoader } from '@uiw/react-baidu-map'; 3 4const Example = () => { 5 const [visiable, setVisiable] = useState(true); 6 const [enableEditing, setEnableEditing] = useState(false); 7 const [strokeOpacity, setStrokeOpacity] = useState(0.9); 8 function circleRef(props) { 9 if (props && props.circle) { 10 console.log('circle:', props.circle, props.map, props.BMap); 11 } 12 } 13 return ( 14 <> 15 <button onClick={() => setVisiable(!visiable)}>{visiable ? '隐藏' : '显示'}</button> 16 <button onClick={() => setEnableEditing(!enableEditing)}>{enableEditing ? '取消编辑' : '编辑'}</button> 17 <button onClick={() => setStrokeOpacity(0.7)}>透明度0.7</button> 18 <button onClick={() => setStrokeOpacity(0.2)}>透明度0.2</button> 19 <Map widget={['NavigationControl']} style={{ height: 350 }}> 20 <Circle 21 ref={circleRef} 22 visiable={visiable} 23 enableEditing={enableEditing} 24 strokeOpacity={strokeOpacity} 25 strokeWeight={1} 26 center={{ lng: 121.455228, lat: 31.240257 }} 27 radius={1000} 28 /> 29 <Circle 30 visiable={visiable} 31 enableEditing={enableEditing} 32 strokeOpacity={strokeOpacity} 33 center={{ lng: 121.490298, lat: 31.229388 }} 34 radius={1500} 35 /> 36 </Map> 37 </> 38 ); 39} 40 41const Demo = () => ( 42 <div style={{ width: '100%' }}> 43 <APILoader akay="eYpCTECSntZmw0WyoQ7zFpCRR9cpgHFG"> 44 <Example /> 45 </APILoader> 46 </div> 47); 48 49export default Demo;
circle
, setCircle
1import React from 'react'; 2import { useRef, useEffect, useState } from 'react'; 3import { Map, Provider, APILoader, useMap, useCircle } from '@uiw/react-baidu-map'; 4 5const Example = () => { 6 const [enableEditing, setEnableEditing] = useState(false); 7 const [strokeOpacity, setStrokeOpacity] = useState(0.9); 8 const divElm = useRef(null); 9 const { setContainer, map } = useMap({ 10 widget: ['GeolocationControl', 'NavigationControl'] 11 }); 12 const { circle } = useCircle({ map, 13 enableScrollWheelZoom: true, // 启用滚轮放大缩小,默认禁用 14 enableEditing, strokeOpacity, 15 center: { lng: 121.455228, lat: 31.240257 }, 16 radius: 1000, 17 }); 18 useCircle({ map, 19 strokeWeight: 1, 20 center: { lng: 121.490298, lat: 31.229388 }, 21 radius: 1500, 22 }); 23 24 useEffect(() => { 25 if (divElm.current) { 26 setContainer(divElm.current); 27 } 28 }); 29 30 useEffect(() => { 31 if (map && circle) { 32 if (enableEditing) { 33 circle.setFillColor('red'); 34 circle.enableEditing(); 35 } else { 36 circle.setFillColor('transparent'); 37 circle.disableEditing(); 38 } 39 } 40 }, [enableEditing]); 41 42 useEffect(() => { 43 if (map && circle) { 44 circle.setStrokeOpacity(strokeOpacity); 45 } 46 }, [strokeOpacity]); 47 48 return ( 49 <> 50 <button onClick={() => setEnableEditing(!enableEditing)}>{enableEditing ? '取消编辑' : '开启编辑'}</button> 51 <button onClick={() => setStrokeOpacity(0.7)}>透明度0.7</button> 52 <button onClick={() => setStrokeOpacity(0.2)}>透明度0.2</button> 53 <div ref={divElm} style={{ height: '100%' }} /> 54 </> 55 ) 56} 57 58const Demo = () => ( 59 <div style={{ width: '100%', height: '300px' }}> 60 <APILoader akay="eYpCTECSntZmw0WyoQ7zFpCRR9cpgHFG"> 61 <Provider> 62 <Example /> 63 </Provider> 64 </APILoader> 65 </div> 66); 67 68export default Demo;
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
center | 必填 圆形的中心点坐标。百度拾取坐标系统 | Point | - |
radius | 必填 设置圆形的半径,单位为米。 | number | - |
visiable | 覆盖物是否可见。 | boolean | - |
strokeColor | 圆形边线颜色 | String | - |
fillColor | 圆形填充颜色。当参数为空时,圆形将没有填充效果 | String | - |
strokeWeight | 圆形边线的宽度,以像素为单位 | Number | - |
strokeOpacity | 圆形边线透明度,取值范围0 - 1 | Number | - |
fillOpacity | 圆形填充的透明度,取值范围0 - 1 | Number | - |
strokeStyle | 圆形边线的样式,solid或dashed | String | - |
enableMassClear | 是否在调用 map.clearOverlays 清除此覆盖物。 | Boolean | true |
enableEditing | 是否启用线编辑。 | Boolean | false |
enableClicking | 是否响应点击事件。 | Boolean | true |
参数 | 说明 | 类型 |
---|---|---|
onClick | 鼠标点击圆形后会触发此事件 | (event: { type: string, target: any, point: Point, pixel: Pixel }): void; |
onDblClick | 鼠标双击圆形后会触发此事件 | (event: { type: string, target: any, point: Point, pixel: Pixel }): void; |
onMouseDown | 鼠标在圆形上按下触发此事件 | (event: { type: string, target: any, point: Point, pixel: Pixel }): void; |
onMouseUp | 鼠标在圆形释放触发此事件 | (event: { type: string, target: any, point: Point, pixel: Pixel }): void; |
onMouseOut | 鼠标离开圆形时触发此事件 | (event: { type: string, target: any, point: Point, pixel: Pixel }): void; |
onMouseOver | 当鼠标进入圆形区域时会触发此事件 | (event: { type: string, target: any, point: Point, pixel: Pixel }): void; |
onRemove | 移除圆形时触发此事件 | (event: { type: string, target: any }): void; |
onLineUpdate | 圆形覆盖物的属性发生变化时触发此事件 | (event: { type: string, target: any }): void; |
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
packaging workflow detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/24 approved changesets -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More