File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,10 @@ test.each([
36
36
{ mapIds : [ "foo" , "bar" ] } ,
37
37
"https://maps.googleapis.com/maps/api/js?callback=__googleMapsCallback&map_ids=foo,bar" ,
38
38
] ,
39
+ [
40
+ { url : "https://example.com/js" } ,
41
+ "https://example.com/js?callback=__googleMapsCallback" ,
42
+ ] ,
39
43
] ) ( "createUrl is correct" , ( options : LoaderOptions , expected : string ) => {
40
44
const loader = new Loader ( options ) ;
41
45
expect ( loader . createUrl ( ) ) . toEqual ( expected ) ;
Original file line number Diff line number Diff line change @@ -130,6 +130,10 @@ export interface LoaderOptions {
130
130
* your bootstrap request.
131
131
*/
132
132
mapIds ?: string [ ] ;
133
+ /**
134
+ * Use a custom url and path to load the Google Maps API script.
135
+ */
136
+ url ?: string ;
133
137
}
134
138
135
139
/**
@@ -179,8 +183,12 @@ export class Loader {
179
183
*/
180
184
mapIds : string [ ] ;
181
185
186
+ /**
187
+ * See [[LoaderOptions.url]]
188
+ */
189
+ url : string ;
190
+
182
191
private CALLBACK = "__googleMapsCallback" ;
183
- private URL = "https://maps.googleapis.com/maps/api/js" ;
184
192
private callbacks : ( ( e : Event ) => void ) [ ] = [ ] ;
185
193
private done = false ;
186
194
private loading = false ;
@@ -202,21 +210,23 @@ export class Loader {
202
210
region,
203
211
version,
204
212
mapIds,
213
+ url = "https://maps.googleapis.com/maps/api/js" ,
205
214
} : LoaderOptions ) {
206
215
this . version = version ;
207
216
this . apiKey = apiKey ;
208
217
this . libraries = libraries ;
209
218
this . language = language ;
210
219
this . region = region ;
211
220
this . mapIds = mapIds ;
221
+ this . url = url ;
212
222
}
213
223
/**
214
224
* CreateUrl returns the Google Maps JavaScript API script url given the [[LoaderOptions]].
215
225
*
216
226
* @ignore
217
227
*/
218
228
createUrl ( ) : string {
219
- let url = this . URL ;
229
+ let url = this . url ;
220
230
221
231
url += `?callback=${ this . CALLBACK } ` ;
222
232
You can’t perform that action at this time.
0 commit comments