Skip to content

Commit

Permalink
Atlas #4 - Adding optional "boundingBoxOptions" and "boundingBoxData"…
Browse files Browse the repository at this point in the history
… props to LocationMarkers
  • Loading branch information
dleadbetter committed Apr 2, 2024
1 parent c631af8 commit d5d4459
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/core-data/src/components/SearchResultsLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import TypesenseUtils from '../utils/Typesense';
import { useCachedHits, useSearchCompleted } from '../hooks/Typesense';

type Props = {
boundingBoxData?: any,
boundingBoxOptions?: any,
buffer?: number,
fitBoundingBox?: boolean,
Expand Down Expand Up @@ -44,9 +45,9 @@ const SearchResultsLayer = (props: Props) => {
useSearchCompleted(() => {
if (props.fitBoundingBox && mapLoaded && data) {
const boundingBox = MapUtils.getBoundingBox(data, props.buffer);
map.fitBounds(boundingBox, props.boundingBoxOptions);
map.fitBounds(boundingBox, props.boundingBoxOptions, props.boundingBoxData);
}
}, [data, map, mapLoaded, props.boundingBoxOptions, props.buffer, props.fitBoundingBox]);
}, [data, map, mapLoaded, props.boundingBoxData, props.boundingBoxOptions, props.buffer, props.fitBoundingBox]);

return (
<LocationMarkers
Expand Down
15 changes: 13 additions & 2 deletions packages/geospatial/src/components/LocationMarkers.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ type Props = {
*/
animate?: boolean,

/**
* (Optional) data to pass to the fitToBounds function.
*/
boundingBoxData?: any,

/**
* (Optional) options to pass to the fitToBounds function.
* See [spec](https://maplibre.org/maplibre-gl-js/docs/API/types/FitBoundsOptions/).
*/
boundingBoxOptions?: any,

/**
* The number of miles to buffer the GeoJSON data.
*/
Expand Down Expand Up @@ -86,9 +97,9 @@ const LocationMarkers = (props: Props) => {
useEffect(() => {
if (map && props.data && props.fitBoundingBox) {
const boundingBox = MapUtils.getBoundingBox(props.data, props.buffer);
map.fitBounds(boundingBox);
map.fitBounds(boundingBox, props.boundingBoxOptions, props.boundingBoxData);
}
}, [map, props.buffer, props.data, props.fitBoundingBox]);
}, [map, props.buffer, props.data, props.boundingBoxData, props.boundingBoxOptions, props.fitBoundingBox]);

return (
<>
Expand Down

0 comments on commit d5d4459

Please sign in to comment.