Skip to content

Commit 2c64b8b

Browse files
shreeyash07samshara
authored andcommitted
Handle undefined bbox
1 parent e5fc860 commit 2c64b8b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

app/src/utils/map.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { isDefined } from '@togglecorp/fujs';
12
import getBbox from '@turf/bbox';
23
import type {
34
FillLayer,
@@ -183,9 +184,14 @@ export function getCountryListBoundingBox(countryList: Country[]) {
183184
return undefined;
184185
}
185186

187+
const countryWithBbox = countryList.filter((country) => isDefined(country.bbox));
188+
189+
if (countryWithBbox.length < 1) {
190+
return undefined;
191+
}
186192
const collection = {
187193
type: 'FeatureCollection' as const,
188-
features: countryList.map((country) => ({
194+
features: countryWithBbox.map((country) => ({
189195
type: 'Feature' as const,
190196
geometry: country.bbox,
191197
})),

0 commit comments

Comments
 (0)