import { AMap } from '@/components'; import usePlaceSearch from '@/components/AMapComponent/hooks/PlaceSearch'; import { Input, Modal, Select } from 'antd'; import { debounce } from 'lodash'; import { Marker } from 'react-amap'; import { useEffect, useState } from 'react'; import './style'; interface Props { value: any; close: () => void; ok: (data: any) => void; } type MarkerPointType = { longitude: number; latitude: number; }; export default (props: Props) => { const [markerCenter, setMarkerCenter] = useState({ longitude: 0, latitude: 0 }); const [map, setMap] = useState(null); const { data, search } = usePlaceSearch(map); const [value, setValue] = useState(props.value); const onSearch = (value1: string) => { search(value1); }; useEffect(() => { setValue(props?.value || ''); const list = (props?.value || '').split(',') || []; if (!!props.value && list.length === 2) { setMarkerCenter({ longitude: list[0], latitude: list[1], }); } }, [props.value]); console.log(markerCenter); return ( props.close()} onOk={() => { props.ok(value); }} >
{ setValue(`${e.lnglat.lng},${e.lnglat.lat}`); setMarkerCenter({ longitude: e.lnglat.lng, latitude: e.lnglat.lat, }); }, }} > {markerCenter.longitude ? ( // @ts-ignore ) : null}
); };