-
Notifications
You must be signed in to change notification settings - Fork 4.9k
/
MapView.js
861 lines (750 loc) · 23 KB
/
MapView.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
import PropTypes from 'prop-types';
import React from 'react';
import {
EdgeInsetsPropType,
Platform,
Animated as RNAnimated,
requireNativeComponent,
NativeModules,
ColorPropType,
findNodeHandle,
ViewPropTypes,
View,
} from 'react-native';
import MapMarker from './MapMarker';
import MapPolyline from './MapPolyline';
import MapPolygon from './MapPolygon';
import MapCircle from './MapCircle';
import MapCallout from './MapCallout';
import MapOverlay from './MapOverlay';
import MapUrlTile from './MapUrlTile';
import MapLocalTile from './MapLocalTile';
import AnimatedRegion from './AnimatedRegion';
import {
contextTypes as childContextTypes,
getAirMapName,
googleMapIsInstalled,
createNotSupportedComponent,
} from './decorateMapComponent';
import * as ProviderConstants from './ProviderConstants';
export const MAP_TYPES = {
STANDARD: 'standard',
SATELLITE: 'satellite',
HYBRID: 'hybrid',
TERRAIN: 'terrain',
NONE: 'none',
MUTEDSTANDARD: 'mutedStandard',
};
const GOOGLE_MAPS_ONLY_TYPES = [
MAP_TYPES.TERRAIN,
MAP_TYPES.NONE,
];
const viewConfig = {
uiViewClassName: 'AIR<provider>Map',
validAttributes: {
region: true,
},
};
// if ViewPropTypes is not defined fall back to View.propType (to support RN < 0.44)
const viewPropTypes = ViewPropTypes || View.propTypes;
const propTypes = {
...viewPropTypes,
/**
* When provider is "google", we will use GoogleMaps.
* Any value other than "google" will default to using
* MapKit in iOS or GoogleMaps in android as the map provider.
*/
provider: PropTypes.oneOf([
'google',
]),
/**
* Used to style and layout the `MapView`. See `StyleSheet.js` and
* `ViewStylePropTypes.js` for more info.
*/
style: viewPropTypes.style,
/**
* A json object that describes the style of the map. This is transformed to a string
* and saved in mayStyleString to be sent to android and ios
* https://developers.google.com/maps/documentation/ios-sdk/styling#use_a_string_resource
* https://developers.google.com/maps/documentation/android-api/styling
*/
customMapStyle: PropTypes.array,
/**
* A json string that describes the style of the map
* https://developers.google.com/maps/documentation/ios-sdk/styling#use_a_string_resource
* https://developers.google.com/maps/documentation/android-api/styling
*/
customMapStyleString: PropTypes.string,
/**
* If `true` the app will ask for the user's location.
* Default value is `false`.
*
* **NOTE**: You need to add NSLocationWhenInUseUsageDescription key in
* Info.plist to enable geolocation, otherwise it is going
* to *fail silently*! You will also need to add an explanation for why
* you need the users location against `NSLocationWhenInUseUsageDescription` in Info.plist.
* Otherwise Apple may reject your app submission.
*/
showsUserLocation: PropTypes.bool,
/**
* The title of the annotation for current user location. This only works if
* `showsUserLocation` is true.
* There is a default value `My Location` set by MapView.
*
* @platform ios
*/
userLocationAnnotationTitle: PropTypes.string,
/**
* If `false` hide the button to move map to the current user's location.
* Default value is `true`.
*
* @platform android
*/
showsMyLocationButton: PropTypes.bool,
/**
* If `true` the map will focus on the user's location. This only works if
* `showsUserLocation` is true and the user has shared their location.
* Default value is `false`.
*
* @platform ios
*/
followsUserLocation: PropTypes.bool,
/**
* If `false` points of interest won't be displayed on the map.
* Default value is `true`.
*
*/
showsPointsOfInterest: PropTypes.bool,
/**
* If `false` compass won't be displayed on the map.
* Default value is `true`.
*
* @platform ios
*/
showsCompass: PropTypes.bool,
/**
* If `false` the user won't be able to pinch/zoom the map.
* Default value is `true`.
*
*/
zoomEnabled: PropTypes.bool,
/**
*If `false` the user won't be able to zoom the map
* Default value is `true`.
*
*@platform android
*/
zoomControlEnabled: PropTypes.bool,
/**
* If `false` the user won't be able to pinch/rotate the map.
* Default value is `true`.
*
*/
rotateEnabled: PropTypes.bool,
/**
* If `true` the map will be cached to an Image for performance
* Default value is `false`.
*
*/
cacheEnabled: PropTypes.bool,
/**
* If `true` the map will be showing a loading indicator
* Default value is `false`.
*
*/
loadingEnabled: PropTypes.bool,
/**
* Loading background color while generating map cache image or loading the map
* Default color is light gray.
*
*/
loadingBackgroundColor: ColorPropType,
/**
* Loading indicator color while generating map cache image or loading the map
* Default color is gray color for iOS, theme color for Android.
*
*/
loadingIndicatorColor: ColorPropType,
/**
* If `false` the user won't be able to change the map region being displayed.
* Default value is `true`.
*
*/
scrollEnabled: PropTypes.bool,
/**
* If `false` the user won't be able to adjust the camera’s pitch angle.
* Default value is `true`.
*
*/
pitchEnabled: PropTypes.bool,
/**
* If `false` will hide 'Navigate' and 'Open in Maps' buttons on marker press
* Default value is `true`.
*
* @platform android
*/
toolbarEnabled: PropTypes.bool,
/**
* A Boolean indicating whether on marker press the map will move to the pressed marker
* Default value is `true`
*
* @platform android
*/
moveOnMarkerPress: PropTypes.bool,
/**
* A Boolean indicating whether the map shows scale information.
* Default value is `false`
*
*/
showsScale: PropTypes.bool,
/**
* A Boolean indicating whether the map displays extruded building information.
* Default value is `true`.
*/
showsBuildings: PropTypes.bool,
/**
* A Boolean value indicating whether the map displays traffic information.
* Default value is `false`.
*/
showsTraffic: PropTypes.bool,
/**
* A Boolean indicating whether indoor maps should be enabled.
* Default value is `false`
*
* @platform android
*/
showsIndoors: PropTypes.bool,
/**
* A Boolean indicating whether indoor level picker should be enabled.
* Default value is `false`
*
* @platform android
*/
showsIndoorLevelPicker: PropTypes.bool,
/**
* The map type to be displayed.
*
* - standard: standard road map (default)
* - satellite: satellite view
* - hybrid: satellite view with roads and points of interest overlayed
* - terrain: topographic view
* - none: no base map
*/
mapType: PropTypes.oneOf(Object.values(MAP_TYPES)),
/**
* The region to be displayed by the map.
*
* The region is defined by the center coordinates and the span of
* coordinates to display.
*/
region: PropTypes.shape({
/**
* Coordinates for the center of the map.
*/
latitude: PropTypes.number.isRequired,
longitude: PropTypes.number.isRequired,
/**
* Difference between the minimun and the maximum latitude/longitude
* to be displayed.
*/
latitudeDelta: PropTypes.number.isRequired,
longitudeDelta: PropTypes.number.isRequired,
}),
/**
* The initial region to be displayed by the map. Use this prop instead of `region`
* only if you don't want to control the viewport of the map besides the initial region.
*
* Changing this prop after the component has mounted will not result in a region change.
*
* This is similar to the `initialValue` prop of a text input.
*/
initialRegion: PropTypes.shape({
/**
* Coordinates for the center of the map.
*/
latitude: PropTypes.number.isRequired,
longitude: PropTypes.number.isRequired,
/**
* Difference between the minimun and the maximum latitude/longitude
* to be displayed.
*/
latitudeDelta: PropTypes.number.isRequired,
longitudeDelta: PropTypes.number.isRequired,
}),
/**
* A Boolean indicating whether to use liteMode for android
* Default value is `false`
*
* @platform android
*/
liteMode: PropTypes.bool,
/**
* (Google Maps only)
*
* Padding that is used by the Google Map View to position
* the camera, legal labels and buttons
*
*/
mapPadding: EdgeInsetsPropType,
/**
* (Google Maps only, iOS)
*
* Whether the safe area padding is added to the Google Map View padding.
* This affects where markers, compass, Google logo etc. are placed on the view.
*
*/
paddingAdjustmentBehavior: PropTypes.oneOf(['always', 'automatic', 'never']),
/**
* Maximum size of area that can be displayed.
*
* @platform ios
*/
maxDelta: PropTypes.number,
/**
* Minimum size of area that can be displayed.
*
* @platform ios
*/
minDelta: PropTypes.number,
/**
* Insets for the map's legal label, originally at bottom left of the map.
* See `EdgeInsetsPropType.js` for more information.
*/
legalLabelInsets: EdgeInsetsPropType,
/**
* Callback that is called once the map is fully loaded.
*/
onMapReady: PropTypes.func,
/**
* Callback that is called once the kml is fully loaded.
*/
onKmlReady: PropTypes.func,
/**
* Callback that is called continuously when the user is dragging the map.
*/
onRegionChange: PropTypes.func,
/**
* Callback that is called once, when the user is done moving the map.
*/
onRegionChangeComplete: PropTypes.func,
/**
* Callback that is called when user taps on the map.
*/
onPress: PropTypes.func,
/**
* Callback that is called when user makes a "long press" somewhere on the map.
*/
onLongPress: PropTypes.func,
/**
* Callback that is called when the underlying map figures our users current location.
*/
onUserLocationChange: PropTypes.func,
/**
* Callback that is called when user makes a "drag" somewhere on the map
*/
onPanDrag: PropTypes.func,
/**
* Callback that is called when user click on a POI
*/
onPoiClick: PropTypes.func,
/**
* Callback that is called when a marker on the map is tapped by the user.
*/
onMarkerPress: PropTypes.func,
/**
* Callback that is called when a marker on the map becomes selected. This will be called when
* the callout for that marker is about to be shown.
*
* @platform ios
*/
onMarkerSelect: PropTypes.func,
/**
* Callback that is called when a marker on the map becomes deselected. This will be called when
* the callout for that marker is about to be hidden.
*
* @platform ios
*/
onMarkerDeselect: PropTypes.func,
/**
* Callback that is called when a callout is tapped by the user.
*/
onCalloutPress: PropTypes.func,
/**
* Callback that is called when the user initiates a drag on a marker (if it is draggable)
*/
onMarkerDragStart: PropTypes.func,
/**
* Callback called continuously as a marker is dragged
*/
onMarkerDrag: PropTypes.func,
/**
* Callback that is called when a drag on a marker finishes. This is usually the point you
* will want to setState on the marker's coordinate again
*/
onMarkerDragEnd: PropTypes.func,
/**
* Minimum zoom value for the map, must be between 0 and 20
*/
minZoomLevel: PropTypes.number,
/**
* Maximum zoom value for the map, must be between 0 and 20
*/
maxZoomLevel: PropTypes.number,
/**
* Url KML Source
*/
kmlSrc: PropTypes.string,
/**
* Callback that is called when a level is activated on a indoor building.
*/
onIndoorLevelActivated: PropTypes.func,
/**
* Callback that is called when a Building is focused.
*/
onIndoorBuildingFocused: PropTypes.func,
};
class MapView extends React.Component {
constructor(props) {
super(props);
this.state = {
isReady: Platform.OS === 'ios',
};
this._onMapReady = this._onMapReady.bind(this);
this._onMarkerPress = this._onMarkerPress.bind(this);
this._onChange = this._onChange.bind(this);
this._onLayout = this._onLayout.bind(this);
}
getChildContext() {
return { provider: this.props.provider };
}
componentWillUpdate(nextProps) {
const a = this.__lastRegion;
const b = nextProps.region;
if (!a || !b) return;
if (
a.latitude !== b.latitude ||
a.longitude !== b.longitude ||
a.latitudeDelta !== b.latitudeDelta ||
a.longitudeDelta !== b.longitudeDelta
) {
this.map.setNativeProps({ region: b });
}
}
componentDidMount() {
const { isReady } = this.state;
if (isReady) {
this._updateStyle();
}
}
_updateStyle() {
const { customMapStyle } = this.props;
this.map.setNativeProps({ customMapStyleString: JSON.stringify(customMapStyle) });
}
_onMapReady() {
const { region, initialRegion, onMapReady } = this.props;
if (region) {
this.map.setNativeProps({ region });
} else if (initialRegion) {
this.map.setNativeProps({ initialRegion });
}
this._updateStyle();
this.setState({ isReady: true }, () => {
if (onMapReady) onMapReady();
});
}
_onLayout(e) {
const { layout } = e.nativeEvent;
if (!layout.width || !layout.height) return;
if (this.state.isReady && !this.__layoutCalled) {
const { region, initialRegion } = this.props;
if (region) {
this.__layoutCalled = true;
this.map.setNativeProps({ region });
} else if (initialRegion) {
this.__layoutCalled = true;
this.map.setNativeProps({ initialRegion });
}
}
if (this.props.onLayout) {
this.props.onLayout(e);
}
}
_onMarkerPress(event) {
if (this.props.onMarkerPress) {
this.props.onMarkerPress(event.nativeEvent);
}
}
_onChange(event) {
this.__lastRegion = event.nativeEvent.region;
if (event.nativeEvent.continuous) {
if (this.props.onRegionChange) {
this.props.onRegionChange(event.nativeEvent.region);
}
} else if (this.props.onRegionChangeComplete) {
this.props.onRegionChangeComplete(event.nativeEvent.region);
}
}
animateToNavigation(location, bearing, angle, duration) {
this._runCommand('animateToNavigation', [location, bearing, angle, duration || 500]);
}
animateToRegion(region, duration) {
this._runCommand('animateToRegion', [region, duration || 500]);
}
animateToCoordinate(latLng, duration) {
this._runCommand('animateToCoordinate', [latLng, duration || 500]);
}
animateToBearing(bearing, duration) {
this._runCommand('animateToBearing', [bearing, duration || 500]);
}
animateToViewingAngle(angle, duration) {
this._runCommand('animateToViewingAngle', [angle, duration || 500]);
}
fitToElements(animated) {
this._runCommand('fitToElements', [animated]);
}
fitToSuppliedMarkers(markers, options = {}) {
const {
edgePadding = { top: 0, right: 0, bottom: 0, left: 0 },
animated = true,
} = options;
this._runCommand('fitToSuppliedMarkers', [markers, edgePadding, animated]);
}
fitToCoordinates(coordinates = [], options = {}) {
const {
edgePadding = { top: 0, right: 0, bottom: 0, left: 0 },
animated = true,
} = options;
this._runCommand('fitToCoordinates', [coordinates, edgePadding, animated]);
}
setMapBoundaries(northEast, southWest) {
this._runCommand('setMapBoundaries', [northEast, southWest]);
}
setIndoorActiveLevelIndex(activeLevelIndex) {
this._runCommand('setIndoorActiveLevelIndex', [activeLevelIndex]);
}
/**
* Takes a snapshot of the map and saves it to a picture
* file or returns the image as a base64 encoded string.
*
* @param config Configuration options
* @param [config.width] Width of the rendered map-view (when omitted actual view width is used).
* @param [config.height] Height of the rendered map-view (when omitted actual height is used).
* @param [config.region] Region to render (Only supported on iOS).
* @param [config.format] Encoding format ('png', 'jpg') (default: 'png').
* @param [config.quality] Compression quality (only used for jpg) (default: 1.0).
* @param [config.result] Result format ('file', 'base64') (default: 'file').
*
* @return Promise Promise with either the file-uri or base64 encoded string
*/
takeSnapshot(args) {
// For the time being we support the legacy API on iOS.
// This will be removed in a future release and only the
// new Promise style API shall be supported.
if (Platform.OS === 'ios' && (arguments.length === 4)) {
console.warn('Old takeSnapshot API has been deprecated; will be removed in the near future'); //eslint-disable-line
const width = arguments[0]; // eslint-disable-line
const height = arguments[1]; // eslint-disable-line
const region = arguments[2]; // eslint-disable-line
const callback = arguments[3]; // eslint-disable-line
this._runCommand('takeSnapshot', [
width || 0,
height || 0,
region || {},
'png',
1,
'legacy',
callback,
]);
return undefined;
}
// Sanitize inputs
const config = {
width: args.width || 0,
height: args.height || 0,
region: args.region || {},
format: args.format || 'png',
quality: args.quality || 1.0,
result: args.result || 'file',
};
if ((config.format !== 'png') &&
(config.format !== 'jpg')) throw new Error('Invalid format specified');
if ((config.result !== 'file') &&
(config.result !== 'base64')) throw new Error('Invalid result specified');
// Call native function
if (Platform.OS === 'android') {
return NativeModules.AirMapModule.takeSnapshot(this._getHandle(), config);
} else if (Platform.OS === 'ios') {
return new Promise((resolve, reject) => {
this._runCommand('takeSnapshot', [
config.width,
config.height,
config.region,
config.format,
config.quality,
config.result,
(err, snapshot) => {
if (err) {
reject(err);
} else {
resolve(snapshot);
}
},
]);
});
}
return Promise.reject('takeSnapshot not supported on this platform');
}
/**
* Convert a map coordinate to user-space point
*
* @param coordinate Coordinate
* @param [coordinate.latitude] Latitude
* @param [coordinate.longitude] Longitude
*
* @return Promise Promise with the point ({ x: Number, y: Number })
*/
pointForCoordinate(coordinate) {
if (Platform.OS === 'android') {
return NativeModules.AirMapModule.pointForCoordinate(this._getHandle(), coordinate);
} else if (Platform.OS === 'ios') {
return this._runCommand('pointForCoordinate', [coordinate]);
}
return Promise.reject('pointForCoordinate not supported on this platform');
}
/**
* Convert a user-space point to a map coordinate
*
* @param point Point
* @param [point.x] X
* @param [point.x] Y
*
* @return Promise Promise with the coordinate ({ latitude: Number, longitude: Number })
*/
coordinateForPoint(point) {
if (Platform.OS === 'android') {
return NativeModules.AirMapModule.coordinateForPoint(this._getHandle(), point);
} else if (Platform.OS === 'ios') {
return this._runCommand('coordinateForPoint', [point]);
}
return Promise.reject('coordinateForPoint not supported on this platform');
}
_uiManagerCommand(name) {
return NativeModules.UIManager[getAirMapName(this.props.provider)].Commands[name];
}
_mapManagerCommand(name) {
return NativeModules[`${getAirMapName(this.props.provider)}Manager`][name];
}
_getHandle() {
return findNodeHandle(this.map);
}
_runCommand(name, args) {
switch (Platform.OS) {
case 'android':
return NativeModules.UIManager.dispatchViewManagerCommand(
this._getHandle(),
this._uiManagerCommand(name),
args
);
case 'ios':
return this._mapManagerCommand(name)(this._getHandle(), ...args);
default:
return Promise.reject(`Invalid platform was passed: ${Platform.OS}`);
}
}
render() {
let props;
if (this.state.isReady) {
props = {
region: null,
initialRegion: null,
onMarkerPress: this._onMarkerPress,
onChange: this._onChange,
onMapReady: this._onMapReady,
onLayout: this._onLayout,
...this.props,
};
if (Platform.OS === 'ios' && props.provider === ProviderConstants.PROVIDER_DEFAULT
&& GOOGLE_MAPS_ONLY_TYPES.includes(props.mapType)) {
props.mapType = MAP_TYPES.standard;
}
props.handlePanDrag = !!props.onPanDrag;
} else {
props = {
style: this.props.style,
region: null,
initialRegion: null,
onMarkerPress: this._onMarkerPress,
onChange: this._onChange,
onMapReady: this._onMapReady,
onLayout: this._onLayout,
};
}
if (Platform.OS === 'android' && this.props.liteMode) {
return (
<AIRMapLite
ref={ref => { this.map = ref; }}
{...props}
/>
);
}
const AIRMap = getAirMapComponent(this.props.provider);
return (
<AIRMap
ref={ref => { this.map = ref; }}
{...props}
/>
);
}
}
MapView.propTypes = propTypes;
MapView.viewConfig = viewConfig;
MapView.childContextTypes = childContextTypes;
MapView.MAP_TYPES = MAP_TYPES;
const nativeComponent = Component => requireNativeComponent(Component, MapView, {
nativeOnly: {
onChange: true,
onMapReady: true,
onKmlReady: true,
handlePanDrag: true,
},
});
const airMaps = {
default: nativeComponent('AIRMap'),
};
if (Platform.OS === 'android') {
airMaps.google = airMaps.default;
} else {
airMaps.google = googleMapIsInstalled ? nativeComponent('AIRGoogleMap') :
createNotSupportedComponent('react-native-maps: AirGoogleMaps dir must be added to your xCode project to support GoogleMaps on iOS.'); // eslint-disable-line max-len
}
const getAirMapComponent = provider => airMaps[provider || 'default'];
const AIRMapLite = NativeModules.UIManager.AIRMapLite &&
requireNativeComponent('AIRMapLite', MapView, {
nativeOnly: {
onChange: true,
onMapReady: true,
handlePanDrag: true,
},
});
export const Animated = RNAnimated.createAnimatedComponent(MapView);
export const ProviderPropType = PropTypes.oneOf(Object.values(ProviderConstants));
/**
* TODO:
* All of these properties on MapView are unecessary since they can be imported
* individually with the es6 exports in index.js. Removing them is a breaking change,
* but potentially allows for better dead code elimination since references are not
* kept to components which are never used.
*/
MapView.Marker = MapMarker;
MapView.Polyline = MapPolyline;
MapView.Polygon = MapPolygon;
MapView.Circle = MapCircle;
MapView.UrlTile = MapUrlTile;
MapView.LocalTile = MapLocalTile;
MapView.Overlay = MapOverlay;
MapView.Callout = MapCallout;
Object.assign(MapView, ProviderConstants);
MapView.ProviderPropType = ProviderPropType;
MapView.Animated = Animated;
MapView.AnimatedRegion = AnimatedRegion;
export default MapView;