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.

error 'google' is not defined no-undef

See original GitHub issue

This doc: https://tomchentw.github.io/react-google-maps/basics/directions isn’t working at all.

can’t get around: error ‘google’ is not defined no-undef

I did find a solution that is partly working, e.g. using

  return (
       <GoogleMapLoader
               containerElement={mapContainer}
               googleMapElement={
                   <GoogleMap  
                       defaultZoom={12}
                       defaultCenter={this.props.center}
                       options={{ streetviewcontrol: false, mapTypeControl: true}}>
                   </GoogleMap>
               } 

But I have no idea how to match this to the tutorial with componentDidMount etc. to get it to work with the direction service. Any help is greatly appreciated.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

126reactions
voquockhanhcommented, Jun 19, 2017

add this line to top of your file: /*global google*/ -> for disable ESLint

40reactions
johnaniserecommented, Jan 9, 2018

const google=window.google solves this problem.You see this because reactjs use a linting rule that forbids unknown global variables.

Read more comments on GitHub >

github_iconTop Results From Across the Web

'Google' is not defined: adding Google Maps API in React JS
Okay, this seems to work: The solution was to implicitly define google in a variable above the class, like this: const google =...
Read more >
Reference Error: google is not defined
Hi All, I am trying to execute javascript through Qt script. My javascript contains code for google maps API. ... Error: google is...
Read more >
Google Maps API Common Errors & Solutions - SoftAuthor
2. Google is not defined ... Scenario #1: When you are trying to create a Google Maps Map Object without including the Maps...
Read more >
How do import a javascript file on /scripts/routes/common.js?
28:23 error 'google' is not defined no-undef 62:33 error Missing trailing comma comma-dangle 66:26 error 'google' is not defined no-undef
Read more >
Uncaught ReferenceError: google is not defined - MSDN
Usually this type of error is due to forgetting to reference a JavaScript library or trying to access a library object before the...
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