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