Matt-Jensen / ember-cli-g-maps

Deprecated Google Maps Addon
http://matt-jensen.github.io/ember-cli-g-maps
MIT License
59 stars 31 forks source link

Unable to get geocoding for gMaps to work #99

Closed stephcmartin closed 7 years ago

stephcmartin commented 7 years ago

Hi Matt,

I ran through the setup guide for ember-cli-g-maps, first running ember install ember-cli-g-maps, then adding

ENV.contentSecurityPolicy = {
  'default-src': "'none'",
  'script-src': "'self' 'unsafe-eval' *.googleapis.com maps.gstatic.com",
  'font-src': "'self' fonts.gstatic.com",
  'connect-src': "'self' maps.gstatic.com",
  'img-src': "'self' *.googleapis.com maps.gstatic.com csi.gstatic.com",
  'style-src': "'self' 'unsafe-inline' fonts.googleapis.com maps.gstatic.com"
};

and

  ENV.googleMap = {
  apiKey: '*my api keys*',
  libraries: ['drawing', 'visualization']
};

I ran ember generate route google-search and placed the following in my .hbs file:

<h3>Search For A Location Through Google</h3>
{{g-maps name="my-map" lat=lat lng=lng zoom=zoom}}

In my .js file I have:

import Ember from 'ember';

export default Ember.Route.extend({
  setupController: function(controller) {
    controller.setProperties({
      lat: 42.75494243654723,
      lng: -71.8359375,
      zoom: 8
    });
  }
});

However, when I refresh the page, the map loads for around 2 seconds, then errors Oops! Something went wrong. screen shot 2017-11-04 at 12 57 29 pm

The console errors on chrome are: common.js:47 Uncaught TypeError: Cannot read property 'prototype' of undefined, js:59 Uncaught TypeError: Cannot read property 'data' of undefined and Uncaught TypeError: b.match is not a function.

I'm pretty sure I set up everything right. Is there something I'm missing?

Matt-Jensen commented 7 years ago

@stephcmartin can you make a sample repo for me to debug using your exact code?

stephcmartin commented 7 years ago

@Matt-Jensen My whole repo is here: https://github.com/stephcmartin/waldo/tree/google/app

The .hbs file is here: https://github.com/stephcmartin/waldo/blob/google/app/templates/google-search.hbs

The .js file is here: https://github.com/stephcmartin/waldo/blob/google/app/routes/google-search.js

Matt-Jensen commented 7 years ago

Hey Steph, I'm playing with master right now and I'm not seeing ember-cli-g-maps added to the project. Is there a specific branch I should be using?

stephcmartin commented 7 years ago

Hi Matt, just tried starting it from scratch and it's on the 'g-maps' branch.

It can be found here.

My package.json file is here, it has the package installed.

The google-search.hbs is in waldo/app/templates/google-search.hbs, and the .js script is in waldo/app/routes/google-search.js

The route is this.route('google-search', {path: 'location/search'});, so if you fork and clone it, you can run it at http://localhost:7165/location/search.

Sorry for not being specific - and thank you for investigating :)

Matt-Jensen commented 7 years ago

Thanks for that Steph, however seems to be working fine for me:

Chrome: 61.0.3163.100 ember-cli: 2.16.2 node: 6.11.5 os: darwin x64

However I see you have "ember-cli": "^2.10.0" specified in your package.json file, are your existing dependencies a similar version to mine? However if this issue is resolve by migrating your project to the latest ember-cli that could be a good solution, because I'm not sure I'm even testing on 2.10 anymore.

stephcmartin commented 7 years ago

Hi Matt,

I ran an update and it works! Thank you so much!

I just followed the instructions on this page.

Best, Steph