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