5

I'm getting ReferenceError: _ is not defined the angular-google-maps

I don't really understand why I'm getting this error, because I'm doing exactly what it is written on the website.

Also I searched for similar questions, but they didn't helped.

bundle.js

$ = window.$ = window.jQuery = require('./lib/jquery');
require('./lib/angular-simple-logger.js');
require('./lib/angular-google-maps.js');
require('./lib/lodash.js');

I'm importind bundle.js into the index.html. I also tried to use ngLodash, but no results.

app.js

var app = angular.module('app', [
  'ngLodash',
  'nemLogging',
  'uiGmapgoogle-maps'
]);

app.config(function(uiGmapGoogleMapApiProvider) {
    uiGmapGoogleMapApiProvider.configure({
       key: '{myKey}',
       v: '3.20',
       libraries: 'places' // I don't need the whole map, only the places
   });
});

Also I enabled the GoogleMaps Api from the Google Developer Console

Does someone have some experience with this library and can give me a hint?

1 Answer 1

5

You need to add the _ underscore library as a dependency. npm install underscore, or add to your bower config, or whatever you use for dependecy management.

<script src="bower_components/underscore/underscore-min.js"></script>
Sign up to request clarification or add additional context in comments.

1 Comment

I am facing the same issue. I even added underscore as a dependency using maven, but still getting the same error. Can anyone please help me out?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.