@@ -60,7 +60,8 @@ class MapOptions {
6060 providerOptions : ProviderMapOptions | object ;
6161 singlePinZoom : number ;
6262 wrapper : HTMLElement | null ;
63- instance : typeof mapboxgl ;
63+ iframeWindow : Window | undefined ;
64+ apiKey : string | undefined ;
6465 /**
6566 * Initialize with default options
6667 */
@@ -81,7 +82,6 @@ class MapOptions {
8182 this . providerOptions = { } ;
8283 this . singlePinZoom = 14 ;
8384 this . wrapper = null ;
84- this . instance = mapboxgl ;
8585 }
8686
8787 /**
@@ -192,8 +192,20 @@ class MapOptions {
192192 return this ;
193193 }
194194
195- withInstance ( instance : typeof mapboxgl ) : MapOptions {
196- this . instance = instance ;
195+ /**
196+ * @param iframeWindow - The window of the iframe that the map will be rendered in.
197+ * This is only necessary if the map is being rendered in an iframe.
198+ */
199+ withIframeWindow ( iframeWindow : Window | undefined ) : MapOptions {
200+ this . iframeWindow = iframeWindow ;
201+ return this ;
202+ }
203+
204+ /**
205+ * @param apiKey - The API key to use for the map provider, if required.
206+ */
207+ withApiKey ( apiKey : string | undefined ) : MapOptions {
208+ this . apiKey = apiKey ;
197209 return this ;
198210 }
199211
@@ -230,7 +242,6 @@ class Map {
230242 _panHandler ?: PanHandler ;
231243 _panStartHandler ?: PanStartHandler ;
232244 _map : ProviderMap ;
233- _instance : typeof mapboxgl ;
234245
235246 constructor ( options : MapOptions ) {
236247 assertInstance ( options , MapOptions ) ;
@@ -279,13 +290,12 @@ class Map {
279290 . withPanHandler ( ( ) => this . panHandler ( ) )
280291 . withPanStartHandler ( ( ) => this . panStartHandler ( ) )
281292 . withProviderOptions ( options . providerOptions )
282- . withInstance ( options . instance )
293+ . withIframeWindow ( options . iframeWindow )
294+ . withApiKey ( options . apiKey )
283295 . build ( ) ;
284296
285297 this . setZoomCenter ( this . _defaultZoom , this . _defaultCenter ) ;
286298 this . _currentBounds = this . getBounds ( ) ;
287-
288- this . _instance = options . instance ;
289299 }
290300
291301 /**
@@ -401,7 +411,7 @@ class Map {
401411 * instance with the same provider as this map
402412 */
403413 newPinOptions ( ) : MapPinOptions {
404- return new MapPinOptions ( ) . withProvider ( this . _provider ) . withInstance ( this . _instance ) ;
414+ return new MapPinOptions ( ) . withProvider ( this . _provider ) ;
405415 }
406416
407417 /**
0 commit comments