forked from asennikov/ember-g-map
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
66 lines (52 loc) · 1.54 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* eslint-env node */
'use strict';
module.exports = {
name: 'ember-g-map',
included: function(app, parentAddon) {
var target = (parentAddon || app);
target.import('vendor/addons.css');
},
contentFor: function(type, config) {
var content = '';
if (type === 'head') {
var src = '//maps.googleapis.com/maps/api/js';
var gMapConfig = config['g-map'] || {};
var params = [];
var key = gMapConfig.key;
if (key) {
params.push('key=' + encodeURIComponent(key));
}
var version = gMapConfig.version;
if (version) {
params.push('v=' + encodeURIComponent(version));
}
var client = gMapConfig.client;
if (client) {
params.push('client=' + encodeURIComponent(client));
}
var channel = gMapConfig.channel;
if (channel) {
params.push('channel=' + encodeURIComponent(channel));
}
var libraries = gMapConfig.libraries;
if (libraries && libraries.length) {
params.push('libraries=' + encodeURIComponent(libraries.join(',')));
}
var language = gMapConfig.language;
if (language) {
params.push('language=' + encodeURIComponent(language));
}
var protocol = gMapConfig.protocol;
if (protocol) {
src = protocol + ':' + src;
}
src += '?' + params.join('&');
content = '<script type="text/javascript" src="' + src + '"></script>';
var exclude = gMapConfig.exclude;
if (exclude) {
content = ''
}
}
return content;
}
};