react-native-maps 1.21.0-alpha.15 → 1.21.0-alpha.17

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.
@@ -517,6 +517,9 @@ using namespace facebook::react;
517
517
  REMAP_MAPVIEW_PROP(zoomTapEnabled)
518
518
 
519
519
  REMAP_MAPVIEW_PROP(scrollEnabled)
520
+ if (_view.scrollEnabled != newViewProps.scrollEnabled){
521
+ [_view setScrollEnabled:newViewProps.scrollEnabled];
522
+ }
520
523
 
521
524
  if (newViewProps.minZoom != oldViewProps.minZoom || newViewProps.maxZoom != oldViewProps.maxZoom){
522
525
  [_view setMinZoom:newViewProps.minZoom maxZoom:newViewProps.maxZoom];
@@ -35,6 +35,7 @@ extern const NSInteger AIRMapMaxZoomLevel;
35
35
  @property (nonatomic, assign) BOOL hasStartedRendering;
36
36
  @property (nonatomic, assign) BOOL cacheEnabled;
37
37
  @property (nonatomic, assign) BOOL loadingEnabled;
38
+ @property (nonatomic, assign) BOOL handlePanDrag;
38
39
  @property (nonatomic, assign) BOOL legacyZoomConstraintsEnabled;
39
40
  @property (nonatomic, strong) UIColor *loadingBackgroundColor;
40
41
  @property (nonatomic, strong) UIColor *loadingIndicatorColor;
@@ -538,13 +538,14 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
538
538
  _userLocationCalloutEnabled = calloutEnabled;
539
539
  }
540
540
 
541
- - (void)setHandlePanDrag:(BOOL)handleMapDrag {
541
+ - (void)setHandlePanDrag:(BOOL)handlePanDrag {
542
542
  for (UIGestureRecognizer *recognizer in [self gestureRecognizers]) {
543
543
  if ([recognizer isKindOfClass:[UIPanGestureRecognizer class]]) {
544
- recognizer.enabled = handleMapDrag;
544
+ recognizer.enabled = handlePanDrag;
545
545
  break;
546
546
  }
547
547
  }
548
+ _handlePanDrag = handlePanDrag;
548
549
  }
549
550
 
550
551
  - (void)setRegion:(MKCoordinateRegion)region animated:(BOOL)animated
@@ -82,12 +82,12 @@ using namespace facebook::react;
82
82
  for (id json : coordinatesArr){
83
83
  [mutableArray addObject:[RCTConvert AIRMapCoordinate:json]];
84
84
  }
85
-
85
+
86
86
  NSDictionary* edgePadding = [RCTConvert dictonaryFromString:edgePaddingJSON];
87
-
87
+
88
88
  UIEdgeInsets edgeInsets = [RCTConvert UIEdgeInsets:edgePadding];
89
89
  [_view fitToCoordinates:mutableArray edgePadding:edgeInsets animated:animated];
90
-
90
+
91
91
  }
92
92
 
93
93
  #pragma mark - Native commands
@@ -110,27 +110,27 @@ using namespace facebook::react;
110
110
  _props = defaultProps;
111
111
  _legacyMapManager = [[AIRMapManager alloc] init];
112
112
  _view = (AIRMap *)[_legacyMapManager view];
113
-
113
+
114
114
  self.contentView = _view;
