forked from gzzfw/frontEnd/gzDyh

dminyi
2024-08-27 a923c0ad0bc50abd9160b068abba60beea98275b
地图
4 files modified
82 ■■■■ changed files
gz-customerSystem/src/api/appUrl.js 2 ●●● patch | view | raw | blame | history
gz-customerSystem/src/components/basicInformation/organization/AddOrEditOrganization.jsx 2 ●●● patch | view | raw | blame | history
gz-customerSystem/src/components/basicInformation/organization/PersonModal.jsx 6 ●●●● patch | view | raw | blame | history
gz-customerSystem/src/views/register/visit/component/map.jsx 72 ●●●● patch | view | raw | blame | history
gz-customerSystem/src/api/appUrl.js
@@ -2,7 +2,7 @@
 * @Company: hugeInfo
 * @Author: ldh
 * @Date: 2022-02-16 11:25:57
 * @LastEditTime: 2024-08-26 10:55:13
 * @LastEditTime: 2024-08-27 10:02:01
 * @LastEditors: dminyi 1301963064@qq.com
 * @Version: 1.0.0
 * @Description: api地址
gz-customerSystem/src/components/basicInformation/organization/AddOrEditOrganization.jsx
@@ -100,7 +100,7 @@
                    >
                        <Row gutter={[24, 16]}>
                            <Col span={8}>
                                <Form.Item label="组织名称" name="name" required rules={[{ required: true }]}>
                                <Form.Item label="组织名称" name="unitName" required rules={[{ required: true }]}>
                                    <Input placeholder="请输入" allowClear />
                                </Form.Item>
                            </Col>
gz-customerSystem/src/components/basicInformation/organization/PersonModal.jsx
@@ -2,8 +2,8 @@
 * @Company: hugeInfo
 * @Author: ldh
 * @Date: 2022-02-24 09:48:22
 * @LastEditTime: 2022-10-31 12:01:23
 * @LastEditors: ldh
 * @LastEditTime: 2024-08-26 14:58:09
 * @LastEditors: dminyi 1301963064@qq.com
 * @Version: 1.0.0
 * @Description: 查看部门人员的modal
 */
@@ -93,7 +93,7 @@
            title: '状态',
            dataIndex: 'status',
            width: 50,
            render: (text) => <span style={{ color: text === '1' ? '#52C41A' : '#BFBFBF' }}>{text === '1' ? '正常' : '停用'}</span>,
            render: (text) => <span style={{ color: text === 1 ? '#52C41A' : '#BFBFBF' }}>{text === 1 ? '正常' : '停用'}</span>,
        },
    ];
gz-customerSystem/src/views/register/visit/component/map.jsx
@@ -2,7 +2,7 @@
 * @Author: dminyi 1301963064@qq.com
 * @Date: 2024-08-17 14:41:57
 * @LastEditors: dminyi 1301963064@qq.com
 * @LastEditTime: 2024-08-23 17:06:13
 * @LastEditTime: 2024-08-27 10:17:49
 * @FilePath: \gzDyh\gz-customerSystem\src\views\register\visit\component\map.jsx
 * @Description: 地图
 */
@@ -21,11 +21,16 @@
  },
};
// var map = new window.BMapGL.Map("container");
// map.centerAndZoom(new window.BMapGL.Point(116.401952, 40.032704), 12);
// map.enableScrollWheelZoom();
export default function MapView(props) {
  const mapRef = useRef()
  const formRef = useRef()
  const [addressList, setAddressList] = useState([])
  useEffect(() => {
    if (mapRef.current) {
@@ -40,6 +45,19 @@
    }
  }, [mapRef]);
  // const addCustomLabel = (point, content) => {
  //   var label = new window.BMapGL.Label(content, {
  //     position: point,
  //     offset: new window.BMapGL.Size(10, 20)
  //   });
  //   label.setStyle({
  //     color: '#000',
  //     fontSize: '30px',
  //     border: '2px solid #1E90FF'
  //   });
  //   mapRef.current.map.addOverlay(label);
  // };
  const handleSubmit = () => {
    if (formRef.current) {
      formRef.current.validate(undefined, (errors, values) => {
@@ -51,7 +69,7 @@
              mapRef.current.map.centerAndZoom(point, 15);
              mapRef.current.map.addOverlay(new window.BMapGL.Marker(point, { title: values.name }));
              handleAnalysis(point, values.name); // 添加地点名称
              // searchNearbyPOIs(point);
              // addCustomLabel(point, 'label'); // 添加自定义样式标签
            } else {
              Message.warning('您输入的地址没有解析到结果!');
            }
@@ -60,6 +78,8 @@
      });
    }
  };
  // 解析地址为中文
  const handleAnalysis = (pt, name) => {
@@ -72,41 +92,22 @@
      if (name) {
        addName += ` ${name}`; // 添加地点名称
      }
      mapRef.current.map.centerAndZoom(pt, 15);
      mapRef.current.map.addOverlay(new window.BMapGL.Marker(pt, { title: addName }));
      mapRef.current?.map.centerAndZoom(pt, 15);
      mapRef.current?.map.addOverlay(new window.BMapGL.Marker(pt, { title: addName }));
      setAddressList(surroundingPois);
      console.log(pt, addName, 'pt', 'addName')
    });
  };
  // 搜索附近的POI
  const searchNearbyPOIs = (centerPoint) => {
    const radius = 10; // 半径10米
    const circle = new window.BMapGL.Circle(centerPoint, {
      strokeColor: "#FF0000",
      strokeOpacity: 0.9,
      strokeWeight: 2,
      fillColor: "#FF0000",
      fillOpacity: 0.1,
      radius: radius
    });
    mapRef.current.map.addOverlay(circle);
    const poiSearch = new window.BMapGL.PoiSearch(mapRef.current.map, {
      searchComplete: function (results) {
        if (results.status === window.BMapGL.RESULT_SUCCESS) {
          const pois = results.pois.map(poi => poi.name);
          setAddressList([...addressList, ...pois]);
        }
      }
    });
    poiSearch.searchInCircle('', circle);
  };
  console.log(addressList, 'addressList')
  return (
    <div>
@@ -141,8 +142,13 @@
            onClick={(e) => {
              let pt = e.latlng;
              handleAnalysis(pt, null);
              // addCustomLabel(pt, 'label'); // 添加自定义样式标签
            }}
          >
            <Marker position={{ lng: 116.402544, lat: 39.928216 }} />
            <NavigationControl />
            <InfoWindow position={{ lng: 116.402544, lat: 39.928216 }} text="内容" title="标题" />
          </Map>
        </Col>
        <Col span={8}>