sửa l fix xcall api getTrip

This commit is contained in:
Tran Anh Tuan
2025-11-06 17:45:03 +07:00
parent aabd1109b2
commit 1b748285c9
5 changed files with 29 additions and 33 deletions

View File

@@ -30,19 +30,11 @@ import {
convertWKTtoLatLngString,
} from "@/utils/geom";
import { useEffect, useRef, useState } from "react";
import {
Animated,
Image as RNImage,
StyleSheet,
View
} from "react-native";
import { Animated, Image as RNImage, StyleSheet, View } from "react-native";
import MapView, { Circle, Marker } from "react-native-maps";
export default function HomeScreen() {
const [gpsData, setGpsData] = useState<Model.GPSResonse | null>(
null
);
const [gpsData, setGpsData] = useState<Model.GPSResponse | null>(null);
const [alarmData, setAlarmData] = useState<Model.AlarmResponse | null>(null);
const [entityData, setEntityData] = useState<
Model.TransformedEntity[] | null
@@ -54,9 +46,8 @@ export default function HomeScreen() {
const [circleRadius, setCircleRadius] = useState(100);
const [zoomLevel, setZoomLevel] = useState(10);
const [isFirstLoad, setIsFirstLoad] = useState(true);
const [polylineCoordinates, setPolylineCoordinates] = useState<
PolylineWithLabelProps | null
>(null);
const [polylineCoordinates, setPolylineCoordinates] =
useState<PolylineWithLabelProps | null>(null);
const [polygonCoordinates, setPolygonCoordinates] = useState<
PolygonWithLabelProps[]
>([]);
@@ -76,7 +67,7 @@ export default function HomeScreen() {
getEntitiesEventBus();
getBanzonesEventBus();
getTrackPointsEventBus();
const queryGpsData = (gpsData: Model.GPSResonse) => {
const queryGpsData = (gpsData: Model.GPSResponse) => {
if (gpsData) {
// console.log("GPS Data: ", gpsData);
setGpsData(gpsData);
@@ -182,7 +173,6 @@ export default function HomeScreen() {
label: zone?.zone_name ?? "",
content: zone?.message ?? "",
});
}
} else if (geom_type === 1) {
// foundPolygon = true;
@@ -293,8 +283,9 @@ export default function HomeScreen() {
return (
<View
// edges={["top"]}
style={styles.container}>
// edges={["top"]}
style={styles.container}
>
<MapView
onMapReady={handleMapReady}
onRegionChangeComplete={handleRegionChangeComplete}
@@ -351,7 +342,9 @@ export default function HomeScreen() {
return (
<PolygonWithLabel
key={`polygon-${index}-${gpsData?.lat || 0}-${gpsData?.lon || 0}`}
key={`polygon-${index}-${gpsData?.lat || 0}-${
gpsData?.lon || 0
}`}
coordinates={polygon.coordinates}
label={polygon.label}
content={polygon.content}
@@ -367,7 +360,11 @@ export default function HomeScreen() {
)}
{gpsData !== null && (
<Marker
key={platform === IOS_PLATFORM ? `${gpsData.lat}-${gpsData.lon}` : "gps-data"}
key={
platform === IOS_PLATFORM
? `${gpsData.lat}-${gpsData.lon}`
: "gps-data"
}
coordinate={{
latitude: gpsData.lat,
longitude: gpsData.lon,
@@ -412,10 +409,11 @@ export default function HomeScreen() {
height: 32,
transform: [
{
rotate: `${typeof gpsData.h === "number" && !isNaN(gpsData.h)
rotate: `${
typeof gpsData.h === "number" && !isNaN(gpsData.h)
? gpsData.h
: 0
}deg`,
}deg`,
},
],
}}
@@ -425,7 +423,7 @@ export default function HomeScreen() {
</Marker>
)}
</MapView>
<View className="absolute top-14 right-2 shadow-md">
<SosButton />
</View>