import { useState } from "react"; import LocationIcon from "zy-react-library/components/Icon/LocationIcon"; import MapSelector from "zy-react-library/components/Map/MapSelector"; function BaiduMap({ longitude, latitude, disable = true, onChange, onConfirm, enablePointSelect, onPointSelect, }) { const [mapVisible, setMapVisible] = useState(false); const [selectedLocation, setSelectedLocation] = useState({ longitude: "", latitude: "", }); const currentLongitude = longitude || selectedLocation.longitude; const currentLatitude = latitude || selectedLocation.latitude; const mapDisabled = disable && !enablePointSelect; const handleConfirm = (nextLongitude, nextLatitude, extra) => { setSelectedLocation({ longitude: nextLongitude, latitude: nextLatitude, }); onPointSelect?.(nextLongitude, nextLatitude, extra); onChange?.(nextLongitude, nextLatitude, extra); onConfirm?.(nextLongitude, nextLatitude, extra); setMapVisible(false); }; return (
经度: {currentLongitude || "-"} 纬度: {currentLatitude || "-"} { setMapVisible(true); }} />
{mapVisible && ( setMapVisible(false)} longitude={currentLongitude} latitude={currentLatitude} disable={mapDisabled} onConfirm={handleConfirm} type="cesium" /> )}
); } export default BaiduMap;