Skip to content

Commit

Permalink
Merge main into sweep/add-jsdoc-regionmap
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] authored Jan 2, 2024
2 parents e072e13 + 9d15c80 commit 683c278
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions frontend/src/components/RegionMap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,15 @@ function MapComponent() {
type: 'FeatureCollection',
features: updatedFeatures,
};
const bounds = turf.bbox(featureCollection);
const seletctedRegionFeature = updatedFeatures.find(
(feature) => feature.properties.id === newSelectedRegionId,
);
let bounds;
if (seletctedRegionFeature) {
bounds = turf.bbox(seletctedRegionFeature);
} else {
bounds = turf.bbox(featureCollection);
}
const mapBounds = new maplibregl.LngLatBounds([bounds[0], bounds[1]], [bounds[2], bounds[3]]);

if (map.current.getSource('polygon')) {
Expand Down Expand Up @@ -189,7 +197,16 @@ function MapComponent() {
type: 'FeatureCollection',
features: validFeatures,
};
const bounds = turf.bbox(featureCollection);

const seletctedRegionFeature = validFeatures.find(
(feature) => feature.properties.id === selectedRegion.id,
);
let bounds;
if (seletctedRegionFeature) {
bounds = turf.bbox(seletctedRegionFeature);
} else {
bounds = turf.bbox(featureCollection);
}
const mapBounds = new maplibregl.LngLatBounds([bounds[0], bounds[1]], [bounds[2], bounds[3]]);

if (map.current) {
Expand Down

0 comments on commit 683c278

Please sign in to comment.