forked from nitaliano/react-native-mapbox-gl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ios.js
More file actions
162 lines (157 loc) · 6.52 KB
/
index.ios.js
File metadata and controls
162 lines (157 loc) · 6.52 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
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
'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);
},
updateAnnotation(mapRef, annotation) {
NativeModules.MapboxGLManager.updateAnnotation(React.findNodeHandle(this.refs[mapRef]), annotation);
},
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);
},
mapStyles: NativeModules.MapboxGLManager.mapStyles,
userTrackingMode: NativeModules.MapboxGLManager.userTrackingMode
};
var MapView = React.createClass({
statics: {
Mixin: MapMixins
},
_onRegionChange(event: Event) {
if (this.props.onRegionChange) this.props.onRegionChange(event.nativeEvent.src);
},
_onRegionWillChange(event: Event) {
if (this.props.onRegionWillChange) this.props.onRegionWillChange(event.nativeEvent.src);
},
_onOpenAnnotation(event: Event) {
if (this.props.onOpenAnnotation) this.props.onOpenAnnotation(event.nativeEvent.src);
},
_onRightAnnotationTapped(event: Event) {
if (this.props.onRightAnnotationTapped) this.props.onRightAnnotationTapped(event.nativeEvent.src);
},
_onUpdateUserLocation(event: Event) {
if (this.props.onUpdateUserLocation) this.props.onUpdateUserLocation(event.nativeEvent.src);
},
_onLongPress(event: Event) {
if (this.props.onLongPress) this.props.onLongPress(event.nativeEvent.src);
},
_onFinishLoadingMap(event: Event) {
if (this.props.onFinishLoadingMap) this.props.onFinishLoadingMap(event.nativeEvent.src);
},
_onStartLoadingMap(event: Event) {
if (this.props.onStartLoadingMap) this.props.onStartLoadingMap(event.nativeEvent.src);
},
_onLocateUserFailed(event: Event) {
if (this.props.onLocateUserFailed) this.props.onLocateUserFailed(event.nativeEvent.src);
},
propTypes: {
showsUserLocation: React.PropTypes.bool,
rotateEnabled: React.PropTypes.bool,
scrollEnabled: React.PropTypes.bool,
zoomEnabled: React.PropTypes.bool,
accessToken: React.PropTypes.string.isRequired,
zoomLevel: React.PropTypes.number,
direction: React.PropTypes.number,
styleURL: React.PropTypes.string,
clipsToBounds: React.PropTypes.bool,
debugActive: React.PropTypes.bool,
userTrackingMode: React.PropTypes.number,
attributionButton: React.PropTypes.bool,
centerCoordinate: React.PropTypes.shape({
latitude: React.PropTypes.number.isRequired,
longitude: React.PropTypes.number.isRequired
}),
annotations: React.PropTypes.arrayOf(React.PropTypes.shape({
coordinates: React.PropTypes.array.isRequired,
title: React.PropTypes.string,
subtitle: React.PropTypes.string,
fillAlpha: React.PropTypes.number,
fillColor: React.PropTypes.string,
strokeAlpha: React.PropTypes.number,
strokeColor: React.PropTypes.string,
strokeWidth: React.PropTypes.number,
id: React.PropTypes.string,
type: React.PropTypes.string.isRequired,
rightCalloutAccessory: React.PropTypes.object({
height: React.PropTypes.number,
width: React.PropTypes.number,
url: React.PropTypes.string
}),
annotationImage: React.PropTypes.object({
height: React.PropTypes.number,
width: React.PropTypes.number,
url: React.PropTypes.string
})
})),
attributionButtonIsHidden: React.PropTypes.bool,
logoIsHidden: React.PropTypes.bool,
compassIsHidden: React.PropTypes.bool,
onRegionChange: React.PropTypes.func,
onRegionWillChange: React.PropTypes.func,
onOpenAnnotation: React.PropTypes.func,
onUpdateUserLocation: React.PropTypes.func,
onRightAnnotationTapped: React.PropTypes.func,
onFinishLoadingMap: React.PropTypes.func,
onStartLoadingMap: React.PropTypes.func,
onLocateUserFailed: React.PropTypes.func
},
getDefaultProps() {
return {
centerCoordinate: {
latitude: 0,
longitude: 0
},
debugActive: false,
direction: 0,
rotateEnabled: true,
scrollEnabled: true,
showsUserLocation: false,
styleUrl: this.Mixin.mapStyles.streets,
zoomEnabled: true,
zoomLevel: 0,
attributionButtonIsHidden: false,
logoIsHidden: false,
compassIsHidden: false
};
},
render() {
return <MapboxGLView
{...this.props}
onRegionChange={this._onRegionChange}
onRegionWillChange={this._onRegionWillChange}
onOpenAnnotation={this._onOpenAnnotation}
onRightAnnotationTapped={this._onRightAnnotationTapped}
onUpdateUserLocation={this._onUpdateUserLocation}
onLongPress={this._onLongPress}
onFinishLoadingMap={this._onFinishLoadingMap}
onStartLoadingMap={this._onStartLoadingMap}
onLocateUserFailed={this._onLocateUserFailed} />;
}
});
var MapboxGLView = requireNativeComponent('RCTMapboxGL', MapView);
module.exports = MapView;