tmaximini / generator-ionic-gulp

A Yeoman generator for fast hybrid app development that stays out of your way
134 stars 36 forks source link

angular-google-maps #40

Closed dco5 closed 7 years ago

dco5 commented 7 years ago

Has someone being able to use angular-google-maps with this generator? I tried bower install angular-google-maps --save

But I keep getting Error: [$injector:modulerr] Failed to instantiate module uiGmapgoogle-maps due to: Error: [$injector:nomod] Module 'uiGmapgoogle-maps' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument. angular.module('app', [ 'ionic', 'ngCordova', 'ngResource','uiGmapgoogle-maps' ])

If I try this on the regular ionic starter and add the scripts manually it works without a problem.

tmaximini commented 7 years ago

not really sure what is going on with that library. the project page says Tip use some library which will always pull in your dependencies (no matter what the changes are) to your vendor.js. (see https://github.com/angular-ui/angular-google-maps#dependencies)

This generator uses wiredep, which does that for us. If I throw a console.log in the generated gulpfile, I see the deps are being added correctly (it seems):

gulp.task('vendor', function() {
  var vendorFiles = wiredep().js;

  console.log('vendorFiles', vendorFiles);

  return gulp.src(vendorFiles)
    .pipe(plugins.concat('vendor.js'))
    .pipe(plugins.if(build, plugins.uglify()))
    .pipe(plugins.if(build, plugins.rev()))

    .pipe(gulp.dest(targetDir))

    .on('error', errorHandler);
});

produces:

vendorFiles [ '/Users/thomas/projects/test/ionic/bower_components/angular/angular.js',
  '/Users/thomas/projects/test/ionic/bower_components/ngCordova/dist/ng-cordova.js',
  '/Users/thomas/projects/test/ionic/bower_components/angular-resource/angular-resource.js',
  '/Users/thomas/projects/test/ionic/bower_components/angular-animate/angular-animate.js',
  '/Users/thomas/projects/test/ionic/bower_components/angular-sanitize/angular-sanitize.js',
  '/Users/thomas/projects/test/ionic/bower_components/angular-ui-router/release/angular-ui-router.js',
  '/Users/thomas/projects/test/ionic/bower_components/ionic/release/js/ionic.js',
  '/Users/thomas/projects/test/ionic/bower_components/ionic/release/js/ionic-angular.js',
  '/Users/thomas/projects/test/ionic/bower_components/angular-simple-logger/dist/angular-simple-logger.js',
  '/Users/thomas/projects/test/ionic/bower_components/lodash/lodash.js',
  '/Users/thomas/projects/test/ionic/bower_components/markerclustererplus/src/markerclusterer.js',
  '/Users/thomas/projects/test/ionic/bower_components/google-maps-utility-library-v3-markerwithlabel/dist/markerwithlabel.js',
  '/Users/thomas/projects/test/ionic/bower_components/google-maps-utility-library-v3-infobox/dist/infobox.js',
  '/Users/thomas/projects/test/ionic/bower_components/google-maps-utility-library-v3-keydragzoom/dist/keydragzoom.js',
  '/Users/thomas/projects/test/ionic/bower_components/js-rich-marker/src/richmarker.js',
  '/Users/thomas/projects/test/ionic/bower_components/angular-google-maps/dist/angular-google-maps.js' ]

it also gives a reference error vendor.js:94868 Uncaught ReferenceError: google is not defined maybe that's the root problem?

dco5 commented 7 years ago

Yes I think is trying to use the google library before is loaded, but I am using the async load so that is not suppose to happen. It is only happening with this template, I tried with another template and there are no problems.

tmaximini commented 7 years ago

reading through the quickstart guide it says you have to include the google maps API yourself (see point 3. requirements here: http://angular-ui.github.io/angular-google-maps/#!/use) When I do this it works without any error.

tmaximini commented 7 years ago

Also please update the generator to version 1.5.1

dco5 commented 7 years ago

Updated to version 1.5.1 and now is working! Thank you so much for you help!