react-native-maps 1.21.0-alpha.11 → 1.21.0-alpha.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/AirGoogleMaps/AIRGMSMarker.h +1 -1
- package/ios/AirGoogleMaps/AIRGoogleMap.m +10 -6
- package/ios/AirGoogleMaps/AIRGoogleMapMarker.h +2 -0
- package/ios/AirGoogleMaps/AIRGoogleMapMarker.m +344 -243
- package/ios/AirGoogleMaps/AIRGoogleMapPolygon.h +2 -1
- package/ios/AirGoogleMaps/AIRGoogleMapPolygon.m +27 -0
- package/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.m +2 -0
- package/ios/AirGoogleMaps/RNMapsGoogleMapView.mm +30 -19
- package/ios/AirMaps/AIRMap.h +1 -0
- package/ios/AirMaps/AIRMap.m +8 -0
- package/ios/AirMaps/AIRMapManager.m +3 -0
- package/ios/AirMaps/RNMapsMapView.mm +351 -338
- package/lib/MapView.js +9 -4
- package/package.json +1 -1
- package/react-native-maps.podspec +1 -1
|
@@ -33,12 +33,21 @@ using namespace facebook::react;
|
|
|
33
33
|
return _view;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
- (void) prepareForRecycle
|
|
37
|
+
{
|
|
38
|
+
[super prepareForRecycle];
|
|
39
|
+
[_view removeFromSuperview];
|
|
40
|
+
_view = nil;
|
|
41
|
+
_legacyMapManager = nil;
|
|
42
|
+
self.contentView = nil;
|
|
43
|
+
}
|
|
44
|
+
|
|
36
45
|
#pragma mark - JS Commands
|
|
37
46
|
- (void)animateToRegion:(NSString *)regionJSON duration:(NSInteger)duration{
|
|
38
47
|
NSDictionary* regionDic = [RCTConvert dictonaryFromString:regionJSON];
|
|
39
|
-
[
|
|
40
|
-
|
|
41
|
-
|
|
48
|
+
MKCoordinateRegion region = [RCTConvert MKCoordinateRegion:regionDic];
|
|
49
|
+
_view.ignoreRegionChanges = YES;
|
|
50
|
+
[_view setRegion:region animated:YES];
|
|
42
51
|
}
|
|
43
52
|
- (void)setCamera:(NSString *)cameraJSON{
|
|
44
53
|
NSDictionary* cameraDic = [RCTConvert dictonaryFromString:cameraJSON];
|
|
@@ -49,16 +58,9 @@ using namespace facebook::react;
|
|
|
49
58
|
- (void)animateCamera:(NSString *)cameraJSON duration:(NSInteger)duration{
|
|
50
59
|
NSDictionary* cameraDic = [RCTConvert dictonaryFromString:cameraJSON];
|
|
51
60
|
MKMapCamera *camera = [RCTConvert MKMapCameraWithDefaults:cameraDic existingCamera:[_view camera]];
|
|
52
|
-
|
|
53
61
|
// don't emit region change events when we are setting the camera
|
|
54
|
-
BOOL originalIgnore = _view.ignoreRegionChanges;
|
|
55
62
|
_view.ignoreRegionChanges = YES;
|
|
56
|
-
[
|
|
57
|
-
[self->_view setCamera:camera animated:YES];
|
|
58
|
-
} completion:^(BOOL finished){
|
|
59
|
-
self->_view.ignoreRegionChanges = originalIgnore;
|
|
60
|
-
}];
|
|
61
|
-
|
|
63
|
+
[_view setCamera:camera animated:YES];
|
|
62
64
|
}
|
|
63
65
|
|
|
64
66
|
- (void)fitToElements:(NSString *)edgePaddingJSON animated:(BOOL)animated {
|
|
@@ -73,7 +75,6 @@ using namespace facebook::react;
|
|
|
73
75
|
}];
|
|
74
76
|
NSArray *filteredMarkers = [_view.annotations filteredArrayUsingPredicate:filterMarkers];
|
|
75
77
|
[_view showAnnotations:filteredMarkers animated:animated];
|
|
76
|
-
|
|
77
78
|
}
|
|
78
79
|
- (void)fitToCoordinates:(NSString *)coordinatesJSON edgePaddingJSON:(NSString *)edgePaddingJSON animated:(BOOL)animated {
|
|
79
80
|
NSArray* coordinatesArr = [RCTConvert arrayFromString:coordinatesJSON];
|
|
@@ -81,12 +82,12 @@ using namespace facebook::react;
|
|
|
81
82
|
for (id json : coordinatesArr){
|
|
82
83
|
[mutableArray addObject:[RCTConvert AIRMapCoordinate:json]];
|
|
83
84
|
}
|
|
84
|
-
|
|
85
|
+
|
|
85
86
|
NSDictionary* edgePadding = [RCTConvert dictonaryFromString:edgePaddingJSON];
|
|
86
|
-
|
|
87
|
+
|
|
87
88
|
UIEdgeInsets edgeInsets = [RCTConvert UIEdgeInsets:edgePadding];
|
|
88
89
|
[_view fitToCoordinates:mutableArray edgePadding:edgeInsets animated:animated];
|
|
89
|
-
|
|
90
|
+
|
|
90
91
|
}
|
|
91
92
|
|
|
92
93
|
#pragma mark - Native commands
|
|
@@ -99,264 +100,270 @@ using namespace facebook::react;
|
|
|
99
100
|
|
|
100
101
|
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
101
102
|
{
|
|
102
|
-
|
|
103
|
+
return concreteComponentDescriptorProvider<RNMapsMapViewComponentDescriptor>();
|
|
103
104
|
}
|
|
104
105
|
|
|
105
|
-
|
|
106
|
-
- (instancetype)initWithFrame:(CGRect)frame
|
|
106
|
+
- (void) prepareMapView
|
|
107
107
|
{
|
|
108
|
-
|
|
108
|
+
if (_legacyMapManager && _view) return;
|
|
109
109
|
static const auto defaultProps = std::make_shared<const RNMapsMapViewProps>();
|
|
110
110
|
_props = defaultProps;
|
|
111
|
-
|
|
111
|
+
_legacyMapManager = [[AIRMapManager alloc] init];
|
|
112
112
|
_view = (AIRMap *)[_legacyMapManager view];
|
|
113
|
-
|
|
113
|
+
|
|
114
114
|
self.contentView = _view;
|
|
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
|
-
|
|
115
|
+
|
|
116
|
+
_view.onPress = [self](NSDictionary* dictionary) {
|
|
117
|
+
if (_eventEmitter) {
|
|
118
|
+
// Extract values from the NSDictionary
|
|
119
|
+
NSDictionary* coordinateDict = dictionary[@"coordinate"];
|
|
120
|
+
NSDictionary* positionDict = dictionary[@"position"];
|
|
121
|
+
|
|
122
|
+
// Populate the OnMapPressCoordinate struct
|
|
123
|
+
facebook::react::RNMapsMapViewEventEmitter::OnPressCoordinate coordinate = {
|
|
124
|
+
.latitude = [coordinateDict[@"latitude"] doubleValue],
|
|
125
|
+
.longitude = [coordinateDict[@"longitude"] doubleValue],
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// Populate the OnMapPressPosition struct
|
|
129
|
+
facebook::react::RNMapsMapViewEventEmitter::OnPressPosition position = {
|
|
130
|
+
.x = [positionDict[@"x"] doubleValue],
|
|
131
|
+
.y = [positionDict[@"y"] doubleValue],
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
|
|
135
|
+
facebook::react::RNMapsMapViewEventEmitter::OnPress data = {
|
|
136
|
+
.action = std::string([@"press" UTF8String]),
|
|
137
|
+
.position = position,
|
|
138
|
+
.coordinate = coordinate
|
|
139
|
+
};
|
|
140
|
+
mapViewEventEmitter->onPress(data);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
_view.onMapReady = [self](NSDictionary* dictionary) {
|
|
146
|
+
if (_eventEmitter) {
|
|
147
|
+
|
|
148
|
+
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
|
|
149
|
+
facebook::react::RNMapsMapViewEventEmitter::OnMapReady data = {};
|
|
150
|
+
mapViewEventEmitter->onMapReady(data);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
_view.onChange = [self](NSDictionary* dictionary) {
|
|
154
|
+
if (_eventEmitter) {
|
|
155
|
+
|
|
156
|
+
NSDictionary* regionDict = dictionary[@"region"];
|
|
157
|
+
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
|
|
158
|
+
facebook::react::RNMapsMapViewEventEmitter::OnRegionChange data = {
|
|
159
|
+
.region.latitude = [regionDict[@"latitude"] doubleValue],
|
|
160
|
+
.region.longitude = [regionDict[@"longitude"] doubleValue],
|
|
161
|
+
.region.latitudeDelta = [regionDict[@"latitudeDelta"] doubleValue],
|
|
162
|
+
.region.longitudeDelta = [regionDict[@"longitudeDelta"] doubleValue],
|
|
163
|
+
.continuous = [dictionary[@"continuous"] boolValue],
|
|
164
|
+
};
|
|
165
|
+
mapViewEventEmitter->onRegionChange(data);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
_view.onDoublePress = [self](NSDictionary* dictionary) {
|
|
169
|
+
if (_eventEmitter) {
|
|
170
|
+
|
|
171
|
+
NSDictionary* coordinateDict = dictionary[@"coordinate"];
|
|
172
|
+
NSDictionary* positionDict = dictionary[@"position"];
|
|
173
|
+
|
|
174
|
+
// Populate the OnMapPressCoordinate struct
|
|
175
|
+
facebook::react::RNMapsMapViewEventEmitter::OnDoublePressCoordinate coordinate = {
|
|
176
|
+
.latitude = [coordinateDict[@"latitude"] doubleValue],
|
|
177
|
+
.longitude = [coordinateDict[@"longitude"] doubleValue],
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
// Populate the OnMapDouplePressPosition struct
|
|
181
|
+
facebook::react::RNMapsMapViewEventEmitter::OnDoublePressPosition position = {
|
|
182
|
+
.x = [positionDict[@"x"] doubleValue],
|
|
183
|
+
.y = [positionDict[@"y"] doubleValue],
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
|
|
188
|
+
facebook::react::RNMapsMapViewEventEmitter::OnDoublePress data = {
|
|
189
|
+
.position = position,
|
|
190
|
+
.coordinate = coordinate
|
|
191
|
+
};
|
|
192
|
+
mapViewEventEmitter->onDoublePress(data);
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
_view.onPanDrag = [self](NSDictionary* dictionary) {
|
|
197
|
+
if (_eventEmitter) {
|
|
198
|
+
|
|
199
|
+
NSDictionary* coordinateDict = dictionary[@"coordinate"];
|
|
200
|
+
NSDictionary* positionDict = dictionary[@"position"];
|
|
201
|
+
|
|
202
|
+
// Populate the OnMapPressCoordinate struct
|
|
203
|
+
facebook::react::RNMapsMapViewEventEmitter::OnPanDragCoordinate coordinate = {
|
|
204
|
+
.latitude = [coordinateDict[@"latitude"] doubleValue],
|
|
205
|
+
.longitude = [coordinateDict[@"longitude"] doubleValue],
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
// Populate the OnMapDouplePressPosition struct
|
|
209
|
+
facebook::react::RNMapsMapViewEventEmitter::OnPanDragPosition position = {
|
|
210
|
+
.x = [positionDict[@"x"] doubleValue],
|
|
211
|
+
.y = [positionDict[@"y"] doubleValue],
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
|
|
215
|
+
facebook::react::RNMapsMapViewEventEmitter::OnPanDrag data = {
|
|
216
|
+
.position = position,
|
|
217
|
+
.coordinate = coordinate,
|
|
218
|
+
};
|
|
219
|
+
mapViewEventEmitter->onPanDrag(data);
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
_view.onUserLocationChange = [self](NSDictionary* dictionary) {
|
|
224
|
+
if (_eventEmitter) {
|
|
225
|
+
|
|
226
|
+
NSDictionary* coordinateDict = dictionary[@"coordinate"];
|
|
227
|
+
NSDictionary* errorDict = dictionary[@"error"];
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
// Populate the OnMapPressCoordinate struct
|
|
231
|
+
facebook::react::RNMapsMapViewEventEmitter::OnUserLocationChangeCoordinate coordinate = {
|
|
232
|
+
.latitude = [coordinateDict[@"latitude"] doubleValue],
|
|
233
|
+
.longitude = [coordinateDict[@"longitude"] doubleValue],
|
|
234
|
+
};
|
|
235
|
+
NSString* str = @"";
|
|
236
|
+
if (errorDict){
|
|
237
|
+
str = errorDict[@"message"];
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
facebook::react::RNMapsMapViewEventEmitter::OnUserLocationChangeError error = {
|
|
241
|
+
.message = std::string([str UTF8String]),
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
|
|
246
|
+
facebook::react::RNMapsMapViewEventEmitter::OnUserLocationChange data = {
|
|
247
|
+
.coordinate = coordinate,
|
|
248
|
+
.error = error,
|
|
249
|
+
};
|
|
250
|
+
mapViewEventEmitter->onUserLocationChange(data);
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
_view.onCalloutPress = [self](NSDictionary* dictionary) {
|
|
255
|
+
if (_eventEmitter) {
|
|
256
|
+
|
|
257
|
+
NSDictionary* coordinateDict = dictionary[@"coordinate"];
|
|
258
|
+
NSDictionary* positionDict = dictionary[@"position"];
|
|
259
|
+
|
|
260
|
+
// Populate the OnCalloutPressPoint struct
|
|
261
|
+
facebook::react::RNMapsMapViewEventEmitter::OnCalloutPressPoint point = {
|
|
262
|
+
.x = [coordinateDict[@"x"] doubleValue],
|
|
263
|
+
.y = [coordinateDict[@"y"] doubleValue],
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
facebook::react::RNMapsMapViewEventEmitter::OnCalloutPressFrame frame = {
|
|
268
|
+
.x = [positionDict[@"x"] doubleValue],
|
|
269
|
+
.y = [positionDict[@"y"] doubleValue],
|
|
270
|
+
.width = [positionDict[@"width"] doubleValue],
|
|
271
|
+
.height = [positionDict[@"height"] doubleValue],
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
|
|
275
|
+
facebook::react::RNMapsMapViewEventEmitter::OnCalloutPress data = {
|
|
276
|
+
.action = std::string([dictionary[@"action"] UTF8String]),
|
|
277
|
+
.id = std::string([dictionary[@"id"] UTF8String]),
|
|
278
|
+
.point = point,
|
|
279
|
+
.frame = frame,
|
|
280
|
+
};
|
|
281
|
+
mapViewEventEmitter->onCalloutPress(data);
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
_view.onRegionChangeStart = [self](NSDictionary* dictionary) {
|
|
287
|
+
if (_eventEmitter) {
|
|
288
|
+
|
|
289
|
+
NSDictionary* regionDict = dictionary[@"region"];
|
|
290
|
+
auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
|
|
291
|
+
facebook::react::RNMapsMapViewEventEmitter::OnRegionChangeStart data = {
|
|
292
|
+
.region.latitude = [regionDict[@"latitude"] doubleValue],
|
|
293
|
+
.region.longitude = [regionDict[@"longitude"] doubleValue],
|
|
294
|
+
.region.latitudeDelta = [regionDict[@"latitudeDelta"] doubleValue],
|
|
295
|
+
.region.longitudeDelta = [regionDict[@"longitudeDelta"] doubleValue],
|
|
296
|
+
.continuous = [dictionary[@"continuous"] boolValue],
|
|
297
|
+
};
|
|
298
|
+
mapViewEventEmitter->onRegionChangeStart(data);
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
|
|
298
303
|
#define HANDLE_MARKER_DRAG_EVENT(eventName, emitterFunction) \
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
304
|
+
if (_eventEmitter) { \
|
|
305
|
+
NSDictionary* coordinateDict = dictionary[@"coordinate"]; \
|
|
306
|
+
auto mapViewEventEmitter = \
|
|
307
|
+
std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter); \
|
|
308
|
+
facebook::react::RNMapsMapViewEventEmitter::eventName data = { \
|
|
309
|
+
.coordinate.latitude = [coordinateDict[@"latitude"] doubleValue], \
|
|
310
|
+
.coordinate.longitude = [coordinateDict[@"longitude"] doubleValue], \
|
|
311
|
+
.id = std::string([[dictionary valueForKey:@"id"] UTF8String]), \
|
|
312
|
+
}; \
|
|
313
|
+
mapViewEventEmitter->emitterFunction(data); \
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
|
|
313
318
|
#define HANDLE_MARKER_EVENT(eventName, emitterFunction, actionName) \
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
319
|
+
if (_eventEmitter) { \
|
|
320
|
+
NSDictionary* coordinateDict = dictionary[@"coordinate"]; \
|
|
321
|
+
facebook::react::RNMapsMapViewEventEmitter::eventName##Coordinate coordinate = { \
|
|
322
|
+
.latitude = [coordinateDict[@"latitude"] doubleValue], \
|
|
323
|
+
.longitude = [coordinateDict[@"longitude"] doubleValue], \
|
|
324
|
+
}; \
|
|
325
|
+
\
|
|
326
|
+
auto mapViewEventEmitter = \
|
|
327
|
+
std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter); \
|
|
328
|
+
facebook::react::RNMapsMapViewEventEmitter::eventName data = { \
|
|
329
|
+
.action = std::string([@actionName UTF8String]), \
|
|
330
|
+
.id = std::string([[dictionary valueForKey:@"id"] UTF8String]), \
|
|
331
|
+
.coordinate = coordinate \
|
|
332
|
+
}; \
|
|
333
|
+
mapViewEventEmitter->emitterFunction(data); \
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
_view.onMarkerDrag = [self](NSDictionary* dictionary) {
|
|
337
|
+
HANDLE_MARKER_DRAG_EVENT(OnMarkerDrag, onMarkerDrag);
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
_view.onMarkerDragStart = [self](NSDictionary* dictionary) {
|
|
341
|
+
HANDLE_MARKER_DRAG_EVENT(OnMarkerDragStart, onMarkerDragStart);
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
_view.onMarkerDragEnd = [self](NSDictionary* dictionary) {
|
|
345
|
+
HANDLE_MARKER_DRAG_EVENT(OnMarkerDragEnd, onMarkerDragEnd);
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
_view.onMarkerSelect = [self](NSDictionary* dictionary) {
|
|
349
|
+
HANDLE_MARKER_EVENT(OnMarkerSelect, onMarkerSelect, "marker-select");
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
_view.onMarkerDeselect = [self](NSDictionary* dictionary) {
|
|
353
|
+
HANDLE_MARKER_EVENT(OnMarkerDeselect, onMarkerDeselect, "marker-deselect");
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
_view.onMarkerPress = [self](NSDictionary* dictionary) {
|
|
357
|
+
HANDLE_MARKER_EVENT(OnMarkerPress, onMarkerPress, "marker-press");
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
361
|
+
{
|
|
362
|
+
if (self = [super initWithFrame:frame]) {
|
|
363
|
+
[self prepareMapView];
|
|
329
364
|
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
HANDLE_MARKER_DRAG_EVENT(OnMarkerDrag, onMarkerDrag);
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
_view.onMarkerDragStart = [self](NSDictionary* dictionary) {
|
|
336
|
-
HANDLE_MARKER_DRAG_EVENT(OnMarkerDragStart, onMarkerDragStart);
|
|
337
|
-
};
|
|
338
|
-
|
|
339
|
-
_view.onMarkerDragEnd = [self](NSDictionary* dictionary) {
|
|
340
|
-
HANDLE_MARKER_DRAG_EVENT(OnMarkerDragEnd, onMarkerDragEnd);
|
|
341
|
-
};
|
|
342
|
-
|
|
343
|
-
_view.onMarkerSelect = [self](NSDictionary* dictionary) {
|
|
344
|
-
HANDLE_MARKER_EVENT(OnMarkerSelect, onMarkerSelect, "marker-select");
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
_view.onMarkerDeselect = [self](NSDictionary* dictionary) {
|
|
348
|
-
HANDLE_MARKER_EVENT(OnMarkerDeselect, onMarkerDeselect, "marker-deselect");
|
|
349
|
-
};
|
|
350
|
-
|
|
351
|
-
_view.onMarkerPress = [self](NSDictionary* dictionary) {
|
|
352
|
-
HANDLE_MARKER_EVENT(OnMarkerPress, onMarkerPress, "marker-press");
|
|
353
|
-
};
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
return self;
|
|
365
|
+
|
|
366
|
+
return self;
|
|
360
367
|
}
|
|
361
368
|
|
|
362
369
|
|
|
@@ -393,106 +400,112 @@ MKMapType mapRNTypeToMKMapType(RNMapsMapViewMapType rnMapType) {
|
|
|
393
400
|
|
|
394
401
|
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
|
395
402
|
{
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
403
|
+
[self prepareMapView];
|
|
404
|
+
const auto &oldViewProps = *std::static_pointer_cast<RNMapsMapViewProps const>(_props);
|
|
405
|
+
const auto &newViewProps = *std::static_pointer_cast<RNMapsMapViewProps const>(props);
|
|
406
|
+
|
|
399
407
|
#define REMAP_MAPVIEW_PROP(name) \
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
408
|
+
if (oldViewProps.name != newViewProps.name) { \
|
|
409
|
+
_view.name = newViewProps.name; \
|
|
410
|
+
}
|
|
411
|
+
|
|
404
412
|
#define REMAP_MAPVIEW_STRING_PROP(name) \
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
413
|
+
if (oldViewProps.name != newViewProps.name) { \
|
|
414
|
+
_view.name = RCTNSStringFromString(newViewProps.name); \
|
|
415
|
+
}
|
|
416
|
+
|
|
409
417
|
#define REMAP_MAPVIEW_COLOR_PROP(name) \
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
418
|
+
if (oldViewProps.name != newViewProps.name) { \
|
|
419
|
+
_view.name = RCTUIColorFromSharedColor(newViewProps.name); \
|
|
420
|
+
}
|
|
421
|
+
|
|
414
422
|
#define REMAP_MAPVIEW_POINT_PROP(name) \
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
423
|
+
if (newViewProps.name.x != oldViewProps.name.x || \
|
|
424
|
+
newViewProps.name.y != oldViewProps.name.y) { \
|
|
425
|
+
_view.name = CGPointMake(newViewProps.name.x, newViewProps.name.y); \
|
|
426
|
+
}
|
|
427
|
+
|
|
420
428
|
#define REMAP_MAPVIEW_REGION_PROP(name) \
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
429
|
+
if (newViewProps.name.latitude != oldViewProps.name.latitude || \
|
|
430
|
+
newViewProps.name.longitude != oldViewProps.name.longitude || \
|
|
431
|
+
newViewProps.name.latitudeDelta != oldViewProps.name.latitudeDelta ||\
|
|
432
|
+
newViewProps.name.longitudeDelta != oldViewProps.name.longitudeDelta) { \
|
|
433
|
+
MKCoordinateSpan span = MKCoordinateSpanMake(newViewProps.name.latitudeDelta, \
|
|
434
|
+
newViewProps.name.longitudeDelta); \
|
|
435
|
+
MKCoordinateRegion region = MKCoordinateRegionMake(CLLocationCoordinate2DMake( \
|
|
436
|
+
newViewProps.name.latitude, newViewProps.name.longitude), span); \
|
|
437
|
+
_view.name = region; \
|
|
438
|
+
[_view didSetRegion]; \
|
|
439
|
+
}
|
|
440
|
+
|
|
432
441
|
#define REMAP_MAPVIEW_CAMERA_PROP(name) \
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
442
|
+
if (newViewProps.name.center.latitude != oldViewProps.name.center.latitude || \
|
|
443
|
+
newViewProps.name.center.longitude != oldViewProps.name.center.longitude || \
|
|
444
|
+
newViewProps.name.heading != oldViewProps.name.heading || \
|
|
445
|
+
newViewProps.name.pitch != oldViewProps.name.pitch) { \
|
|
446
|
+
CLLocationCoordinate2D center = CLLocationCoordinate2DMake( \
|
|
447
|
+
newViewProps.name.center.latitude, \
|
|
448
|
+
newViewProps.name.center.longitude); \
|
|
449
|
+
MKMapCamera* camera = [[MKMapCamera alloc] init]; \
|
|
450
|
+
camera.centerCoordinate = center; \
|
|
451
|
+
camera.heading = newViewProps.name.heading; \
|
|
452
|
+
camera.pitch = newViewProps.name.pitch; \
|
|
453
|
+
_view.name = camera; \
|
|
454
|
+
}
|
|
455
|
+
|
|
447
456
|
#define REMAP_MAPVIEW_EDGEINSETS_PROP(name) \
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
457
|
+
if (newViewProps.name.top != oldViewProps.name.top || \
|
|
458
|
+
newViewProps.name.right != oldViewProps.name.right || \
|
|
459
|
+
newViewProps.name.bottom != oldViewProps.name.bottom || \
|
|
460
|
+
newViewProps.name.left != oldViewProps.name.left) { \
|
|
461
|
+
_view.name = UIEdgeInsetsMake(newViewProps.name.top, \
|
|
462
|
+
newViewProps.name.left, \
|
|
463
|
+
newViewProps.name.bottom, \
|
|
464
|
+
newViewProps.name.right); \
|
|
465
|
+
}
|
|
466
|
+
|
|
458
467
|
#define REMAP_MAPVIEW_MAPTYPE(rnMapType) MKMapType##rnMapType
|
|
459
|
-
|
|
460
|
-
|
|
468
|
+
|
|
469
|
+
|
|
461
470
|
REMAP_MAPVIEW_PROP(cacheEnabled)
|
|
462
|
-
|
|
471
|
+
|
|
463
472
|
REMAP_MAPVIEW_PROP(followsUserLocation)
|
|
464
473
|
REMAP_MAPVIEW_PROP(loadingEnabled)
|
|
465
474
|
REMAP_MAPVIEW_PROP(scrollEnabled)
|
|
466
|
-
|
|
475
|
+
|
|
467
476
|
REMAP_MAPVIEW_PROP(maxDelta)
|
|
468
477
|
REMAP_MAPVIEW_PROP(maxZoom)
|
|
469
478
|
REMAP_MAPVIEW_PROP(minDelta)
|
|
470
479
|
REMAP_MAPVIEW_PROP(minZoom)
|
|
471
|
-
|
|
480
|
+
|
|
472
481
|
REMAP_MAPVIEW_PROP(showsCompass)
|
|
473
482
|
REMAP_MAPVIEW_PROP(showsScale)
|
|
474
483
|
REMAP_MAPVIEW_PROP(showsTraffic)
|
|
475
484
|
REMAP_MAPVIEW_PROP(showsUserLocation)
|
|
476
485
|
REMAP_MAPVIEW_PROP(userLocationCalloutEnabled)
|
|
477
486
|
REMAP_MAPVIEW_PROP(zoomEnabled)
|
|
478
|
-
|
|
487
|
+
|
|
479
488
|
REMAP_MAPVIEW_POINT_PROP(compassOffset)
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
489
|
+
|
|
490
|
+
if (![_view ignoreRegionChanges]){
|
|
491
|
+
_view.ignoreRegionChanges = YES;
|
|
492
|
+
REMAP_MAPVIEW_REGION_PROP(initialRegion)
|
|
493
|
+
REMAP_MAPVIEW_REGION_PROP(region)
|
|
494
|
+
_view.ignoreRegionChanges = NO;
|
|
495
|
+
}
|
|
496
|
+
|
|
484
497
|
REMAP_MAPVIEW_CAMERA_PROP(initialCamera)
|
|
485
498
|
REMAP_MAPVIEW_CAMERA_PROP(camera)
|
|
486
|
-
|
|
499
|
+
|
|
487
500
|
REMAP_MAPVIEW_EDGEINSETS_PROP(legalLabelInsets)
|
|
488
501
|
REMAP_MAPVIEW_EDGEINSETS_PROP(mapPadding)
|
|
489
|
-
|
|
502
|
+
|
|
490
503
|
REMAP_MAPVIEW_COLOR_PROP(loadingIndicatorColor)
|
|
491
504
|
REMAP_MAPVIEW_COLOR_PROP(loadingIndicatorColor)
|
|
492
505
|
REMAP_MAPVIEW_COLOR_PROP(tintColor)
|
|
493
|
-
|
|
506
|
+
|
|
494
507
|
REMAP_MAPVIEW_STRING_PROP(userLocationAnnotationTitle)
|
|
495
|
-
|
|
508
|
+
|
|
496
509
|
if (oldViewProps.mapType != newViewProps.mapType){
|
|
497
510
|
_view.mapType = mapRNTypeToMKMapType(newViewProps.mapType);
|
|
498
511
|
}
|
|
@@ -509,22 +522,22 @@ MKMapType mapRNTypeToMKMapType(RNMapsMapViewMapType rnMapType) {
|
|
|
509
522
|
break;
|
|
510
523
|
}
|
|
511
524
|
}
|
|
512
|
-
|
|
525
|
+
|
|
513
526
|
if (oldViewProps.cameraZoomRange.minCenterCoordinateDistance != newViewProps.cameraZoomRange.minCenterCoordinateDistance ||
|
|
514
527
|
oldViewProps.cameraZoomRange.maxCenterCoordinateDistance != newViewProps.cameraZoomRange.maxCenterCoordinateDistance ||
|
|
515
528
|
oldViewProps.cameraZoomRange.animated != newViewProps.cameraZoomRange.animated) {
|
|
516
|
-
|
|
529
|
+
|
|
517
530
|
MKMapCameraZoomRange* zoomRange = [[MKMapCameraZoomRange alloc] initWithMinCenterCoordinateDistance:newViewProps.cameraZoomRange.minCenterCoordinateDistance maxCenterCoordinateDistance:newViewProps.cameraZoomRange.maxCenterCoordinateDistance];
|
|
518
531
|
[_view setCameraZoomRange:zoomRange animated:newViewProps.cameraZoomRange.animated];
|
|
519
532
|
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
[super updateProps:props oldProps:oldProps];
|
|
523
536
|
}
|
|
524
537
|
|
|
525
538
|
@end
|
|
526
539
|
|
|
527
540
|
Class<RCTComponentViewProtocol> RNMapsMapViewCls(void)
|
|
528
541
|
{
|
|
529
|
-
|
|
542
|
+
return RNMapsMapView.class;
|
|
530
543
|
}
|