Skip to content

Commit 99027e7

Browse files
author
Spike Brehm
committed
Make MAP_TYPES constant, don't pass none mapType to iOS
1 parent 1368327 commit 99027e7

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

components/MapView.js

+18-9
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@ import MapCircle from './MapCircle';
1616
import MapCallout from './MapCallout';
1717
import MapUrlTile from './MapUrlTile';
1818

19+
const MAP_TYPES = {
20+
STANDARD: 'standard',
21+
SATELLITE: 'satellite',
22+
HYBRID: 'hybrid',
23+
TERRAIN: 'terrain',
24+
NONE: 'none',
25+
};
26+
27+
const ANDROID_ONLY_MAP_TYPES = [
28+
MAP_TYPES.TERRAIN,
29+
MAP_TYPES.NONE,
30+
];
31+
1932
const viewConfig = {
2033
uiViewClassName: 'AIRMap',
2134
validAttributes: {
@@ -172,13 +185,7 @@ const propTypes = {
172185
* - hybrid: satellite view with roads and points of interest overlayed
173186
* - terrain: (Android only) topographic view
174187
*/
175-
mapType: PropTypes.oneOf([
176-
'standard',
177-
'satellite',
178-
'hybrid',
179-
'terrain',
180-
'none',
181-
]),
188+
mapType: PropTypes.oneOf(Object.values(MAP_TYPES)),
182189

183190
/**
184191
* The region to be displayed by the map.
@@ -452,8 +459,8 @@ class MapView extends React.Component {
452459
onMapReady: this._onMapReady,
453460
onLayout: this._onLayout,
454461
};
455-
if (Platform.OS === 'ios' && props.mapType === 'terrain') {
456-
props.mapType = 'standard';
462+
if (Platform.OS === 'ios' && ANDROID_ONLY_MAP_TYPES.includes(props.mapType)) {
463+
props.mapType = MAP_TYPES.STANDARD;
457464
}
458465
props.handlePanDrag = !!props.onPanDrag;
459466
} else {
@@ -488,6 +495,8 @@ class MapView extends React.Component {
488495
MapView.propTypes = propTypes;
489496
MapView.viewConfig = viewConfig;
490497

498+
MapView.MAP_TYPES = MAP_TYPES;
499+
491500
const AIRMap = requireNativeComponent('AIRMap', MapView, {
492501
nativeOnly: {
493502
onChange: true,

example/examples/CustomTiles.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
Dimensions,
77
} from 'react-native';
88

9-
import MapView from 'react-native-maps';
9+
import MapView, { MAP_TYPES } from 'react-native-maps';
1010

1111
const { width, height } = Dimensions.get('window');
1212

@@ -35,7 +35,7 @@ class CustomTiles extends React.Component {
3535
return (
3636
<View style={styles.container}>
3737
<MapView
38-
mapType="none"
38+
mapType={MAP_TYPES.NONE}
3939
style={styles.map}
4040
initialRegion={region}
4141
>

example/examples/DisplayLatLng.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
TouchableOpacity,
88
} from 'react-native';
99

10-
import MapView from 'react-native-maps';
10+
import MapView, { MAP_TYPES } from 'react-native-maps';
1111

1212
const { width, height } = Dimensions.get('window');
1313

@@ -57,7 +57,7 @@ class DisplayLatLng extends React.Component {
5757
<View style={styles.container}>
5858
<MapView
5959
ref={ref => { this.map = ref; }}
60-
mapType="terrain"
60+
mapType={MAP_TYPES.TERRAIN}
6161
style={styles.map}
6262
region={this.state.region}
6363
onRegionChange={region => this.onRegionChange(region)}

0 commit comments

Comments
 (0)