debug show points tollhouse
This commit is contained in:
@@ -20,8 +20,9 @@ const PointsOnMap = ({ data, isCluster }) => {
|
||||
};
|
||||
|
||||
const markers = useMemo(() => {
|
||||
return data.map(({ id, lat, lng, step }) => (
|
||||
<CircleMarker
|
||||
return data.map(({ id, lat, lng, step }) => {
|
||||
if (!lat && !lng) return
|
||||
return <CircleMarker
|
||||
key={id}
|
||||
center={L.latLng(Number(lat), Number(lng))}
|
||||
radius={8}
|
||||
@@ -32,22 +33,41 @@ const PointsOnMap = ({ data, isCluster }) => {
|
||||
},
|
||||
}}
|
||||
color={getMarkerColor(Number(status))}
|
||||
/>
|
||||
));
|
||||
/>;
|
||||
});
|
||||
}, [data, theme]);
|
||||
|
||||
useEffect(() => {
|
||||
if (data.length === 0) return;
|
||||
if (data.length === 0) {
|
||||
// fly to Iran
|
||||
map.flyTo([32.4279, 53.6880], 6, { duration: 0.7 });
|
||||
return;
|
||||
}
|
||||
|
||||
const bounds = L.latLngBounds(
|
||||
data.map(({ lat, lng }) => {
|
||||
return L.latLng(Number(lat), Number(lng));
|
||||
})
|
||||
);
|
||||
// ساختن bounds با حذف مواردی که lat/lng ندارند
|
||||
const validPoints = data
|
||||
.filter(({ lat, lng }) => lat && lng)
|
||||
.map(({ lat, lng }) => L.latLng(Number(lat), Number(lng)));
|
||||
|
||||
if (validPoints.length === 0) {
|
||||
// اگر هیچ مختصات معتبری نبود → ایران
|
||||
map.flyTo([32.4279, 53.6880], 6, { duration: 0.7 });
|
||||
return;
|
||||
}
|
||||
|
||||
const bounds = L.latLngBounds(validPoints);
|
||||
|
||||
if (!bounds.isValid()) {
|
||||
// اگر bounds معتبر نبود → fallback روی ایران
|
||||
map.flyTo([32.4279, 53.6880], 6, { duration: 0.7 });
|
||||
return;
|
||||
}
|
||||
|
||||
map.flyToBounds(bounds, { duration: 0.7 });
|
||||
|
||||
}, [data]);
|
||||
|
||||
|
||||
const createClusterCustomIcon = (cluster) => {
|
||||
const count = cluster.getChildCount();
|
||||
return L.divIcon({
|
||||
|
||||
Reference in New Issue
Block a user