question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Empty Grey Box When Conditionally Rendering GMaps

See original GitHub issue

Before mounting the google map, I’m waiting for some requests to finish so I’m trying to put another element in the meantime. The problem is that an empty grey div stays even though I’m not rendering the google map and as a result pushes my loading screen all the way to the bottom.

image

Here’s a snippet of the elements I’m trying to render:

return (Object.keys(this.state.center).length !== 0) ? (
      <GoogleMap
        defaultZoom={this.state.zoom}
        defaultCenter={this.state.center}
        options={{scrollwheel: true}}
      >
        {this.state.municipalities.map(municipality => {
          return <Polygon key={municipality.name}
                          paths={municipality.borders}
                          fillOpacity={0.3}/>;
        })}
        {this.state.trees.map(tree => {
          return <Marker key={tree.treeId} position={{lat: tree.location.latitude, lng: tree.location.longitude}}/>;
        })}
      </GoogleMap>
    ) : (
      <div>
      <Segment>
        <Dimmer active>
          <Loader size='huge'/>
        </Dimmer>
        <Image centered size='medium' src={Logo}/>
      </Segment>
      </div>
    );

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
abbasyadollahicommented, Apr 12, 2018

@SyedSaifAli I’m sending an object {lat: latitude, lng: longitude} for the defaultCenter property and the map renders fine when it is loaded. The problem I have is that a grey div that would normally render the map persists even if I’m not rendering a <GoogleMap> element. I believe it might have something to do with the withProps but not sure

0reactions
hjJuniorcommented, Feb 5, 2022

I have identified an weird behaviour, really inconsistent, when you have markers and one of them have invalid lat/lng you may have this empty grey box (and no errors on console 🤦)

On my specific case, this edge case was happening between new renders so everytime that I was updating the state, it was changing between empty box and the working map, also during this re-render I could notice a kick flash of map working with marker

Related with:

TL;DR: Check if you have any markers that may have an invalid Latitude / Longitude

Read more comments on GitHub >

github_iconTop Results From Across the Web

Grey boxes appear in parts of embedded Google Map in ...
Grey boxes appear in the map canvas when the modal is shown.​​ Resizing the browser window, bringing up Web Inspector, etc. makes all...
Read more >
UI best practices for loading, error, and empty states in React
In this article, we'll cover the best practices to use in client-side rendered React apps when handling loading, error, and empty state.
Read more >
Conditional Questions - FormAssembly Resource Center
To delete a condition, click the red [-] box to the right. AND/OR Branching. To add additional logic to your field, click the...
Read more >
Maya Getting Started: Applying a texture map to a polygon mesh
This displays the cracker box with a default gray, smooth shading material, lit using default lighting. Turning on Smooth Shade All displays the...
Read more >
KML Reference | Keyhole Markup Language
This information matches the Web Map Service (WMS) bounding box specification. If you specify an empty <viewFormat> tag, no information is appended to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found