Google is not defined. JSHint Error


#1
geocode : functions()
{ 
  new google.maps.Geocoder().geocode( { address: addy }, deferred.resolve ); 
  return ...;
}

I tried adding following script to index.html

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"> </script>

Can anyone help me what is wrong in here ?


#2

jshint doesn’t exactly have access to the “magic” of the framework. In general, you can let JSHint (or I use JSLint, but close enough) know that are some globals that it can ignore and just trust you. You can add this:

/*global Google */

to the top of your file and it should make JSHint feel better.


#3

Thanks. It worked. It make sense that if you are using any global like google, setInterval(), clearInterval() JSHint is not smart enough to recognize those. So, if we use any global we have to add to JSHint manually. I was doing window.google, window.setInterval(), window.clearInterval(). That approach also works but I like JSHint approach better.


#4

great! glad it worked.