diff --git a/src/components/map/CurrentLocation.tsx b/src/components/map/CurrentLocation.tsx index 0caa4e7..6212bc0 100644 --- a/src/components/map/CurrentLocation.tsx +++ b/src/components/map/CurrentLocation.tsx @@ -1,11 +1,12 @@ import { atom, useAtom } from 'jotai'; import react from 'react'; import Marker from './Marker'; -import { geoPoint, TileKeyObject } from './types'; +import { geoPoint, Rectangle, TileKeyObject } from './types'; export interface CurrentLocationProperties { keyObject?: TileKeyObject; zoom?: number; + viewPort?: Rectangle; } const initialLocation: geoPoint | null = null; @@ -33,6 +34,7 @@ export const CurrentLocation: react.FC = ( } keyObject={props.keyObject} zoom={props.zoom} + viewPort={props.viewPort} /> ) : null; }; diff --git a/src/components/map/Marker.tsx b/src/components/map/Marker.tsx index a355804..bb1f5e3 100644 --- a/src/components/map/Marker.tsx +++ b/src/components/map/Marker.tsx @@ -15,6 +15,14 @@ export const Marker: react.FC = (props: MarkerProperties) => { const x = lon2tile(props.coordinates.lon, props.keyObject.zoomLevel); const y = lat2tile(props.coordinates.lat, props.keyObject.zoomLevel); + if (props.viewPort === undefined) return null; + if ( + x < props.viewPort.topLeft.x || + x > props.viewPort.bottomRight.x || + y < props.viewPort.topLeft.y || + y > props.viewPort.bottomRight.y + ) + return null; return ( {props.icon}