sửa sửa lỗi polygon không bị xóa trên iOS
This commit is contained in:
@@ -55,11 +55,11 @@ export default function HomeScreen() {
|
||||
const [zoomLevel, setZoomLevel] = useState(10);
|
||||
const [isFirstLoad, setIsFirstLoad] = useState(true);
|
||||
const [polylineCoordinates, setPolylineCoordinates] = useState<
|
||||
PolylineWithLabelProps | undefined
|
||||
>(undefined);
|
||||
PolylineWithLabelProps | null
|
||||
>(null);
|
||||
const [polygonCoordinates, setPolygonCoordinates] = useState<
|
||||
PolygonWithLabelProps[] | undefined
|
||||
>(undefined);
|
||||
PolygonWithLabelProps[]
|
||||
>([]);
|
||||
const platform = usePlatform();
|
||||
const theme = useColorScheme();
|
||||
const scale = useRef(new Animated.Value(0)).current;
|
||||
@@ -82,6 +82,8 @@ export default function HomeScreen() {
|
||||
setGpsData(gpsData);
|
||||
} else {
|
||||
setGpsData(undefined);
|
||||
setPolygonCoordinates([]);
|
||||
setPolylineCoordinates(null);
|
||||
}
|
||||
};
|
||||
const queryAlarmData = (alarmData: Model.AlarmResponse) => {
|
||||
@@ -133,7 +135,7 @@ export default function HomeScreen() {
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (polylineCoordinates !== undefined) {
|
||||
if (polylineCoordinates !== null) {
|
||||
console.log("Polyline Khac null");
|
||||
} else {
|
||||
console.log("Polyline null");
|
||||
@@ -141,8 +143,16 @@ export default function HomeScreen() {
|
||||
}, [polylineCoordinates]);
|
||||
|
||||
useEffect(() => {
|
||||
setPolylineCoordinates(undefined);
|
||||
setPolygonCoordinates(undefined);
|
||||
if (polygonCoordinates.length > 0) {
|
||||
console.log("Polygon Khac null");
|
||||
} else {
|
||||
console.log("Polygon null");
|
||||
}
|
||||
}, [polygonCoordinates]);
|
||||
|
||||
useEffect(() => {
|
||||
setPolylineCoordinates(null);
|
||||
setPolygonCoordinates([]);
|
||||
if (!entityData) return;
|
||||
if (!banzoneData) return;
|
||||
for (const entity of entityData) {
|
||||
@@ -159,8 +169,8 @@ export default function HomeScreen() {
|
||||
}
|
||||
// Nếu danh sách zone rỗng, clear tất cả
|
||||
if (zones.length === 0) {
|
||||
setPolylineCoordinates(undefined);
|
||||
setPolygonCoordinates(undefined);
|
||||
setPolylineCoordinates(null);
|
||||
setPolygonCoordinates([]);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -335,7 +345,7 @@ export default function HomeScreen() {
|
||||
/>
|
||||
);
|
||||
})}
|
||||
{polylineCoordinates !== undefined && (
|
||||
{polylineCoordinates && (
|
||||
<PolylineWithLabel
|
||||
coordinates={polylineCoordinates.coordinates}
|
||||
label={polylineCoordinates.label}
|
||||
@@ -346,7 +356,7 @@ export default function HomeScreen() {
|
||||
zIndex={50}
|
||||
/>
|
||||
)}
|
||||
{polygonCoordinates !== undefined && (
|
||||
{polygonCoordinates.length > 0 && (
|
||||
<>
|
||||
{polygonCoordinates.map((polygon, index) => {
|
||||
// Tạo key ổn định từ tọa độ đầu tiên của polygon
|
||||
|
||||
Reference in New Issue
Block a user