Compare commits

..

No commits in common. "db5b5933b21b6b4d2ab23376a42d40c910b658ab" and "c189725deb483214a1af844aebcc5db1f7c462c9" have entirely different histories.

2 changed files with 8 additions and 6 deletions

View File

@ -19,7 +19,6 @@ const MapSelector = (props) => {
const mapContainerRef = useRef(null); const mapContainerRef = useRef(null);
const mapInstanceRef = useRef(null); const mapInstanceRef = useRef(null);
const local = useRef(null);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [currentLongitude, setCurrentLongitude] = useState(longitude || ""); const [currentLongitude, setCurrentLongitude] = useState(longitude || "");
const [currentLatitude, setCurrentLatitude] = useState(latitude || ""); const [currentLatitude, setCurrentLatitude] = useState(latitude || "");
@ -87,10 +86,10 @@ const MapSelector = (props) => {
// 搜索功能 // 搜索功能
const handleLocalSearch = () => { const handleLocalSearch = () => {
if (localSearch && mapInstanceRef.current) { if (localSearch && mapInstanceRef.current) {
local.current = new window.BMapGL.LocalSearch(mapInstanceRef.current, { const local = new window.BMapGL.LocalSearch(mapInstanceRef.current, {
renderOptions: { map: mapInstanceRef.current }, renderOptions: { map: mapInstanceRef.current },
}); });
local.current.search(localSearch); local.search(localSearch);
} }
}; };
@ -98,7 +97,10 @@ const MapSelector = (props) => {
const handleLocalClear = () => { const handleLocalClear = () => {
setLocalSearch(""); setLocalSearch("");
if (mapInstanceRef.current) { if (mapInstanceRef.current) {
local.current.search(""); const local = new window.BMapGL.LocalSearch(mapInstanceRef.current, {
renderOptions: { map: mapInstanceRef.current },
});
local.search("");
} }
}; };
@ -204,7 +206,7 @@ const MapSelector = (props) => {
<Button type="primary" onClick={handleLocalSearch}> <Button type="primary" onClick={handleLocalSearch}>
搜索 搜索
</Button> </Button>
<Button onClick={handleLocalClear} style={{ marginLeft: 8 }}> <Button onClick={handleLocalClear}>
重置 重置
</Button> </Button>
</Form.Item> </Form.Item>

View File

@ -1,7 +1,7 @@
{ {
"name": "zy-react-library", "name": "zy-react-library",
"private": false, "private": false,
"version": "1.0.154", "version": "1.0.153",
"type": "module", "type": "module",
"description": "", "description": "",
"author": "LiuJiaNan", "author": "LiuJiaNan",