Skip to content

Commit

Permalink
Change default zoom of map by changing the bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
shaked-hayek committed Nov 12, 2024
1 parent 0cba97b commit cfa6584
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/components/molecules/map/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { makeStyles } from '@material-ui/core/styles';
import { MapContainer } from 'react-leaflet';
import L, { LatLng } from 'leaflet';
import { IPoint } from 'models/Point';
import { INITIAL_CENTER, INITIAL_ZOOM } from 'const/generalConst';
import { INITIAL_CENTER } from 'const/generalConst';
import { uniquePoints } from 'utils/map.utils';
import MapViewControl from 'services/MapViewControl';
import GoogleMapsLayer from './GoogleMapsLayer';
Expand All @@ -20,9 +20,10 @@ const useStyles = makeStyles({
},
});

// Default bounds set the default zoom when no default location in data param
const DEFAULT_BOUNDS = [
L.latLng(29.5, 34.22), // most possible south-west point
L.latLng(33.271, 35.946), // most possible north-east point
L.latLng(31.761, 33.809), // most possible south-west point
L.latLng(32.329, 35.743), // most possible north-east point
];

interface IProps {
Expand All @@ -31,13 +32,13 @@ interface IProps {
data?: IPoint[];
}

const Map: FC<IProps> = ({ zoom = INITIAL_ZOOM, center = INITIAL_CENTER, data, children }) => {
const Map: FC<IProps> = ({ center = INITIAL_CENTER, data, children }) => {
const classes = useStyles();

const bounds = getBounds(data);

return (
<MapContainer zoom={zoom} center={center} className={classes.root}>
<MapContainer center={center} className={classes.root}>
<MapViewControl bounds={bounds} />
<GoogleMapsLayer />
{children}
Expand Down

0 comments on commit cfa6584

Please sign in to comment.