Currently the user has to inject the google maps SDK manually before using this addon. It would be great if it could be handled by the addon. In my project I'm using the following helper that I borrowed from some other ember google maps addon:
import Ember from 'ember';
const API_KEY = 'xxxxxxxxtheapikeyxxxxxx';
const LIBRARIES = ['drawing'];
var promise;
/**
* Loads the google map SDK
*
* @return {Ember.RSVP.Promise}
*/
export function loadGoogleMaps(resolveWith) {
if (window.google && window.google.maps) {
return Ember.RSVP.resolve(resolveWith);
}
if (promise) {
return promise;
}
var src = `https://maps.googleapis.com/maps/api/js?key=${API_KEY}&libraries=${LIBRARIES.join(",")}`;
return promise = new Ember.RSVP.Promise(function (resolve, reject) {
window.__emberGoogleMapLoaded__ = Ember.run.bind(function () {
promise = null;
window.__emberGoogleMapLoaded__ = null;
resolve(resolveWith);
});
Ember.$.getScript(src + '&callback=__emberGoogleMapLoaded__').fail(function (jqXhr) {
promise = null;
window.__emberGoogleMapLoaded__ = null;
reject(jqXhr);
});
});
}
export default Ember.Helper.helper(loadGoogleMaps);
Currently the user has to inject the google maps SDK manually before using this addon. It would be great if it could be handled by the addon. In my project I'm using the following helper that I borrowed from some other ember google maps addon: