@@ -427,18 +427,24 @@ export interface ListOfflineRegionsOptions {
427
427
428
428
// ------------------------------------------------------------
429
429
430
+ export enum ControlPosition {
431
+ TOP_LEFT ,
432
+ TOP_RIGHT ,
433
+ BOTTOM_LEFT ,
434
+ BOTTOM_RIGHT
435
+ }
436
+
430
437
/**
431
438
* The options object passed into the show function.
432
439
*/
433
-
434
440
export interface ShowOptions {
435
441
accessToken : string ;
436
442
/**
437
443
* default 'streets'
438
444
*/
439
- style ?: MapStyle ;
445
+ style ?: string | MapStyle ;
440
446
margins ?: ShowOptionsMargins ;
441
- center ?: LatLng ;
447
+ center ?: Partial < LatLng > ;
442
448
/**
443
449
* default 0 (which is almost the entire planet)
444
450
*/
@@ -451,14 +457,26 @@ export interface ShowOptions {
451
457
* default false (required for the 'starter' plan)
452
458
*/
453
459
hideLogo ?: boolean ;
460
+ /**
461
+ * default BOTTOM_LEFT
462
+ */
463
+ logoPosition ?: ControlPosition ;
454
464
/**
455
465
* default true
456
466
*/
457
467
hideAttribution ?: boolean ;
468
+ /**
469
+ * default BOTTOM_LEFT
470
+ */
471
+ attributionPosition ?: ControlPosition ;
458
472
/**
459
473
* default false
460
474
*/
461
475
hideCompass ?: boolean ;
476
+ /**
477
+ * default TOP_RIGHT
478
+ */
479
+ compassPosition ?: ControlPosition ;
462
480
/**
463
481
* default false
464
482
*/
@@ -479,52 +497,46 @@ export interface ShowOptions {
479
497
* Immediately add markers to the map
480
498
*/
481
499
markers ?: MapboxMarker [ ] ;
482
-
483
500
/**
484
501
* callback on location permission granted
485
502
*
486
503
* Android Only
487
504
*/
488
-
489
505
onLocationPermissionGranted ?: any ;
490
-
491
506
/**
492
507
* callback on location permission denied
493
508
*
494
509
* Android Only
495
510
*/
496
-
497
511
onLocationPermissionDenied ?: any ;
498
-
499
512
/**
500
513
* callback on Map Ready
501
514
*/
502
-
503
515
onMapReady ?: any ;
504
-
505
516
/**
506
517
* callback on scroll event
507
518
*/
508
-
509
519
onScrollEvent ?: any ;
510
-
511
520
/**
512
521
* callback on move begin event
513
522
*/
514
-
515
523
onMoveBeginEvent ?: any ;
516
-
517
524
/**
518
525
* Android context
519
526
*/
520
-
521
527
context ?: any ;
522
-
523
528
/**
524
529
* Android parent View
525
530
*/
526
-
527
531
parentView ?: any ;
532
+ /**
533
+ * On Android by default there is a 200ms delay before showing the map to work around a race condition.
534
+ */
535
+ delay ?: number ;
536
+ /**
537
+ * See https://docs.mapbox.com/archive/android/maps/api/9.0.0/com/mapbox/mapboxsdk/location/LocationComponentOptions.html
538
+ */
539
+ locationComponentOptions : any ;
528
540
}
529
541
530
542
// ------------------------------------------------------------
@@ -724,9 +736,8 @@ export interface MapboxApi {
724
736
725
737
export abstract class MapboxCommon implements MapboxCommonApi {
726
738
constructor ( public view ?: MapboxViewCommonBase ) { }
727
- public static defaults = {
739
+ public static defaults : Partial < ShowOptions > = {
728
740
style : MapStyle . STREETS . toString ( ) ,
729
- mapStyle : MapStyle . STREETS . toString ( ) ,
730
741
margins : {
731
742
left : 0 ,
732
743
right : 0 ,
@@ -737,8 +748,11 @@ export abstract class MapboxCommon implements MapboxCommonApi {
737
748
showUserLocation : false , // true requires adding `NSLocationWhenInUseUsageDescription` or `NSLocationAlwaysUsageDescription` in the .plist
738
749
locationComponentOptions : { } ,
739
750
hideLogo : false , // required for the 'starter' plan
751
+ logoPosition : ControlPosition . BOTTOM_LEFT , // The default position mimics constructor of MapboxMapOptions
740
752
hideAttribution : true ,
753
+ attributionPosition : ControlPosition . BOTTOM_LEFT , // The default position mimics constructor of MapboxMapOptions
741
754
hideCompass : false ,
755
+ compassPosition : ControlPosition . TOP_RIGHT , // The default position mimics constructor of MapboxMapOptions
742
756
disableRotation : false ,
743
757
disableScroll : false ,
744
758
disableZoom : false ,
@@ -1152,13 +1166,25 @@ export const hideLogoProperty = new Property<MapboxViewCommonBase, boolean>({
1152
1166
} ) ;
1153
1167
hideLogoProperty . register ( MapboxViewCommonBase ) ;
1154
1168
1169
+ export const logoPositionProperty = new Property < MapboxViewCommonBase , ControlPosition > ( {
1170
+ name : 'logoPosition' ,
1171
+ defaultValue : MapboxCommon . defaults . logoPosition
1172
+ } ) ;
1173
+ logoPositionProperty . register ( MapboxViewCommonBase ) ;
1174
+
1155
1175
export const hideAttributionProperty = new Property < MapboxViewCommonBase , boolean > ( {
1156
1176
name : 'hideAttribution' ,
1157
1177
defaultValue : MapboxCommon . defaults . hideAttribution ,
1158
1178
valueConverter : booleanConverter
1159
1179
} ) ;
1160
1180
hideAttributionProperty . register ( MapboxViewCommonBase ) ;
1161
1181
1182
+ export const attributionPositionProperty = new Property < MapboxViewCommonBase , ControlPosition > ( {
1183
+ name : 'attributionPosition' ,
1184
+ defaultValue : MapboxCommon . defaults . attributionPosition
1185
+ } ) ;
1186
+ attributionPositionProperty . register ( MapboxViewCommonBase ) ;
1187
+
1162
1188
export const telemetryProperty = new Property < MapboxViewCommonBase , boolean > ( {
1163
1189
name : 'telemetry' ,
1164
1190
defaultValue : false ,
@@ -1173,6 +1199,12 @@ export const hideCompassProperty = new Property<MapboxViewCommonBase, boolean>({
1173
1199
} ) ;
1174
1200
hideCompassProperty . register ( MapboxViewCommonBase ) ;
1175
1201
1202
+ export const compassPositionProperty = new Property < MapboxViewCommonBase , ControlPosition > ( {
1203
+ name : 'compassPosition' ,
1204
+ defaultValue : MapboxCommon . defaults . compassPosition
1205
+ } ) ;
1206
+ compassPositionProperty . register ( MapboxViewCommonBase ) ;
1207
+
1176
1208
export const disableZoomProperty = new Property < MapboxViewCommonBase , boolean > ( {
1177
1209
name : 'disableZoom' ,
1178
1210
defaultValue : MapboxCommon . defaults . disableZoom ,
@@ -1229,15 +1261,14 @@ export abstract class MapboxViewBase extends MapboxViewCommonBase {
1229
1261
public static locationPermissionGrantedEvent : string = 'locationPermissionGranted' ;
1230
1262
public static locationPermissionDeniedEvent : string = 'locationPermissionDenied' ;
1231
1263
1232
- protected config : any = { } ;
1264
+ protected config : Partial < ShowOptions > = { } ;
1233
1265
1234
1266
[ zoomLevelProperty . setNative ] ( value : number ) {
1235
1267
this . config . zoomLevel = + value ;
1236
1268
}
1237
1269
1238
1270
[ mapStyleProperty . setNative ] ( value : string ) {
1239
1271
this . config . style = value ;
1240
- this . config . mapStyle = value ;
1241
1272
}
1242
1273
1243
1274
[ accessTokenProperty . setNative ] ( value : string ) {
@@ -1270,14 +1301,26 @@ export abstract class MapboxViewBase extends MapboxViewCommonBase {
1270
1301
this . config . hideLogo = value ;
1271
1302
}
1272
1303
1304
+ [ logoPositionProperty . setNative ] ( value : ControlPosition ) {
1305
+ this . config . logoPosition = value ;
1306
+ }
1307
+
1273
1308
[ hideAttributionProperty . setNative ] ( value : boolean ) {
1274
1309
this . config . hideAttribution = value ;
1275
1310
}
1276
1311
1312
+ [ attributionPositionProperty . setNative ] ( value : ControlPosition ) {
1313
+ this . config . attributionPosition = value ;
1314
+ }
1315
+
1277
1316
[ hideCompassProperty . setNative ] ( value : boolean ) {
1278
1317
this . config . hideCompass = value ;
1279
1318
}
1280
1319
1320
+ [ compassPositionProperty . setNative ] ( value : ControlPosition ) {
1321
+ this . config . compassPosition = value ;
1322
+ }
1323
+
1281
1324
[ disableZoomProperty . setNative ] ( value : boolean ) {
1282
1325
this . config . disableZoom = value ;
1283
1326
}
0 commit comments