keplergl / keplergl/kepler.gl

[Bug] `PlotContainer.render` crashes when `center:true` and table does not have geospatial data

Open
#1,217 0 comments 0 reactions 1 assignee View on GitHub

@macrigiuseppe is already working on this.

Since Aug 4, 2020.

bug
Dominant language
TypeScript
Stars
12k
Forks
2k
Avg merge
1d 5h
Merged PRs (30d)
66

Description

Describe the bug
Loading a table that does not have geospatial columns results in bounds being null which crashes the PlotContainer

The fix should just be a matter of adding a bounds check before calling geoViewport.viewport (and maybe adding a test case for bounds=null.

      const bounds = findMapBounds(mapFields.layers);
      const width = size.width / (isSplit ? 2 : 1);
      const height = size.height;
      const scale = this.mapScaleSelector(this.props);
      const newMapState = {
        ...mapState,
        width,
        height,
        zoom: mapState.zoom + (Math.log2(scale) || 0)
      };
      if (exportImageSetting.center) {
        const {center, zoom} = exportImageSetting.center
          ? geoViewport.viewport(bounds, [width, height])
          : {center: [mapState.longitude, mapState.latitude], zoom: mapState.zoom};

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.