From 6e2c1017b1897df9438d9d145a998fba5ead621f Mon Sep 17 00:00:00 2001 From: xingjx Date: Fri, 5 Jan 2024 20:15:37 +0800 Subject: [PATCH] =?UTF-8?q?fix():bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/SelectGaodeLngLat/index.jsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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); }