Prevent JS error on track page when bounding box is invalid
This commit is contained in:
parent
70fa1a41c4
commit
7e33fb6424
|
@ -77,7 +77,9 @@ function Map({
|
|||
|
||||
useEffect(() => {
|
||||
if (boundsFromJson) {
|
||||
const [minX, minY, maxX, maxY] = turfBbox(boundsFromJson)
|
||||
const bbox = turfBbox(boundsFromJson);
|
||||
if (bbox.every(v => Math.abs(v) !== Infinity)) {
|
||||
const [minX, minY, maxX, maxY] = bbox;
|
||||
const vp = new WebMercatorViewport({width: 1000, height: 800}).fitBounds(
|
||||
[
|
||||
[minX, minY],
|
||||
|
@ -90,6 +92,7 @@ function Map({
|
|||
)
|
||||
setViewport(_.pick(vp, ['zoom', 'latitude', 'longitude']))
|
||||
}
|
||||
}
|
||||
}, [boundsFromJson])
|
||||
|
||||
return (
|
||||
|
|
Loading…
Reference in a new issue