forked from nitaliano/react-native-mapbox-gl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.android.js
More file actions
131 lines (126 loc) · 5.25 KB
/
index.android.js
File metadata and controls
131 lines (126 loc) · 5.25 KB
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
'use strict'
var React = require('react-native');
var { NativeModules, requireNativeComponent } = React;
var MapMixins = {
setDirectionAnimated(mapRef, heading) {
NativeModules.MapboxGLManager.setDirectionAnimated(React.findNodeHandle(this.refs[mapRef]), heading);
},
setZoomLevelAnimated(mapRef, zoomLevel) {
NativeModules.MapboxGLManager.setZoomLevelAnimated(React.findNodeHandle(this.refs[mapRef]), zoomLevel);
},
setCenterCoordinateAnimated(mapRef, latitude, longitude) {
NativeModules.MapboxGLManager.setCenterCoordinateAnimated(React.findNodeHandle(this.refs[mapRef]), latitude, longitude);
},
setCenterCoordinateZoomLevelAnimated(mapRef, latitude, longitude, zoomLevel) {
NativeModules.MapboxGLManager.setCenterCoordinateZoomLevelAnimated(React.findNodeHandle(this.refs[mapRef]), latitude, longitude, zoomLevel);
},
addAnnotations(mapRef, annotations) {
NativeModules.MapboxGLManager.addAnnotations(React.findNodeHandle(this.refs[mapRef]), annotations);
},
selectAnnotationAnimated(mapRef, selectedIdentifier) {
NativeModules.MapboxGLManager.selectAnnotationAnimated(React.findNodeHandle(this.refs[mapRef]), selectedIdentifier);
},
removeAnnotation(mapRef, selectedIdentifier) {
NativeModules.MapboxGLManager.removeAnnotation(React.findNodeHandle(this.refs[mapRef]), selectedIdentifier);
},
removeAllAnnotations(mapRef) {
NativeModules.MapboxGLManager.removeAllAnnotations(React.findNodeHandle(this.refs[mapRef]));
},
setVisibleCoordinateBoundsAnimated(mapRef, latitudeSW, longitudeSW, latitudeNE, longitudeNE, paddingTop, paddingRight, paddingBottom, paddingLeft) {
NativeModules.MapboxGLManager.setVisibleCoordinateBoundsAnimated(React.findNodeHandle(this.refs[mapRef]), latitudeSW, longitudeSW, latitudeNE, longitudeNE, paddingTop, paddingRight, paddingBottom, paddingLeft);
},
setUserTrackingMode(mapRef, userTrackingMode) {
NativeModules.MapboxGLManager.setUserTrackingMode(React.findNodeHandle(this.refs[mapRef]), userTrackingMode);
},
setTilt(mapRef, tilt) {
NativeModules.MapboxGLManager.setTilt(React.findNodeHandle(this.refs[mapRef]), tilt);
},
mapStyles: NativeModules.MapboxGLManager.mapStyles,
userTrackingMode: NativeModules.MapboxGLManager.userTrackingMode
};
var ReactMapView = requireNativeComponent('RCTMapbox', {
name: 'RCTMapbox',
propTypes: {
accessToken: React.PropTypes.string.isRequired,
annotations: React.PropTypes.arrayOf(React.PropTypes.shape({
title: React.PropTypes.string,
subtitle: React.PropTypes.string,
coordinates: React.PropTypes.array.isRequired,
alpha: React.PropTypes.number,
fillColor: React.PropTypes.string,
strokeColor: React.PropTypes.string,
strokeWidth: React.PropTypes.number
})),
centerCoordinate: React.PropTypes.shape({
latitude: React.PropTypes.number.isRequired,
longitude: React.PropTypes.number.isRequired
}),
centerCoordinateZoom: React.PropTypes.shape(),
debugActive: React.PropTypes.bool,
direction: React.PropTypes.number,
rotateEnabled: React.PropTypes.bool,
scrollEnabled: React.PropTypes.bool,
showsUserLocation: React.PropTypes.bool,
styleUrl: React.PropTypes.string,
userTrackingMode: React.PropTypes.number,
zoomEnabled: React.PropTypes.bool,
zoomLevel: React.PropTypes.number,
tilt: React.PropTypes.number,
compassIsHidden: React.PropTypes.bool,
onRegionChange: React.PropTypes.func,
onUserLocationChange: React.PropTypes.func,
// Fix for https://github.com/mapbox/react-native-mapbox-gl/issues/118
scaleY: React.PropTypes.number,
scaleX: React.PropTypes.number,
translateY: React.PropTypes.number,
translateX: React.PropTypes.number,
rotation: React.PropTypes.number,
// Fix for https://github.com/mapbox/react-native-mapbox-gl/issues/175
renderToHardwareTextureAndroid: React.PropTypes.bool,
onLayout: React.PropTypes.bool,
accessibilityLiveRegion: React.PropTypes.string,
accessibilityComponentType: React.PropTypes.string,
accessibilityLabel: React.PropTypes.string,
testID: React.PropTypes.string,
importantForAccessibility: React.PropTypes.string
},
defaultProps() {
return {
centerCoordinate: {
latitude: 0,
longitude: 0
},
debugActive: false,
direction: 0,
rotateEnabled: true,
scrollEnabled: true,
showsUserLocation: false,
styleUrl: NativeModules.MapboxGLManager.mapStyles.streets,
userTrackingMode: NativeModules.MapboxGLManager.userTrackingMode.none,
zoomEnabled: true,
zoomLevel: 0,
tilt: 0,
compassIsHidden: false
};
}
});
var ReactMapViewWrapper = React.createClass({
statics: {
Mixin: MapMixins
},
handleOnChange(event) {
if (this.props.onRegionChange) this.props.onRegionChange(event.nativeEvent.src);
},
handleUserLocation(event) {
if (this.props.onUserLocationChange) this.props.onUserLocationChange(event.nativeEvent.src);
},
render() {
return (
<ReactMapView
{...this.props}
onChange={this.handleOnChange}
onSelect={this.handleUserLocation} />
);
}
});
module.exports = ReactMapViewWrapper;