OLD | NEW |
1 <!-- | 1 <!-- |
2 Copyright (c) 2014 The Polymer Project Authors. All rights reserved. | 2 Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
3 This code may only be used under the BSD style license found at https://polymer.
github.io/LICENSE.txt | 3 This code may only be used under the BSD style license found at https://polymer.
github.io/LICENSE.txt |
4 The complete set of authors may be found at https://polymer.github.io/AUTHORS.tx
t | 4 The complete set of authors may be found at https://polymer.github.io/AUTHORS.tx
t |
5 The complete set of contributors may be found at https://polymer.github.io/CONTR
IBUTORS.txt | 5 The complete set of contributors may be found at https://polymer.github.io/CONTR
IBUTORS.txt |
6 Code distributed by Google as part of the polymer project is also | 6 Code distributed by Google as part of the polymer project is also |
7 subject to an additional IP rights grant found at https://polymer.github.io/PATE
NTS.txt | 7 subject to an additional IP rights grant found at https://polymer.github.io/PATE
NTS.txt |
8 --> | 8 --> |
9 | 9 |
10 <link rel="import" href="../polymer/polymer.html"> | 10 <link rel="import" href="../polymer/polymer.html"> |
11 <link rel="import" href="../iron-jsonp-library/iron-jsonp-library.html"> | 11 <link rel="import" href="../iron-jsonp-library/iron-jsonp-library.html"> |
12 | 12 |
13 <script> | 13 <script> |
14 /** | 14 /** |
15 Dynamically loads the Google Maps JavaScript API, firing the `api-load` event wh
en ready. | 15 Dynamically loads the Google Maps JavaScript API, firing the `api-load` event wh
en ready. |
16 | 16 |
17 #### Example | 17 #### Example |
18 | 18 |
19 <google-maps-api api-key="abc123" version="3.exp"></google-maps-api> | 19 <google-maps-api api-key="abc123" version="3.exp"></google-maps-api> |
20 <script> | 20 <script> |
21 var mapsAPI = document.querySelector('google-maps-api'); | 21 var mapsAPI = document.querySelector('google-maps-api'); |
22 mapsAPI.addEventListener('api-load', function(e) { | 22 mapsAPI.addEventListener('api-load', function(e) { |
23 // this.api === google.maps | 23 // this.api === google.maps |
24 }); | 24 }); |
25 <script> | 25 <script> |
26 | 26 |
27 Any number of components can use `<google-maps-api>` elements, and the library w
ill only be loaded once. | 27 Any number of components can use `<google-maps-api>` elements, and the library w
ill only be loaded once. |
28 | 28 |
29 @blurb Element wrapper around Google Maps API. | 29 @summary Element wrapper around Google Maps API. |
30 | 30 |
31 */ | 31 */ |
32 Polymer({ | 32 Polymer({ |
33 | 33 |
34 is: 'google-maps-api', | 34 is: 'google-maps-api', |
35 | 35 |
36 behaviors: [ | 36 behaviors: [ |
37 Polymer.IronJsonpLibraryBehavior | 37 Polymer.IronJsonpLibraryBehavior |
38 ], | 38 ], |
39 | 39 |
(...skipping 16 matching lines...) Expand all Loading... |
56 /** | 56 /** |
57 * A Maps API for Business Client ID. To obtain a Maps API for Business Cl
ient ID, see developers.google.com/maps/documentation/business/. | 57 * A Maps API for Business Client ID. To obtain a Maps API for Business Cl
ient ID, see developers.google.com/maps/documentation/business/. |
58 * If set, a Client ID will take precedence over an API Key. | 58 * If set, a Client ID will take precedence over an API Key. |
59 */ | 59 */ |
60 clientId: { | 60 clientId: { |
61 type: String, | 61 type: String, |
62 value: '' | 62 value: '' |
63 }, | 63 }, |
64 | 64 |
65 /** | 65 /** |
66 * The libraries to load with this map. For more information | |
67 * see https://developers.google.com/maps/documentation/javascript/librari
es. | |
68 */ | |
69 libraries: { | |
70 type: String, | |
71 value: '' | |
72 }, | |
73 | |
74 /** | |
75 * Version of the Maps API to use. | 66 * Version of the Maps API to use. |
76 */ | 67 */ |
77 version: { | 68 version: { |
78 type: String, | 69 type: String, |
79 value: '3.exp' | 70 value: '3.exp' |
80 }, | 71 }, |
81 | 72 |
82 /** | 73 /** |
83 * The localized language to load the Maps API with. For more information | 74 * The localized language to load the Maps API with. For more information |
84 * see https://developers.google.com/maps/documentation/javascript/basics#
Language | 75 * see https://developers.google.com/maps/documentation/javascript/basics#
Language |
(...skipping 22 matching lines...) Expand all Loading... |
107 * Name of event fired when library is loaded and available. | 98 * Name of event fired when library is loaded and available. |
108 */ | 99 */ |
109 notifyEvent: { | 100 notifyEvent: { |
110 type: String, | 101 type: String, |
111 value: 'api-load' | 102 value: 'api-load' |
112 }, | 103 }, |
113 | 104 |
114 /** @private */ | 105 /** @private */ |
115 libraryUrl: { | 106 libraryUrl: { |
116 type: String, | 107 type: String, |
117 computed: '_computeUrl(mapsUrl, version, libraries, apiKey, clientId, la
nguage, signedIn)' | 108 computed: '_computeUrl(mapsUrl, version, apiKey, clientId, language, sig
nedIn)' |
118 } | 109 } |
119 }, | 110 }, |
120 | 111 |
121 _computeUrl: function(mapsUrl, version, libraries, apiKey, clientId, languag
e, signedIn) { | 112 _computeUrl: function(mapsUrl, version, apiKey, clientId, language, signedIn
) { |
122 var url = mapsUrl + '&v=' + version; | 113 var url = mapsUrl + '&v=' + version; |
123 | 114 |
124 if (libraries) { | 115 // Always load all Maps API libraries. |
125 url += "&libraries=" + libraries; | 116 url += '&libraries=drawing,geometry,places,visualization'; |
126 } | |
127 | 117 |
128 if (apiKey && !clientId) { | 118 if (apiKey && !clientId) { |
129 url += '&key=' + apiKey; | 119 url += '&key=' + apiKey; |
130 } | 120 } |
131 | 121 |
132 if (clientId) { | 122 if (clientId) { |
133 url += '&client=' + clientId; | 123 url += '&client=' + clientId; |
134 } | 124 } |
135 | 125 |
136 if (language) { | 126 if (language) { |
137 url += '&language=' + language; | 127 url += '&language=' + language; |
138 } | 128 } |
139 | 129 |
140 if (signedIn) { | 130 if (signedIn) { |
141 url += '&signed_in=' + signedIn; | 131 url += '&signed_in=' + signedIn; |
142 } | 132 } |
143 return url; | 133 return url; |
144 }, | 134 }, |
145 | 135 |
146 /** | 136 /** |
147 * Provides the google.maps JS API namespace. | 137 * Provides the google.maps JS API namespace. |
148 */ | 138 */ |
149 get api() { | 139 get api() { |
150 return google.maps; | 140 return google.maps; |
151 } | 141 } |
152 }); | 142 }); |
153 </script> | 143 </script> |
OLD | NEW |