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