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.

Warning: `NaN` is an invalid value for the `left` css style property. Check the render method of `GoogleMapMarkers`.

See original GitHub issue

Hi 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:closed
  • Created 6 years ago
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
AgustinCBcommented, Sep 15, 2017

I had this error recently and then realized that I was putting my latitude in lng and longitude in lat. Try switching them 😃

3reactions
callamwilliamscommented, Nov 2, 2018

If you are returning data from the places API (searchbox, autocomplete) make sure you call the lat/lng as functions rather than objects

<Marker
  key={place.id}
  text={place.name}
  lat={place.geometry.location.lat()}
  lng={place.geometry.location.lng()}
/>

Otherwise you are passing a function rather than a number - so NaN error

Try testing it manually with proper numbers, and double check the values you are passing via props.

Read more comments on GitHub >

github_iconTop 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 >

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