rusackas commented on code in PR #37625:
URL: https://github.com/apache/superset/pull/37625#discussion_r2765521431
##########
superset-frontend/plugins/legacy-plugin-chart-map-box/src/MapBox.tsx:
##########
@@ -109,15 +132,15 @@ class MapBox extends Component {
// to an area outside of the original bounds, no additional queries are
made to the backend to
// retrieve additional data.
// add this variable to widen the visible area
- const offsetHorizontal = (width * 0.5) / 100;
- const offsetVertical = (height * 0.5) / 100;
+ const offsetHorizontal = ((width ?? 400) * 0.5) / 100;
+ const offsetVertical = ((height ?? 400) * 0.5) / 100;
const bbox = [
- bounds[0][0] - offsetHorizontal,
- bounds[0][1] - offsetVertical,
- bounds[1][0] + offsetHorizontal,
- bounds[1][1] + offsetVertical,
+ bounds![0][0] - offsetHorizontal,
+ bounds![0][1] - offsetVertical,
+ bounds![1][0] + offsetHorizontal,
+ bounds![1][1] + offsetVertical,
Review Comment:
Good catch again — and you're right - in the case of an empty dataset,
bounds could be undefined from transformProps. I've added proper runtime guards:
1. Constructor: Now checks if `(bounds && bounds[0] && bounds[1])` before
calling fitBounds(), defaulting to world center (0,0) at zoom level 1
2. Render: Same guard for the bbox calculation, defaulting to world bounds
`[-180, -90, 180, 90]`
Also changed the type from required to optional (`bounds?:`) to reflect the
reality that empty datasets may not provide bounds.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]