Skip to content

Commit

Permalink
Add location to f2f clusters (#899)
Browse files Browse the repository at this point in the history
* Add f2f location clusters

---------

Co-authored-by: Reckless_Satoshi <[email protected]>
  • Loading branch information
KoalaSat and Reckless-Satoshi authored Oct 17, 2023
1 parent 8aed0aa commit b7f4d55
Show file tree
Hide file tree
Showing 4 changed files with 294 additions and 7 deletions.
80 changes: 80 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
},
"dependencies": {
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@christopherpickering/react-leaflet-markercluster": "^1.1.0",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@mui/base": "^5.0.0-beta.7",
Expand Down
17 changes: 12 additions & 5 deletions frontend/src/components/Map/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import { MapContainer, GeoJSON, useMapEvents, TileLayer, Tooltip, Marker } from
import { useTheme, LinearProgress } from '@mui/material';
import { UseAppStoreType, AppContext } from '../../contexts/AppContext';
import { GeoJsonObject } from 'geojson';
import { Icon, LeafletMouseEvent, Point } from 'leaflet';
import { Icon, LeafletMouseEvent } from 'leaflet';
import { PublicOrder } from '../../models';
import OrderTooltip from '../Charts/helpers/OrderTooltip';
import getWorldmapGeojson from '../../geo/Web';
import MarkerClusterGroup from '@christopherpickering/react-leaflet-markercluster';

interface Props {
orderType?: number;
Expand Down Expand Up @@ -91,14 +92,20 @@ const Map = ({
};

const getOrderMarkers = () => {
return orders.map((order) => {
if (!order.latitude || !order.longitude) return <></>;
return RobotMarker(order.id, [order.latitude, order.longitude], order.type || 0, order);
});
if (orders.length < 1) return <></>;
return (
<MarkerClusterGroup showCoverageOnHover={false} disableClusteringAtZoom={14}>
{orders.map((order) => {
if (!order.latitude || !order.longitude) return <></>;
return RobotMarker(order.id, [order.latitude, order.longitude], order.type || 0, order);
})}
</MarkerClusterGroup>
);
};

return (
<MapContainer
maxZoom={15}
center={center ?? [0, 0]}
zoom={zoom ? zoom : 2}
attributionControl={false}
Expand Down
Loading

0 comments on commit b7f4d55

Please sign in to comment.