@@ -6,10 +6,25 @@ import invariant from 'invariant'
66
77import ErrorBoundry from './ErrorBoundry'
88
9+ type MapKitFeatureVisibility = 'adaptive' | 'hidden' | 'visible'
10+ type MapKitMapType = 'hybrid' | 'satellite' | 'standard'
11+
912type Props = {
1013 callbackUrl ?: string ,
1114 token ?: string ,
15+
16+ mapType : MapKitMapType ,
17+ padding :
18+ | number
19+ | { top ?: number , bottom ?: number , left ?: number , right ?: number } ,
20+ showsCompass : MapKitFeatureVisibility ,
21+ showsMapTypeControl : boolean ,
22+ showsZoomControl : boolean ,
23+ showsUserLocationControl : boolean ,
24+ showsPointsOfInterest : boolean ,
25+ showsScale : MapKitFeatureVisibility ,
1226 tintColor ?: string ,
27+
1328 showsUserLocationControl : boolean ,
1429}
1530
@@ -25,7 +40,14 @@ class MapKit extends React.Component<Props, State> {
2540 map = null
2641
2742 static defaultProps = {
43+ mapType : 'standard' ,
44+ padding : 0 ,
45+ showsCompass : 'adaptive' ,
46+ showsMapTypeControl : true ,
47+ showsZoomControl : true ,
2848 showsUserLocationControl : false ,
49+ showsPointsOfInterest : true ,
50+ showsScale : 'hidden' ,
2951 }
3052
3153 state = {
@@ -50,9 +72,39 @@ class MapKit extends React.Component<Props, State> {
5072
5173 this . map = new mapkit . Map ( 'map' )
5274
75+ console . log ( mapkit . Map . MapTypes . Standard )
76+
77+ this . updateMapProps ( props )
78+
5379 this . setState ( { mapKitIsReady : true } )
5480 }
5581
82+ updateMapProps = ( props : Props ) = > {
83+ // Update map based on props
84+ this . map . showsMapTypeControl = props . showsMapTypeControl
85+ this . map . mapType = props . mapType
86+
87+ const padding = new mapkit . Padding (
88+ typeof props . padding === 'number'
89+ ? {
90+ top : props . padding ,
91+ right : props . padding ,
92+ bottom : props . padding ,
93+ left : props . padding ,
94+ }
95+ : { top : 0 , right : 0 , bottom : 0 , left : 0 , ...props . padding } ,
96+ )
97+
98+ this . map . padding = padding
99+ this . map . showsCompass = props . showsCompass
100+ this . map . showsMapTypeControl = props . showsMapTypeControl
101+ this . map . showsZoomControl = props . showsZoomControl
102+ this . map . showsUserLocationControl = props . showsUserLocationControl
103+ this . map . showsPointsOfInterest = props . showsPointsOfInterest
104+ this . map . showsScale = props . showsScale
105+ this . map . tintColor = props . tintColor
106+ }
107+
56108 constructor ( props : Props ) {
57109 super ( props )
58110
@@ -84,9 +136,7 @@ class MapKit extends React.Component<Props, State> {
84136 }
85137
86138 if ( this . state . mapKitIsReady ) {
87- // Update map based on props
88- this . map . tintColor = nextProps . tintColor
89- this . map . showsUserLocationControl = nextProps . showsUserLocationControl
139+ this . updateMapProps ( nextProps )
90140 }
91141
92142 return ComponentShouldUpdate
@@ -96,8 +146,17 @@ class MapKit extends React.Component<Props, State> {
96146 const {
97147 callbackUrl,
98148 token,
149+
150+ mapType,
151+ padding,
152+ showsCompass,
153+ showsMapTypeControl,
154+ showsZoomControl,
99155 showsUserLocationControl,
156+ showsPointsOfInterest,
157+ showsScale,
100158 tintColor,
159+
101160 ...otherProps
102161 } = this . props
103162
0 commit comments