Skip to content

Commit

Permalink
Extend bounds to include the whole island and all related places.
Browse files Browse the repository at this point in the history
  • Loading branch information
jayvarner committed Jun 24, 2024
1 parent 7ffcd47 commit 45d7f87
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/components/RelatedPlaces.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@ const RelatedPlaces = ({ places }: Props) => {
if (!map || !mapLoaded) return;
// This will give you the GeoJSON to add to the map.
const geoJSON = toFeatureCollection(places);
// Bounds of all related places.
const bounds = new LngLatBounds(
bbox(geoJSON) as [number, number, number, number],
);
// Extend the island bounds if related places are beyond the island bounds.
// TODO: This can probably be removed. Sapelo is the only island with a related
// place off the island. This is probably an error in the data.
const newBounds = map.getBounds().extend(bounds);

map.fitBounds(bounds, { padding: 100 });
map.fitBounds(newBounds, { padding: 100 });

if (!map.getImage("pulsing-dot")) {
const dot = pulsingDot(map);
Expand Down

0 comments on commit 45d7f87

Please sign in to comment.