diff --git a/src/components/SelectGaodeLngLat/index.jsx b/src/components/SelectGaodeLngLat/index.jsx index bf894e1..69eaa1e 100644 --- a/src/components/SelectGaodeLngLat/index.jsx +++ b/src/components/SelectGaodeLngLat/index.jsx @@ -8,6 +8,7 @@ import ajax from "@/services"; import "./index.scss"; import { compileString } from "sass"; import Rerm from "./blue-point.png"; +import { constant } from "lodash"; let timer = null; function SelectGaodeLngLat(props) { const { @@ -65,9 +66,9 @@ function SelectGaodeLngLat(props) { setLnglat([add.lng, add.lat]); getLntLat([add.lng, add.lat]); }; - function getLocationMessage() { + function getLocationMessage(v) { // const lat_lng = lnglat.reverse().join(","); - const lat_lng = lnglat.join(","); + const lat_lng = v ? v.join(",") : lnglat.join(","); ajax.getLocationNameByLngLat({ lat_lng }).then((res) => { if (res.status === 20000) { setAddress(res.data.address); @@ -79,7 +80,9 @@ function SelectGaodeLngLat(props) { useEffect(() => { onChange(address); }, [address]); - + useEffect(() => { + getLocationMessage(lnglat) + }, [lnglat]); return (
`; const addMarker = (data) => { - if(data.length==0) return + if (data.length == 0) return if (Marker) { map.remove(Marker); }