Empty Grey Box When Conditionally Rendering GMaps
See original GitHub issueBefore 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.
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:
- Created 5 years ago
- Comments:5
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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 thewithProps
but not sureI 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