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([
3636 { mapIds : [ "foo" , "bar" ] } ,
3737 "https://maps.googleapis.com/maps/api/js?callback=__googleMapsCallback&map_ids=foo,bar" ,
3838 ] ,
39+ [
40+ { url : "https://example.com/js" } ,
41+ "https://example.com/js?callback=__googleMapsCallback" ,
42+ ] ,
3943] ) ( "createUrl is correct" , ( options : LoaderOptions , expected : string ) => {
4044 const loader = new Loader ( options ) ;
4145 expect ( loader . createUrl ( ) ) . toEqual ( expected ) ;
Original file line number Diff line number Diff line change @@ -130,6 +130,10 @@ export interface LoaderOptions {
130130 * your bootstrap request.
131131 */
132132 mapIds ?: string [ ] ;
133+ /**
134+ * Use a custom url and path to load the Google Maps API script.
135+ */
136+ url ?: string ;
133137}
134138
135139/**
@@ -179,8 +183,12 @@ export class Loader {
179183 */
180184 mapIds : string [ ] ;
181185
186+ /**
187+ * See [[LoaderOptions.url]]
188+ */
189+ url : string ;
190+
182191 private CALLBACK = "__googleMapsCallback" ;
183- private URL = "https://maps.googleapis.com/maps/api/js" ;
184192 private callbacks : ( ( e : Event ) => void ) [ ] = [ ] ;
185193 private done = false ;
186194 private loading = false ;
@@ -202,21 +210,23 @@ export class Loader {
202210 region,
203211 version,
204212 mapIds,
213+ url = "https://maps.googleapis.com/maps/api/js" ,
205214 } : LoaderOptions ) {
206215 this . version = version ;
207216 this . apiKey = apiKey ;
208217 this . libraries = libraries ;
209218 this . language = language ;
210219 this . region = region ;
211220 this . mapIds = mapIds ;
221+ this . url = url ;
212222 }
213223 /**
214224 * CreateUrl returns the Google Maps JavaScript API script url given the [[LoaderOptions]].
215225 *
216226 * @ignore
217227 */
218228 createUrl ( ) : string {
219- let url = this . URL ;
229+ let url = this . url ;
220230
221231 url += `?callback=${ this . CALLBACK } ` ;
222232
You can’t perform that action at this time.
0 commit comments