Warning: `NaN` is an invalid value for the `left` css style property. Check the render method of `GoogleMapMarkers`.
See original GitHub issueHi all,
I’m using google-map-react library for my project and but I keep getting an error in my browser saying that Warning: NaN
is an invalid value for the left
css style property. Check the render method of GoogleMapMarkers
.
Plus, my map does not even get rendered even though there is specific height and width for it.
My code looks like googleMap.js
import React from 'react';
import GoogleMap from 'google-map-react';
import Cart from './cart';
export default (props) => {
return (
<GoogleMap
defaultCenter={[props.lat, props.lng]}
defaultZoom={12}
>
<Cart lat={props.lat} lng={props.lng}/>
</GoogleMap>
);
}
cart.js
import React from 'react';
export default () => {
return (
<i className="fa fa-shopping-cart fa-2x" aria-hidden="true"></i>
);
}
and a method that using google map component
renderMap() {
if (this.props.loc) {
return (
<GoogleMap lat={this.props.loc.lat} lng={this.props.loc.lng}/>
);
} else {
return <h4>Loading map...</h4>
}
}
Has anyone had this kind of issue or know how to solve it?
Thank you all for your time reading this and works.
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (2 by maintainers)
Top Results From Across the Web
`NaN` is an invalid value for the `background` css style ...
I changed the value of the background property to a string literal and that fixed the issue. enter={{ background: `${stripe.background}`, }}.
Read more >Maps JavaScript API Release Notes - Google Developers
NaN values are rejected for width or height when validating marker icon size, marker icon scaled size, or infowindow size. Fixes a bug...
Read more >yFiles for HTML - Changelog - yWorks
The ImageNodeStyle class now supports a numeric aspectRatio property with which a specific aspect ratio of the rendered image can be set. In...
Read more >https://mcdaust.com.au/wp-content/plugins/wp-googl...
Create a custom Google map with high quality markers containing categories ... Fixed various typos * Fixed error where _gdprCompliance on Plugin class...
Read more >WP Google Maps – Pro Add-on Changelog
Updated 2022-12-25 15:25:31 9.0.13 - 2022-11-01. Added ability to set/hide markers on the frontend with the bulk editor. Fixed issue where hover icons...
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
I had this error recently and then realized that I was putting my latitude in
lng
and longitude inlat
. Try switching them 😃If you are returning data from the places API (searchbox, autocomplete) make sure you call the lat/lng as functions rather than objects
Otherwise you are passing a function rather than a number - so
NaN
errorTry testing it manually with proper numbers, and double check the values you are passing via props.