build and format
This commit is contained in:
@@ -21,26 +21,28 @@ const PointsOnMap = ({ data, isCluster }) => {
|
||||
|
||||
const markers = useMemo(() => {
|
||||
return data.map(({ id, lat, lng, step }) => {
|
||||
if (!lat && !lng) return
|
||||
return <CircleMarker
|
||||
key={id}
|
||||
center={L.latLng(Number(lat), Number(lng))}
|
||||
radius={8}
|
||||
eventHandlers={{
|
||||
click: () => {
|
||||
openDialog();
|
||||
setSelectedId(id);
|
||||
},
|
||||
}}
|
||||
color={getMarkerColor(Number(status))}
|
||||
/>;
|
||||
if (!lat && !lng) return;
|
||||
return (
|
||||
<CircleMarker
|
||||
key={id}
|
||||
center={L.latLng(Number(lat), Number(lng))}
|
||||
radius={8}
|
||||
eventHandlers={{
|
||||
click: () => {
|
||||
openDialog();
|
||||
setSelectedId(id);
|
||||
},
|
||||
}}
|
||||
color={getMarkerColor(Number(status))}
|
||||
/>
|
||||
);
|
||||
});
|
||||
}, [data, theme]);
|
||||
|
||||
useEffect(() => {
|
||||
if (data.length === 0) {
|
||||
// fly to Iran
|
||||
map.flyTo([32.4279, 53.6880], 6, { duration: 0.7 });
|
||||
map.flyTo([32.4279, 53.688], 6, { duration: 0.7 });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -51,7 +53,7 @@ const PointsOnMap = ({ data, isCluster }) => {
|
||||
|
||||
if (validPoints.length === 0) {
|
||||
// اگر هیچ مختصات معتبری نبود → ایران
|
||||
map.flyTo([32.4279, 53.6880], 6, { duration: 0.7 });
|
||||
map.flyTo([32.4279, 53.688], 6, { duration: 0.7 });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -59,15 +61,13 @@ const PointsOnMap = ({ data, isCluster }) => {
|
||||
|
||||
if (!bounds.isValid()) {
|
||||
// اگر bounds معتبر نبود → fallback روی ایران
|
||||
map.flyTo([32.4279, 53.6880], 6, { duration: 0.7 });
|
||||
map.flyTo([32.4279, 53.688], 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