115
-
115
+
116
116
  _view.onPress = [self](NSDictionary* dictionary) {
117
117
  if (_eventEmitter) {
118
118
  // Extract values from the NSDictionary
119
119
  NSDictionary* coordinateDict = dictionary[@"coordinate"];
120
120
  NSDictionary* positionDict = dictionary[@"position"];
121
-
121
+
122
122
  // Populate the OnMapPressCoordinate struct
123
123
  facebook::react::RNMapsMapViewEventEmitter::OnPressCoordinate coordinate = {
124
124
  .latitude = [coordinateDict[@"latitude"] doubleValue],
125
125
  .longitude = [coordinateDict[@"longitude"] doubleValue],
126
126
  };
127
-
127
+
128
128
  // Populate the OnMapPressPosition struct
129
129
  facebook::react::RNMapsMapViewEventEmitter::OnPressPosition position = {
130
130
  .x = [positionDict[@"x"] doubleValue],
131
131
  .y = [positionDict[@"y"] doubleValue],
132
132
  };
133
-
133
+
134
134
  auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
135
135
  facebook::react::RNMapsMapViewEventEmitter::OnPress data = {
136
136
  .action = std::string([@"press" UTF8String]),
@@ -140,11 +140,11 @@ using namespace facebook::react;
140
140
  mapViewEventEmitter->onPress(data);
141
141
  }
142
142
  };
143
-
144
-
143
+
144
+
145
145
  _view.onMapReady = [self](NSDictionary* dictionary) {
146
146
  if (_eventEmitter) {
147
-
147
+
148
148
  auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
149
149
  facebook::react::RNMapsMapViewEventEmitter::OnMapReady data = {};
150
150
  mapViewEventEmitter->onMapReady(data);
@@ -152,7 +152,7 @@ using namespace facebook::react;
152
152
  };
153
153
  _view.onChange = [self](NSDictionary* dictionary) {
154
154
  if (_eventEmitter) {
155
-
155
+
156
156
  NSDictionary* regionDict = dictionary[@"region"];
157
157
  auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
158
158
  facebook::react::RNMapsMapViewEventEmitter::OnRegionChange data = {
@@ -167,23 +167,23 @@ using namespace facebook::react;
167
167
  };
168
168
  _view.onDoublePress = [self](NSDictionary* dictionary) {
169
169
  if (_eventEmitter) {
170
-
170
+
171
171
  NSDictionary* coordinateDict = dictionary[@"coordinate"];
172
172
  NSDictionary* positionDict = dictionary[@"position"];
173
-
173
+
174
174
  // Populate the OnMapPressCoordinate struct
175
175
  facebook::react::RNMapsMapViewEventEmitter::OnDoublePressCoordinate coordinate = {
176
176
  .latitude = [coordinateDict[@"latitude"] doubleValue],
177
177
  .longitude = [coordinateDict[@"longitude"] doubleValue],
178
178
  };
179
-
179
+
180
180
  // Populate the OnMapDouplePressPosition struct
181
181
  facebook::react::RNMapsMapViewEventEmitter::OnDoublePressPosition position = {
182
182
  .x = [positionDict[@"x"] doubleValue],
183
183
  .y = [positionDict[@"y"] doubleValue],
184
184
  };
185
-
186
-
185
+
186
+
187
187
  auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
188
188
  facebook::react::RNMapsMapViewEventEmitter::OnDoublePress data = {
189
189
  .position = position,
@@ -192,25 +192,25 @@ using namespace facebook::react;
192
192
  mapViewEventEmitter->onDoublePress(data);
193
193
  }
194
194
  };
195
-
195
+
196
196
  _view.onPanDrag = [self](NSDictionary* dictionary) {
197
197
  if (_eventEmitter) {
198
-
198
+
199
199
  NSDictionary* coordinateDict = dictionary[@"coordinate"];
200
200
  NSDictionary* positionDict = dictionary[@"position"];
201
-
201
+
202
202
  // Populate the OnMapPressCoordinate struct
203
203
  facebook::react::RNMapsMapViewEventEmitter::OnPanDragCoordinate coordinate = {
204
204
  .latitude = [coordinateDict[@"latitude"] doubleValue],
205
205
  .longitude = [coordinateDict[@"longitude"] doubleValue],
206
206
  };
207
-
207
+
208
208
  // Populate the OnMapDouplePressPosition struct
209
209
  facebook::react::RNMapsMapViewEventEmitter::OnPanDragPosition position = {
210
210
  .x = [positionDict[@"x"] doubleValue],
211
211
  .y = [positionDict[@"y"] doubleValue],
212
212
  };
213
-
213
+
214
214
  auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
215
215
  facebook::react::RNMapsMapViewEventEmitter::OnPanDrag data = {
216
216
  .position = position,
@@ -219,14 +219,14 @@ using namespace facebook::react;
219
219
  mapViewEventEmitter->onPanDrag(data);
220
220
  }
221
221
  };
222
-
222
+
223
223
  _view.onUserLocationChange = [self](NSDictionary* dictionary) {
224
224
  if (_eventEmitter) {
225
-
225
+
226
226
  NSDictionary* coordinateDict = dictionary[@"coordinate"];
227
227
  NSDictionary* errorDict = dictionary[@"error"];
228
-
229
-
228
+
229
+
230
230
  // Populate the OnMapPressCoordinate struct
231
231
  facebook::react::RNMapsMapViewEventEmitter::OnUserLocationChangeCoordinate coordinate = {
232
232
  .latitude = [coordinateDict[@"latitude"] doubleValue],
@@ -236,12 +236,12 @@ using namespace facebook::react;
236
236
  if (errorDict){
237
237
  str = errorDict[@"message"];
238
238
  }
239
-
239
+
240
240
  facebook::react::RNMapsMapViewEventEmitter::OnUserLocationChangeError error = {
241
241
  .message = std::string([str UTF8String]),
242
242
  };
243
-
244
-
243
+
244
+
245
245
  auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
246
246
  facebook::react::RNMapsMapViewEventEmitter::OnUserLocationChange data = {
247
247
  .coordinate = coordinate,
@@ -250,27 +250,27 @@ using namespace facebook::react;
250
250
  mapViewEventEmitter->onUserLocationChange(data);
251
251
  }
252
252
  };
253
-
253
+
254
254
  _view.onCalloutPress = [self](NSDictionary* dictionary) {
255
255
  if (_eventEmitter) {
256
-
256
+
257
257
  NSDictionary* coordinateDict = dictionary[@"coordinate"];
258
258
  NSDictionary* positionDict = dictionary[@"position"];
259
-
259
+
260
260
  // Populate the OnCalloutPressPoint struct
261
261
  facebook::react::RNMapsMapViewEventEmitter::OnCalloutPressPoint point = {
262
262
  .x = [coordinateDict[@"x"] doubleValue],
263
263
  .y = [coordinateDict[@"y"] doubleValue],
264
264
  };
265
-
266
-
265
+
266
+
267
267
  facebook::react::RNMapsMapViewEventEmitter::OnCalloutPressFrame frame = {
268
268
  .x = [positionDict[@"x"] doubleValue],
269
269
  .y = [positionDict[@"y"] doubleValue],
270
270
  .width = [positionDict[@"width"] doubleValue],
271
271
  .height = [positionDict[@"height"] doubleValue],
272
272
  };
273
-
273
+
274
274
  auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
275
275
  facebook::react::RNMapsMapViewEventEmitter::OnCalloutPress data = {
276
276
  .action = std::string([dictionary[@"action"] UTF8String]),
@@ -281,11 +281,11 @@ using namespace facebook::react;
281
281
  mapViewEventEmitter->onCalloutPress(data);
282
282
  }
283
283
  };
284
-
285
-
284
+
285
+
286
286
  _view.onRegionChangeStart = [self](NSDictionary* dictionary) {
287
287
  if (_eventEmitter) {
288
-
288
+
289
289
  NSDictionary* regionDict = dictionary[@"region"];
290
290
  auto mapViewEventEmitter = std::static_pointer_cast<RNMapsMapViewEventEmitter const>(_eventEmitter);
291
291
  facebook::react::RNMapsMapViewEventEmitter::OnRegionChangeStart data = {
@@ -298,8 +298,8 @@ using namespace facebook::react;
298
298
  mapViewEventEmitter->onRegionChangeStart(data);
299
299
  }
300
300
  };
301
-
302
-
301
+
302
+
303
303
  #define HANDLE_MARKER_DRAG_EVENT(eventName, emitterFunction) \
304
304
  if (_eventEmitter) { \
305
305
  NSDictionary* coordinateDict = dictionary[@"coordinate"]; \
@@ -312,9 +312,9 @@ facebook::react::RNMapsMapViewEventEmitter::eventName data = { \
312
312
  }; \
313
313
  mapViewEventEmitter->emitterFunction(data); \
314
314
  }
315
-
316
-
317
-
315
+
316
+
317
+
318
318
  #define HANDLE_MARKER_EVENT(eventName, emitterFunction, actionName) \
319
319
  if (_eventEmitter) { \
320
320
  NSDictionary* coordinateDict = dictionary[@"coordinate"]; \
@@ -332,27 +332,27 @@ facebook::react::RNMapsMapViewEventEmitter::eventName data = { \
332
332
  }; \
333
333
  mapViewEventEmitter->emitterFunction(data); \
334
334
  }
335
-
335
+
336
336
  _view.onMarkerDrag = [self](NSDictionary* dictionary) {
337
337
  HANDLE_MARKER_DRAG_EVENT(OnMarkerDrag, onMarkerDrag);
338
338
  };
339
-
339
+
340
340
  _view.onMarkerDragStart = [self](NSDictionary* dictionary) {
341
341
  HANDLE_MARKER_DRAG_EVENT(OnMarkerDragStart, onMarkerDragStart);
342
342
  };
343
-
343
+
344
344
  _view.onMarkerDragEnd = [self](NSDictionary* dictionary) {
345
345
  HANDLE_MARKER_DRAG_EVENT(OnMarkerDragEnd, onMarkerDragEnd);
346
346
  };
347
-
347
+
348
348
  _view.onMarkerSelect = [self](NSDictionary* dictionary) {
349
349
  HANDLE_MARKER_EVENT(OnMarkerSelect, onMarkerSelect, "marker-select");
350
350
  };
351
-
351
+
352
352
  _view.onMarkerDeselect = [self](NSDictionary* dictionary) {
353
353
  HANDLE_MARKER_EVENT(OnMarkerDeselect, onMarkerDeselect, "marker-deselect");
354
354
  };
355
-
355
+
356
356
  _view.onMarkerPress = [self](NSDictionary* dictionary) {
357
357
  HANDLE_MARKER_EVENT(OnMarkerPress, onMarkerPress, "marker-press");
358
358
  };
@@ -362,7 +362,7 @@ mapViewEventEmitter->emitterFunction(data); \
362
362
  if (self = [super initWithFrame:frame]) {
363
363
  [self prepareMapView];
364
364
  }
365
-
365
+
366
366
  return self;
367
367
  }
368
368
 
@@ -403,28 +403,28 @@ MKMapType mapRNTypeToMKMapType(RNMapsMapViewMapType rnMapType) {
403
403
  [self prepareMapView];
404
404
  const auto &oldViewProps = *std::static_pointer_cast<RNMapsMapViewProps const>(_props);
405
405
  const auto &newViewProps = *std::static_pointer_cast<RNMapsMapViewProps const>(props);
406
-
406
+
407
407
  #define REMAP_MAPVIEW_PROP(name) \
408
408
  if (oldViewProps.name != newViewProps.name) { \
409
409
  _view.name = newViewProps.name; \
410
410
  }
411
-
411
+
412
412
  #define REMAP_MAPVIEW_STRING_PROP(name) \
413
413
  if (oldViewProps.name != newViewProps.name) { \
414
414
  _view.name = RCTNSStringFromString(newViewProps.name); \
415
415
  }
416
-
416
+
417
417
  #define REMAP_MAPVIEW_COLOR_PROP(name) \
418
418
  if (oldViewProps.name != newViewProps.name) { \
419
419
  _view.name = RCTUIColorFromSharedColor(newViewProps.name); \
420
420
  }
421
-
421
+
422
422
  #define REMAP_MAPVIEW_POINT_PROP(name) \
423
423
  if (newViewProps.name.x != oldViewProps.name.x || \
424
424
  newViewProps.name.y != oldViewProps.name.y) { \
425
425
  _view.name = CGPointMake(newViewProps.name.x, newViewProps.name.y); \
426
426
  }
427
-
427
+
428
428
  #define REMAP_MAPVIEW_REGION_PROP(name) \
429
429
  if (newViewProps.name.latitude != oldViewProps.name.latitude || \
430
430
  newViewProps.name.longitude != oldViewProps.name.longitude || \
@@ -437,7 +437,7 @@ newViewProps.name.latitude, newViewProps.name.longitude), span); \
437
437
  _view.name = region; \
438
438
  [_view didSetRegion]; \
439
439
  }
440
-
440
+
441
441
  #define REMAP_MAPVIEW_CAMERA_PROP(name) \
442
442
  if (newViewProps.name.center.latitude != oldViewProps.name.center.latitude || \
443
443
  newViewProps.name.center.longitude != oldViewProps.name.center.longitude || \
@@ -452,7 +452,7 @@ camera.heading = newViewProps.name.heading; \
452
452
  camera.pitch = newViewProps.name.pitch; \
453
453
  _view.name = camera; \
454
454
  }
455
-
455
+
456
456
  #define REMAP_MAPVIEW_EDGEINSETS_PROP(name) \
457
457
  if (newViewProps.name.top != oldViewProps.name.top || \
458
458
  newViewProps.name.right != oldViewProps.name.right || \
@@ -463,49 +463,56 @@ newViewProps.name.left, \
463
463
  newViewProps.name.bottom, \
464
464
  newViewProps.name.right); \
465
465
  }
466
-
466
+
467
467
  #define REMAP_MAPVIEW_MAPTYPE(rnMapType) MKMapType##rnMapType
468
-
469
-
468
+
469
+
470
470
  REMAP_MAPVIEW_PROP(cacheEnabled)
471
-
471
+
472
472
  REMAP_MAPVIEW_PROP(followsUserLocation)
473
473
  REMAP_MAPVIEW_PROP(loadingEnabled)
474
+ if (_view.scrollEnabled != newViewProps.scrollEnabled){
475
+ [_view setScrollEnabled:newViewProps.scrollEnabled];
476
+ }
477
+ if (_view.handlePanDrag != newViewProps.handlePanDrag){
478
+ [_view setHandlePanDrag:newViewProps.handlePanDrag];
479
+ }
480
+
474
481
  REMAP_MAPVIEW_PROP(scrollEnabled)
475
-
482
+
476
483
  REMAP_MAPVIEW_PROP(maxDelta)
477
484
  REMAP_MAPVIEW_PROP(maxZoom)
478
485
  REMAP_MAPVIEW_PROP(minDelta)
479
486
  REMAP_MAPVIEW_PROP(minZoom)
480
-
487
+
481
488
  REMAP_MAPVIEW_PROP(showsCompass)
482
489
  REMAP_MAPVIEW_PROP(showsScale)
483
490
  REMAP_MAPVIEW_PROP(showsTraffic)
484
491
  REMAP_MAPVIEW_PROP(showsUserLocation)
485
492
  REMAP_MAPVIEW_PROP(userLocationCalloutEnabled)
486
493
  REMAP_MAPVIEW_PROP(zoomEnabled)
487
-
494
+
488
495
  REMAP_MAPVIEW_POINT_PROP(compassOffset)
489
-
496
+
490
497
  if (![_view ignoreRegionChanges]){
491
498
  _view.ignoreRegionChanges = YES;
492
499
  REMAP_MAPVIEW_REGION_PROP(initialRegion)
493
500
  REMAP_MAPVIEW_REGION_PROP(region)
494
501
  _view.ignoreRegionChanges = NO;
495
502
  }
496
-
503
+
497
504
  REMAP_MAPVIEW_CAMERA_PROP(initialCamera)
498
505
  REMAP_MAPVIEW_CAMERA_PROP(camera)
499
-
506
+
500
507
  REMAP_MAPVIEW_EDGEINSETS_PROP(legalLabelInsets)
501
508
  REMAP_MAPVIEW_EDGEINSETS_PROP(mapPadding)
502
-
509
+
503
510
  REMAP_MAPVIEW_COLOR_PROP(loadingIndicatorColor)
504
511
  REMAP_MAPVIEW_COLOR_PROP(loadingIndicatorColor)
505
512
  REMAP_MAPVIEW_COLOR_PROP(tintColor)
506
-
513
+
507
514
  REMAP_MAPVIEW_STRING_PROP(userLocationAnnotationTitle)
508
-
515
+
509
516
  if (oldViewProps.mapType != newViewProps.mapType){
510
517
  _view.mapType = mapRNTypeToMKMapType(newViewProps.mapType);
511
518
  }
@@ -522,16 +529,16 @@ newViewProps.name.right); \
522
529
  break;
523
530
  }
524
531
  }
525
-
532
+
526
533
  if (oldViewProps.cameraZoomRange.minCenterCoordinateDistance != newViewProps.cameraZoomRange.minCenterCoordinateDistance ||
527
534
  oldViewProps.cameraZoomRange.maxCenterCoordinateDistance != newViewProps.cameraZoomRange.maxCenterCoordinateDistance ||
528
535
  oldViewProps.cameraZoomRange.animated != newViewProps.cameraZoomRange.animated) {
529
-
536
+
530
537
  MKMapCameraZoomRange* zoomRange = [[MKMapCameraZoomRange alloc] initWithMinCenterCoordinateDistance:newViewProps.cameraZoomRange.minCenterCoordinateDistance maxCenterCoordinateDistance:newViewProps.cameraZoomRange.maxCenterCoordinateDistance];
531
538
  [_view setCameraZoomRange:zoomRange animated:newViewProps.cameraZoomRange.animated];
532
539
  }
533
-
534
-
540
+
541
+
535
542
  [super updateProps:props oldProps:oldProps];
536
543
  }
537
544
 
package/lib/MapView.js CHANGED
@@ -374,7 +374,12 @@ class MapView extends React.Component {
374
374
  longitudeDelta: this.props.region.longitudeDelta,
375
375
  };
376
376
  }
377
- if (!this.state.isReady) {
377
+ if (this.state.isReady) {
378
+ if (props.onPanDrag) {
379
+ props.handlePanDrag = !!props.onPanDrag;
380
+ }
381
+ }
382
+ else {
378
383
  props.style = this.props.style;
379
384
  props.initialCamera = this.props.initialCamera;
380
385
  props.onLayout = this.props.onLayout;
@@ -412,12 +417,7 @@ class MapView extends React.Component {
412
417
  : undefined,
413
418
  ...this.props,
414
419
  };
415
- if (this.state.isReady) {
416
- if (props.onPanDrag) {
417
- props.handlePanDrag = !!props.onPanDrag;
418
- }
419
- }
420
- else {
420
+ if (!this.state.isReady) {
421
421
  props.style = this.props.style;
422
422
  props.initialCamera = this.props.initialCamera;
423
423
  props.onLayout = this.props.onLayout;
@@ -560,6 +560,7 @@ export interface MapFabricNativeProps extends ViewProps {
560
560
  * @platform Android: Supported
561
561
  */
562
562
  onPanDrag?: PanDragEventHandler;
563
+ handlePanDrag?: boolean;
563
564
  /**
564
565
  * Callback that is called when user click on a POI.
565
566
  *
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "main": "lib/index.js",
6
6
  "author": "Leland Richardson <leland.m.richardson@gmail.com>",
7
7
  "homepage": "https://github.com/react-native-maps/react-native-maps#readme",
8
- "version": "1.21.0-alpha.15",
8
+ "version": "1.21.0-alpha.17",
9
9
  "license": "MIT",
10
10
  "scripts": {
11
11
  "lint": "eslint . --max-warnings 0",