react-native-maps 1.21.0-alpha.55 → 1.21.0-alpha.56

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.
@@ -1,6 +1,8 @@
1
1
  package com.rnmaps.fabric;
2
2
 
3
3
 
4
+ import static com.rnmaps.maps.MapManager.MY_LOCATION_PRIORITY;
5
+
4
6
  import android.util.Log;
5
7
  import android.view.View;
6
8
 
@@ -9,9 +11,10 @@ import androidx.annotation.Nullable;
9
11
 
10
12
  import com.facebook.react.bridge.ReactApplicationContext;
11
13
  import com.facebook.react.bridge.ReadableMap;
12
- import com.facebook.react.bridge.UiThreadUtil;
13
14
  import com.facebook.react.module.annotations.ReactModule;
14
15
  import com.facebook.react.uimanager.LayoutShadowNode;
16
+ import com.facebook.react.uimanager.ReactStylesDiffMap;
17
+ import com.facebook.react.uimanager.StateWrapper;
15
18
  import com.facebook.react.uimanager.ThemedReactContext;
16
19
  import com.facebook.react.uimanager.ViewGroupManager;
17
20
  import com.facebook.react.uimanager.ViewManagerDelegate;
@@ -24,26 +27,23 @@ import com.google.android.gms.maps.model.CameraPosition;
24
27
  import com.rnmaps.maps.MapView;
25
28
  import com.rnmaps.maps.SizeReportingShadowNode;
26
29
 
27
- import java.util.List;
28
30
  import java.util.Map;
29
31
 
30
32
  @ReactModule(name = MapViewManager.REACT_CLASS)
31
- public class MapViewManager extends ViewGroupManager<MapViewWrapper> implements RNMapsMapViewManagerInterface<MapViewWrapper> {
33
+ public class MapViewManager extends ViewGroupManager<MapView> implements RNMapsMapViewManagerInterface<MapView> {
32
34
 
33
- private GoogleMapOptions options;
34
- private boolean rendererInitialized = false;
35
- private final RNMapsMapViewManagerDelegate<MapViewWrapper, MapViewManager> delegate =
35
+ private static boolean rendererInitialized = false;
36
+ private final RNMapsMapViewManagerDelegate<MapView, MapViewManager> delegate =
36
37
  new RNMapsMapViewManagerDelegate<>(this);
37
38
 
38
39
 
39
40
  public MapViewManager(ReactApplicationContext context) {
40
41
  super(context);
41
- options = new GoogleMapOptions();
42
42
  }
43
43
 
44
44
 
45
45
  @Override
46
- public ViewManagerDelegate<MapViewWrapper> getDelegate() {
46
+ public ViewManagerDelegate<MapView> getDelegate() {
47
47
  return delegate;
48
48
  }
49
49
 
@@ -53,9 +53,89 @@ public class MapViewManager extends ViewGroupManager<MapViewWrapper> implements
53
53
  }
54
54
 
55
55
  @Override
56
- public MapViewWrapper createViewInstance(ThemedReactContext context) {
57
- Log.e(MapViewManager.class.getName(), "createViewInstance");
58
- return new MapViewWrapper(context);
56
+ public MapView createViewInstance(ThemedReactContext context) {
57
+ return new MapView(context, new GoogleMapOptions());
58
+ }
59
+
60
+ @Override
61
+ protected void setupViewRecycling() {
62
+ // override parent to block recycling / allow reliable GoogleMapsOptions passing
63
+ }
64
+
65
+ @Override
66
+ protected MapView createViewInstance(int reactTag, @NonNull ThemedReactContext reactContext, @Nullable ReactStylesDiffMap initialProps, @Nullable StateWrapper stateWrapper) {
67
+ MapView view = null;
68
+ GoogleMapOptions options = new GoogleMapOptions();
69
+ if (initialProps != null) {
70
+ setGoogleRenderer(null, initialProps.getString("googleRenderer"));
71
+ if (initialProps.hasKey("liteMode")) {
72
+ options.liteMode(initialProps.getBoolean("liteMode", false));
73
+ }
74
+ if (initialProps.hasKey("googleMapId")) {
75
+ String googleMapId = initialProps.getString("googleMapId");
76
+ options.mapId(googleMapId);
77
+ }
78
+ if (initialProps.getMap("initialCamera") != null) {
79
+ ReadableMap initialCamera = initialProps.getMap("initialCamera");
80
+ CameraPosition camera = MapView.cameraPositionFromMap(initialCamera);
81
+ if (camera != null) {
82
+ options.camera(camera);
83
+ }
84
+ }
85
+ if (initialProps.hasKey("mapType")) {
86
+ if (initialProps.getString("mapType") != null) {
87
+ options.mapType(mapTypeFromStrValue(initialProps.getString("mapType")));
88
+ }
89
+ }
90
+ if (initialProps.hasKey("minZoom")) {
91
+ if (initialProps.getInt("minZoom", 0) != 0) {
92
+ options.minZoomPreference(initialProps.getInt("minZoom", 0));
93
+ }
94
+ }
95
+ if (initialProps.hasKey("maxZoom")) {
96
+ if (initialProps.getInt("maxZoom", 0) != 0) {
97
+ options.maxZoomPreference(initialProps.getInt("maxZoom", 0));
98
+ }
99
+ }
100
+ if (initialProps.hasKey("pitchEnabled")) {
101
+ options.tiltGesturesEnabled(initialProps.getBoolean("pitchEnabled", true));
102
+ }
103
+ if (initialProps.hasKey("rotateEnabled")) {
104
+ options.rotateGesturesEnabled(initialProps.getBoolean("rotateEnabled", true));
105
+ }
106
+ if (initialProps.hasKey("scrollDuringRotateOrZoomEnabled")) {
107
+ options.scrollGesturesEnabledDuringRotateOrZoom(initialProps.getBoolean("scrollDuringRotateOrZoomEnabled", true));
108
+ }
109
+ if (initialProps.hasKey("scrollEnabled")) {
110
+ options.scrollGesturesEnabled(initialProps.getBoolean("scrollEnabled", true));
111
+ }
112
+ if (initialProps.hasKey("showsCompass")) {
113
+ options.compassEnabled(initialProps.getBoolean("showsCompass", true));
114
+ }
115
+ if (initialProps.hasKey("toolbarEnabled")) {
116
+ options.mapToolbarEnabled(initialProps.getBoolean("toolbarEnabled", true));
117
+ }
118
+ if (initialProps.hasKey("zoomControlEnabled")) {
119
+ options.zoomControlsEnabled(initialProps.getBoolean("zoomControlEnabled", true));
120
+ }
121
+ if (initialProps.hasKey("zoomEnabled")) {
122
+ options.zoomGesturesEnabled(initialProps.getBoolean("zoomEnabled", true));
123
+ }
124
+ }
125
+
126
+ view = new MapView(reactContext, options);
127
+ view.setId(reactTag);
128
+ this.addEventEmitters(reactContext, view);
129
+ if (initialProps != null) {
130
+ this.updateProperties(view, initialProps);
131
+ }
132
+ if (stateWrapper != null) {
133
+ Object extraData = this.updateState(view, initialProps, stateWrapper);
134
+ if (extraData != null) {
135
+ this.updateExtraData(view, extraData);
136
+ }
137
+ }
138
+ return view;
59
139
  }
60
140
 
61
141
 
@@ -82,76 +162,70 @@ public class MapViewManager extends ViewGroupManager<MapViewWrapper> implements
82
162
  }
83
163
 
84
164
  @Override
85
- public void setCacheEnabled(MapViewWrapper view, boolean value) {
165
+ public void setCacheEnabled(MapView view, boolean value) {
86
166
  view.setCacheEnabled(value);
87
167
  }
88
168
 
89
169
  @Override
90
- public void setCamera(MapViewWrapper view, @Nullable ReadableMap value) {
170
+ public void setCamera(MapView view, @Nullable ReadableMap value) {
91
171
  view.setCamera(value);
92
172
  }
93
173
 
94
174
  @Override
95
- public void setCompassOffset(MapViewWrapper view, @Nullable ReadableMap value) {
175
+ public void setCompassOffset(MapView view, @Nullable ReadableMap value) {
96
176
  // not supported
97
177
  }
98
178
 
99
179
  @Override
100
- public void setFollowsUserLocation(MapViewWrapper view, boolean value) {
180
+ public void setFollowsUserLocation(MapView view, boolean value) {
101
181
  // not supported
102
182
  }
103
183
 
104
184
  @Override
105
- public void setPoiClickEnabled(MapViewWrapper view, boolean value) {
185
+ public void setPoiClickEnabled(MapView view, boolean value) {
106
186
  view.setPoiClickEnabled(value);
107
187
  }
108
188
 
109
189
  @Override
110
- public void setInitialCamera(MapViewWrapper view, @Nullable ReadableMap value) {
190
+ public void setInitialCamera(MapView view, @Nullable ReadableMap value) {
111
191
  CameraPosition camera = MapView.cameraPositionFromMap(value);
112
- if (camera != null){
113
- options.camera(camera);
192
+ if (camera != null) {
114
193
  view.setInitialCameraSet(true);
115
194
  }
116
195
  }
117
196
 
118
- @Override
119
- protected MapViewWrapper recycleView(@NonNull ThemedReactContext var1, @NonNull MapViewWrapper wrapper){
120
- wrapper.prepareToRecycleView();
121
- return wrapper;
122
- }
123
-
124
197
 
125
198
  @Override
126
- public void setInitialRegion(MapViewWrapper view, @Nullable ReadableMap value) {
199
+ public void setInitialRegion(MapView view, @Nullable ReadableMap value) {
127
200
  view.setInitialRegion(value);
128
201
  }
129
202
 
130
203
  @Override
131
- public void setKmlSrc(MapViewWrapper view, @Nullable String value) {
204
+ public void setKmlSrc(MapView view, @Nullable String value) {
132
205
  view.setKmlSrc(value);
133
206
  }
134
207
 
135
208
  @Override
136
- public void setLegalLabelInsets(MapViewWrapper view, @Nullable ReadableMap value) {
209
+ public void setLegalLabelInsets(MapView view, @Nullable ReadableMap value) {
137
210
  // not supported
138
211
  }
139
212
 
140
213
  @Override
141
- public void setLiteMode(MapViewWrapper view, boolean value) {
142
- options.liteMode(value);
214
+ public void setLiteMode(MapView view, boolean value) {
215
+
143
216
  }
144
217
 
145
218
  @Override
146
- public void setGoogleMapId(MapViewWrapper view, @Nullable String value) {
147
- options.mapId(value);
219
+ public void setGoogleMapId(MapView view, @Nullable String value) {
220
+ // do nothing (initialProp)
221
+
148
222
  }
149
223
 
150
224
  @Override
151
- public void setGoogleRenderer(MapViewWrapper view, @Nullable String value) {
225
+ public void setGoogleRenderer(MapView view, @Nullable String value) {
152
226
  if (!rendererInitialized) {
153
- MapsInitializer.Renderer renderer = MapsInitializer.Renderer.LATEST;
154
- if ("LEGACY".equals(value)){
227
+ MapsInitializer.Renderer renderer = MapsInitializer.Renderer.LATEST;
228
+ if ("LEGACY".equals(value)) {
155
229
  renderer = MapsInitializer.Renderer.LEGACY;
156
230
  }
157
231
  MapsInitializer.initialize(getReactApplicationContext(), renderer, r -> Log.d("AirMapRenderer", "Init with renderer: " + r));
@@ -161,43 +235,61 @@ public class MapViewManager extends ViewGroupManager<MapViewWrapper> implements
161
235
  }
162
236
 
163
237
  @Override
164
- public void setLoadingBackgroundColor(MapViewWrapper view, @Nullable Integer value) {
238
+ public void setLoadingBackgroundColor(MapView view, @Nullable Integer value) {
165
239
  view.setLoadingBackgroundColor(value);
166
240
  }
167
241
 
168
242
  @Override
169
- public void setLoadingEnabled(MapViewWrapper view, boolean value) {
243
+ public void setLoadingEnabled(MapView view, boolean value) {
170
244
  view.setLoadingEnabled(value);
171
245
  }
172
246
 
173
247
  @Override
174
- public void setLoadingIndicatorColor(MapViewWrapper view, @Nullable Integer value) {
248
+ public void setLoadingIndicatorColor(MapView view, @Nullable Integer value) {
175
249
  view.setLoadingIndicatorColor(value);
176
250
  }
177
251
 
178
252
  @Override
179
- public void setMapPadding(MapViewWrapper view, @Nullable ReadableMap padding) {
180
- view.setMapPadding(padding);
181
- }
253
+ public void setMapPadding(MapView view, @Nullable ReadableMap padding) {
254
+ int left = 0;
255
+ int top = 0;
256
+ int right = 0;
257
+ int bottom = 0;
258
+ double density = (double) view.getResources().getDisplayMetrics().density;
182
259
 
183
- @Override
184
- public void addView(MapViewWrapper parent, View child, int index) {
185
- parent.getMapView().addFeature(child, index);
186
- Log.e("MapViewManager", "addView " + child.getId() + " at index: " + index);
260
+ if (padding != null) {
261
+ if (padding.hasKey("left")) {
262
+ left = (int) (padding.getDouble("left") * density);
263
+ }
187
264
 
188
- }
189
- @Override
190
- public void addViews(MapViewWrapper parent, List<View> views){
191
- for (View view : views){
192
- parent.getMapView().addView(view);
193
- Log.e("MapViewManager", "addViews " + view.getId());
265
+ if (padding.hasKey("top")) {
266
+ top = (int) (padding.getDouble("top") * density);
267
+ }
268
+
269
+ if (padding.hasKey("right")) {
270
+ right = (int) (padding.getDouble("right") * density);
271
+ }
272
+
273
+ if (padding.hasKey("bottom")) {
274
+ bottom = (int) (padding.getDouble("bottom") * density);
275
+ }
194
276
  }
195
277
 
278
+ view.applyBaseMapPadding(left, top, right, bottom);
279
+ view.map.setPadding(left, top, right, bottom);
196
280
  }
197
281
 
282
+ @Override
283
+ public void addView(MapView parent, View child, int index) {
284
+ parent.addFeature(child, index);
285
+ }
198
286
 
199
287
  @Override
200
- public void setMapType(MapViewWrapper view, @Nullable String value) {
288
+ public void setMapType(MapView view, @Nullable String value) {
289
+ view.setMapType(mapTypeFromStrValue(value));
290
+ }
291
+
292
+ private static int mapTypeFromStrValue(String value) {
201
293
  int mapType;
202
294
  //hybrid | none | satellite | standard | terrain
203
295
  if ("hybrid".equals(value)) {
@@ -211,267 +303,199 @@ public class MapViewManager extends ViewGroupManager<MapViewWrapper> implements
211
303
  } else if ("terrain".equals(value)) {
212
304
  mapType = GoogleMap.MAP_TYPE_TERRAIN;
213
305
  } else {
214
- mapType = GoogleMap.MAP_TYPE_NORMAL;
215
- }
216
- options.mapType(mapType);
217
- if (view.getMapView() != null){
218
- view.getMapView().setMapType(mapType);
306
+ mapType = GoogleMap.MAP_TYPE_NORMAL;
219
307
  }
308
+ return mapType;
220
309
  }
221
310
 
222
311
  @Override
223
- public void setMaxDelta(MapViewWrapper view, double value) {
312
+ public void setMaxDelta(MapView view, double value) {
224
313
  // not supported
225
314
  }
226
315
 
227
316
  @Override
228
- public void setMaxZoom(MapViewWrapper view, float value) {
229
- options.maxZoomPreference(value);
230
- if (view.getMapView() != null) {
231
- view.getMapView().setMaxZoomLevel(value);
232
- }
317
+ public void setMaxZoom(MapView view, float value) {
318
+ view.setMaxZoomLevel(value);
233
319
  }
234
320
 
235
321
  @Override
236
- public void setMinDelta(MapViewWrapper view, double value) {
322
+ public void setMinDelta(MapView view, double value) {
237
323
  // not supported
238
324
  }
239
325
 
240
326
  @Override
241
- public void setMinZoom(MapViewWrapper view, float value) {
242
- options.minZoomPreference(value);
243
- if (view.getMapView() != null) {
244
- view.getMapView().setMinZoomLevel(value);
245
- }
327
+ public void setMinZoom(MapView view, float value) {
328
+ view.setMinZoomLevel(value);
246
329
  }
247
330
 
248
331
  @Override
249
- public void setMoveOnMarkerPress(MapViewWrapper view, boolean value) {
250
- view.setMoveOnMarkerPress(value);
332
+ public void setMoveOnMarkerPress(MapView view, boolean value) {
333
+ view.setMoveOnMarkerPress(value);
251
334
  }
252
335
 
253
336
  @Override
254
- public void setHandlePanDrag(MapViewWrapper view, boolean value) {
337
+ public void setHandlePanDrag(MapView view, boolean value) {
255
338
  view.setHandlePanDrag(value);
256
339
  }
257
340
 
258
341
  @Override
259
- public void setPaddingAdjustmentBehavior(MapViewWrapper view, @Nullable String value) {
342
+ public void setPaddingAdjustmentBehavior(MapView view, @Nullable String value) {
260
343
  // not supported
261
344
  }
262
345
 
263
346
  @Override
264
- public void setPitchEnabled(MapViewWrapper view, boolean value) {
265
- options.tiltGesturesEnabled(value);
266
- if (view.getMapView() != null) {
267
- view.getMapView().setPitchEnabled(value);
268
- }
347
+ public void setPitchEnabled(MapView view, boolean value) {
348
+ view.setPitchEnabled(value);
269
349
  }
270
350
 
271
351
  @Override
272
- public void setRegion(MapViewWrapper view, @Nullable ReadableMap value) {
352
+ public void setRegion(MapView view, @Nullable ReadableMap value) {
273
353
  view.setRegion(value);
274
354
  }
275
355
 
276
356
  @Override
277
- public void setRotateEnabled(MapViewWrapper view, boolean value) {
278
- options.rotateGesturesEnabled(value);
279
- if (view.getMapView() != null) {
280
- view.getMapView().setRotateEnabled(value);
281
- }
357
+ public void setRotateEnabled(MapView view, boolean value) {
358
+ view.setRotateEnabled(value);
282
359
  }
283
360
 
284
361
  @Override
285
- public void setScrollDuringRotateOrZoomEnabled(MapViewWrapper view, boolean value) {
286
- options.scrollGesturesEnabledDuringRotateOrZoom(value);
287
- if (view.getMapView() != null) {
288
- view.getMapView().setScrollDuringRotateOrZoomEnabled(value);
289
- }
362
+ public void setScrollDuringRotateOrZoomEnabled(MapView view, boolean value) {
363
+ view.setScrollDuringRotateOrZoomEnabled(value);
290
364
  }
291
365
 
292
366
  @Override
293
- public void setScrollEnabled(MapViewWrapper view, boolean value) {
294
- options.scrollGesturesEnabled(value);
295
- if (view.getMapView() != null) {
296
- view.getMapView().setScrollEnabled(value);
297
- }
367
+ public void setScrollEnabled(MapView view, boolean value) {
368
+ view.setScrollEnabled(value);
298
369
  }
299
370
 
300
371
  @Override
301
- public void setShowsBuildings(MapViewWrapper view, boolean value) {
302
- view.setShowsBuildings(value);
372
+ public void setShowsBuildings(MapView view, boolean value) {
373
+ view.setShowBuildings(value);
303
374
  }
304
375
 
305
376
  @Override
306
- public void setShowsCompass(MapViewWrapper view, boolean value) {
307
- options.compassEnabled(value);
377
+ public void setShowsCompass(MapView view, boolean value) {
308
378
  view.setShowsCompass(value);
309
379
  }
310
380
 
311
381
  @Override
312
- public void setShowsIndoorLevelPicker(MapViewWrapper view, boolean value) {
382
+ public void setShowsIndoorLevelPicker(MapView view, boolean value) {
313
383
  view.setShowsIndoorLevelPicker(value);
314
384
  }
315
385
 
316
386
  @Override
317
- public void setShowsIndoors(MapViewWrapper view, boolean value) {
318
- view.setShowsIndoors(value);
387
+ public void setShowsIndoors(MapView view, boolean value) {
388
+ view.setShowIndoors(value);
319
389
  }
320
390
 
321
391
  @Override
322
- public void setShowsMyLocationButton(MapViewWrapper view, boolean value) {
392
+ public void setShowsMyLocationButton(MapView view, boolean value) {
323
393
  view.setShowsMyLocationButton(value);
324
394
  }
325
395
 
326
396
  @Override
327
- public void setShowsScale(MapViewWrapper view, boolean value) {
397
+ public void setShowsScale(MapView view, boolean value) {
328
398
  // not supported
329
399
  }
330
400
 
331
401
  @Override
332
- public void setShowsUserLocation(MapViewWrapper view, boolean value) {
402
+ public void setShowsUserLocation(MapView view, boolean value) {
333
403
  view.setShowsUserLocation(value);
334
404
  }
335
405
 
336
406
  @Override
337
- public void setTintColor(MapViewWrapper view, @Nullable Integer value) {
407
+ public void setTintColor(MapView view, @Nullable Integer value) {
338
408
  // not supported
339
409
  }
340
410
 
341
411
  @Override
342
- public void setToolbarEnabled(MapViewWrapper view, boolean value) {
343
- options.mapToolbarEnabled(value);
344
- if (view.getMapView() != null) {
345
- view.getMapView().setToolbarEnabled(value);
346
- }
412
+ public void setToolbarEnabled(MapView view, boolean value) {
413
+ view.setToolbarEnabled(value);
347
414
  }
348
415
 
349
416
  @Override
350
- public void setUserInterfaceStyle(MapViewWrapper view, @Nullable String value) {
417
+ public void setUserInterfaceStyle(MapView view, @Nullable String value) {
351
418
  // todo update google maps SDK and add support for MapColorScheme
352
419
  }
353
420
 
354
421
  @Override
355
- public void setUserLocationAnnotationTitle(MapViewWrapper view, @Nullable String value) {
422
+ public void setUserLocationAnnotationTitle(MapView view, @Nullable String value) {
356
423
  // not supported
357
424
  }
358
425
 
359
426
  @Override
360
- public void setUserLocationCalloutEnabled(MapViewWrapper view, boolean value) {
427
+ public void setUserLocationCalloutEnabled(MapView view, boolean value) {
361
428
  // not supported
362
429
  }
363
430
 
364
431
  @Override
365
- public void setUserLocationFastestInterval(MapViewWrapper view, int value) {
432
+ public void setUserLocationFastestInterval(MapView view, int value) {
366
433
  view.setUserLocationFastestInterval(value);
367
434
  }
368
435
 
369
436
  @Override
370
- public void setUserLocationPriority(MapViewWrapper view, @Nullable String value) {
371
- view.setUserLocationPriority(value);
437
+ public void setUserLocationPriority(MapView view, @Nullable String value) {
438
+ view.setUserLocationPriority(MY_LOCATION_PRIORITY.get(value));
372
439
  }
373
440
 
374
441
  @Override
375
- public void setUserLocationUpdateInterval(MapViewWrapper view, int value) {
442
+ public void setUserLocationUpdateInterval(MapView view, int value) {
376
443
  view.setUserLocationUpdateInterval(value);
377
444
  }
378
445
 
379
446
  @Override
380
- public void setZoomControlEnabled(MapViewWrapper view, boolean value) {
381
- options.zoomControlsEnabled(value);
382
- if (view.getMapView() != null) {
383
- view.setZoomControlEnabled(value);
384
- }
447
+ public void setZoomControlEnabled(MapView view, boolean value) {
448
+ view.setZoomControlEnabled(value);
385
449
  }
386
450
 
387
451
  @Override
388
- public void setZoomEnabled(MapViewWrapper view, boolean value) {
389
- options.zoomGesturesEnabled(value);
390
- if (view.getMapView() != null) {
391
- view.setZoomEnabled(value);
392
- }
452
+ public void setZoomEnabled(MapView view, boolean value) {
453
+ view.setZoomEnabled(value);
393
454
  }
394
455
 
395
456
  @Override
396
- public void setZoomTapEnabled(MapViewWrapper view, boolean value) {
457
+ public void setZoomTapEnabled(MapView view, boolean value) {
397
458
  // not supported
398
459
  }
399
460
 
400
461
  @Override
401
- public void setCameraZoomRange(MapViewWrapper view, @Nullable ReadableMap value) {
462
+ public void setCameraZoomRange(MapView view, @Nullable ReadableMap value) {
402
463
  // not supported
403
464
  }
404
465
 
405
466
  @Override
406
- public void animateToRegion(MapViewWrapper view, String regionJSON, int duration) {
407
-
408
- }
409
-
410
- @Override
411
- public void setCamera(MapViewWrapper view, String cameraJSON) {
467
+ public void animateToRegion(MapView view, String regionJSON, int duration) {
412
468
 
413
469
  }
414
470
 
415
471
  @Override
416
- public void animateCamera(MapViewWrapper view, String cameraJSON, int duration) {
472
+ public void setCamera(MapView view, String cameraJSON) {
417
473
 
418
474
  }
419
475
 
420
476
  @Override
421
- public void fitToElements(MapViewWrapper view, String edgePaddingJSON, boolean animated) {
477
+ public void animateCamera(MapView view, String cameraJSON, int duration) {
422
478
 
423
479
  }
424
480
 
425
481
  @Override
426
- public void fitToSuppliedMarkers(MapViewWrapper view, String markersJSON, String edgePaddingJSON, boolean animated) {
482
+ public void fitToElements(MapView view, String edgePaddingJSON, boolean animated) {
427
483
 
428
484
  }
429
485
 
430
486
  @Override
431
- public void fitToCoordinates(MapViewWrapper view, String coordinatesJSON, String edgePaddingJSON, boolean animated) {
432
-
433
- }
434
- @Override
435
- public int getChildCount(MapViewWrapper parent) {
436
- if (parent.getMapView() != null) {
437
- return parent.getMapView().getChildCount();
438
- }
439
- return 0;
440
- }
487
+ public void fitToSuppliedMarkers(MapView view, String markersJSON, String edgePaddingJSON, boolean animated) {
441
488
 
442
- @Override
443
- public View getChildAt(MapViewWrapper parent, int index) {
444
- if (parent.getMapView() != null) {
445
- return parent.getMapView().getChildAt(index);
446
- }
447
- return null;
448
489
  }
449
490
 
450
491
  @Override
451
- public void removeViewAt(MapViewWrapper parent, int index) {
452
- if (parent.getMapView() != null) {
453
- parent.getMapView().removeViewAt(index);
454
- }
455
- }
492
+ public void fitToCoordinates(MapView view, String coordinatesJSON, String edgePaddingJSON, boolean animated) {
456
493
 
457
- public void removeView(MapViewWrapper parent, View view) {
458
- if (parent.getMapView() != null) {
459
- parent.getMapView().removeView(view);
460
- }
461
494
  }
462
495
 
463
-
464
- @Override
465
- protected void onAfterUpdateTransaction(@NonNull MapViewWrapper view) {
466
- super.onAfterUpdateTransaction(view);
467
- setGoogleRenderer(view, null);
468
- view.initializeMapView(options);
469
- options = new GoogleMapOptions();
470
- Log.e("MapViewManager", "onAfterUpdateTransaction tag: " + view.getId());
471
- }
472
496
  @Override
473
- public void onDropViewInstance(MapViewWrapper view) {
497
+ public void onDropViewInstance(MapView view) {
474
498
  super.onDropViewInstance(view);
475
- view.prepareToRecycleView();
499
+ view.onDestroy();
476
500
  }
477
501
  }
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.55",
8
+ "version": "1.21.0-alpha.56",
9
9
  "license": "MIT",
10
10
  "scripts": {
11
11
  "lint": "eslint . --max-warnings 0",
@@ -1,369 +0,0 @@
1
- package com.rnmaps.fabric;
2
-
3
- import static com.rnmaps.maps.MapManager.MY_LOCATION_PRIORITY;
4
-
5
- import android.annotation.SuppressLint;
6
- import android.content.Context;
7
- import android.view.View;
8
- import android.widget.FrameLayout;
9
-
10
- import androidx.annotation.NonNull;
11
- import androidx.annotation.Nullable;
12
-
13
- import com.facebook.react.bridge.ReadableMap;
14
- import com.facebook.react.uimanager.ThemedReactContext;
15
- import com.google.android.gms.maps.GoogleMapOptions;
16
- import com.rnmaps.maps.MapView;
17
-
18
- @SuppressLint("ViewConstructor")
19
- public class MapViewWrapper extends FrameLayout {
20
- private MapView mapView;
21
- private Boolean cacheEnabled;
22
- private Boolean initialCameraSet;
23
-
24
- private Boolean showsBuildings;
25
- private Boolean poiClickEnabled;
26
- private Boolean moveOnMarkerPress;
27
- private Boolean handlePanDrag;
28
- private Boolean showsIndoorLevelPicker;
29
- private Boolean showIndoors;
30
- private Boolean showsMyLocationButton;
31
- private Boolean showsUserLocation;
32
- private Boolean loadingEnabled;
33
-
34
- private ReadableMap camera;
35
-
36
- private ReadableMap initialRegion;
37
-
38
- private String kmlSrc;
39
- private ReadableMap region;
40
- private ReadableMap mapPadding;
41
-
42
- private Integer userLocationPriority;
43
- private Integer userLocationFastestInterval;
44
- private Integer userLocationUpdateInterval;
45
- private Integer loadingIndicatorColor;
46
-
47
-
48
- public MapViewWrapper(@NonNull Context context) {
49
- super(context);
50
- setLayoutParams(new LayoutParams(
51
- LayoutParams.MATCH_PARENT,
52
- LayoutParams.MATCH_PARENT
53
- ));
54
- }
55
-
56
-
57
- public MapView getMapView() {
58
- return mapView;
59
- }
60
- public void initializeMapView(GoogleMapOptions options) {
61
- if (mapView == null) {
62
- mapView = new MapView((ThemedReactContext) getContext(), options);
63
- mapView.setLayoutParams(new LayoutParams(
64
- LayoutParams.MATCH_PARENT,
65
- LayoutParams.MATCH_PARENT
66
- ));
67
- addView(mapView);
68
- if (cacheEnabled != null){
69
- setCacheEnabled(cacheEnabled);
70
- }
71
- if (showsBuildings != null){
72
- setShowsBuildings(showsBuildings);
73
- }
74
- if (poiClickEnabled != null){
75
- setPoiClickEnabled(poiClickEnabled);
76
- }
77
- if (moveOnMarkerPress != null){
78
- setMoveOnMarkerPress(moveOnMarkerPress);
79
- }
80
- if (handlePanDrag != null){
81
- setHandlePanDrag(handlePanDrag);
82
- }
83
- if (showsIndoorLevelPicker != null){
84
- setShowsIndoorLevelPicker(showsIndoorLevelPicker);
85
- }
86
- if (showIndoors != null){
87
- setShowsIndoors(showIndoors);
88
- }
89
-
90
- if (showsMyLocationButton != null){
91
- setShowsMyLocationButton(showsMyLocationButton);
92
- }
93
- if (showsUserLocation != null) {
94
- setShowsUserLocation(showsUserLocation);
95
- }
96
- if (loadingEnabled != null) {
97
- setLoadingEnabled(loadingEnabled);
98
- }
99
- if (camera != null){
100
- setCamera(camera);
101
- }
102
- if (kmlSrc != null){
103
- setKmlSrc(kmlSrc);
104
- }
105
- if (region != null){
106
- setRegion(region);
107
- }
108
- if (mapPadding != null){
109
- setMapPadding(mapPadding);
110
- }
111
- if (userLocationPriority != null) {
112
- mapView.setUserLocationPriority(userLocationPriority);
113
- }
114
- if (userLocationFastestInterval != null) {
115
- setUserLocationFastestInterval(userLocationFastestInterval);
116
- }
117
- if (userLocationUpdateInterval != null) {
118
- setUserLocationUpdateInterval(userLocationUpdateInterval);
119
- }
120
- if (loadingIndicatorColor != null) {
121
- setLoadingIndicatorColor(loadingIndicatorColor);
122
- }
123
- if (initialRegion != null){
124
- mapView.setInitialRegion(initialRegion);
125
- }
126
- if (initialCameraSet != null){
127
- mapView.setInitialCameraSet(initialCameraSet);
128
- }
129
- }
130
- }
131
-
132
- protected void onDetachedFromWindow() {
133
- super.onDetachedFromWindow();
134
- if (mapView != null) {
135
- mapView.onDestroy();
136
- removeView(mapView);
137
- mapView = null;
138
- }
139
- }
140
-
141
- public void setInitialCameraSet(boolean initialCameraSet) {
142
- this.initialCameraSet = initialCameraSet;
143
- }
144
-
145
- public void setInitialRegion(ReadableMap initialRegion) {
146
- this.initialRegion = initialRegion;
147
- if (getMapView() != null){
148
- getMapView().setInitialRegion(initialRegion);
149
- }
150
- }
151
-
152
- public void setCacheEnabled(boolean value) {
153
- if (getMapView() != null) {
154
- getMapView().setCacheEnabled(value);
155
- } else {
156
- cacheEnabled = value;
157
- }
158
- }
159
-
160
-
161
- public void setCamera(@Nullable ReadableMap value) {
162
- if (getMapView() != null) {
163
- getMapView().setCamera(value);
164
- } else {
165
- camera = value;
166
- }
167
- }
168
-
169
-
170
- public void setPoiClickEnabled(boolean value) {
171
- if (getMapView() != null) {
172
- getMapView().setPoiClickEnabled(value);
173
- } else {
174
- poiClickEnabled = value;
175
- }
176
- }
177
-
178
- public void prepareToRecycleView(){
179
- mapView = null;
180
- cacheEnabled = null;
181
- initialCameraSet = null;
182
- showsBuildings = null;
183
- poiClickEnabled = null;
184
- moveOnMarkerPress = null;
185
- handlePanDrag = null;
186
- showsIndoorLevelPicker = null;
187
- showIndoors = null;
188
- showsMyLocationButton = null;
189
- showsUserLocation = null;
190
- loadingEnabled = null;
191
- camera = null;
192
- initialRegion = null;
193
- userLocationPriority = null;
194
- userLocationFastestInterval = null;
195
- userLocationUpdateInterval = null;
196
- loadingIndicatorColor = null;
197
- if (getMapView() != null) {
198
- getMapView().onDestroy();
199
- }
200
- mapView = null;
201
- }
202
-
203
-
204
-
205
- public void setKmlSrc(@Nullable String value) {
206
- if (getMapView() != null) {
207
- getMapView().setKmlSrc(value);
208
- }
209
- kmlSrc = value;
210
- }
211
-
212
-
213
- public void setLoadingBackgroundColor(@Nullable Integer value) {
214
- getMapView().setLoadingBackgroundColor(value);
215
- }
216
-
217
-
218
- public void setLoadingEnabled(boolean value) {
219
- if (getMapView() != null) {
220
- getMapView().setLoadingEnabled(value);
221
- }
222
- loadingEnabled = value;
223
- }
224
-
225
-
226
- public void setLoadingIndicatorColor(@Nullable Integer value) {
227
- if (getMapView() != null) {
228
- getMapView().setLoadingIndicatorColor(value);
229
- }
230
- loadingIndicatorColor = value;
231
- }
232
-
233
-
234
- public void setMapPadding(@Nullable ReadableMap padding) {
235
- if (getMapView() != null) {
236
- int left = 0;
237
- int top = 0;
238
- int right = 0;
239
- int bottom = 0;
240
- double density = (double) getMapView().getResources().getDisplayMetrics().density;
241
-
242
- if (padding != null) {
243
- if (padding.hasKey("left")) {
244
- left = (int) (padding.getDouble("left") * density);
245
- }
246
-
247
- if (padding.hasKey("top")) {
248
- top = (int) (padding.getDouble("top") * density);
249
- }
250
-
251
- if (padding.hasKey("right")) {
252
- right = (int) (padding.getDouble("right") * density);
253
- }
254
-
255
- if (padding.hasKey("bottom")) {
256
- bottom = (int) (padding.getDouble("bottom") * density);
257
- }
258
- }
259
-
260
- getMapView().applyBaseMapPadding(left, top, right, bottom);
261
- getMapView().map.setPadding(left, top, right, bottom);
262
- }
263
- this.mapPadding = padding;
264
- }
265
-
266
- public void setMoveOnMarkerPress(boolean value) {
267
- if (getMapView() != null){
268
- getMapView().setMoveOnMarkerPress(value);
269
- }
270
- moveOnMarkerPress = value;
271
- }
272
-
273
-
274
- public void setHandlePanDrag(boolean value) {
275
- if (getMapView() != null) {
276
- getMapView().setHandlePanDrag(value);
277
- }
278
- handlePanDrag = value;
279
- }
280
-
281
- public void setRegion(@Nullable ReadableMap value) {
282
- if (getMapView() != null) {
283
- getMapView().setRegion(value);
284
- }
285
- region = value;
286
- }
287
-
288
-
289
- public void setShowsBuildings(boolean value) {
290
- showsBuildings = value;
291
- if (getMapView() != null){
292
- getMapView().setShowBuildings(value);
293
- }
294
- }
295
-
296
-
297
- public void setShowsCompass(boolean value) {
298
- if (getMapView() != null) {
299
- getMapView().setShowsCompass(value);
300
- }
301
- }
302
-
303
-
304
- public void setShowsIndoorLevelPicker(boolean value) {
305
- if (getMapView() != null) {
306
- getMapView().setShowsIndoorLevelPicker(value);
307
- }
308
- showsIndoorLevelPicker = value;
309
- }
310
-
311
-
312
- public void setShowsIndoors(boolean value) {
313
- if (getMapView() != null){
314
- getMapView().setShowIndoors(value);
315
- }
316
-
317
- showIndoors = value;
318
- }
319
-
320
-
321
- public void setShowsMyLocationButton(boolean value) {
322
- if (getMapView() != null) {
323
- getMapView().setShowsMyLocationButton(value);
324
- }
325
- showsMyLocationButton = value;
326
- }
327
-
328
- public void setShowsUserLocation(boolean value) {
329
- if (getMapView() != null) {
330
- getMapView().setShowsUserLocation(value);
331
- }
332
- showsUserLocation = value;
333
- }
334
-
335
- public void setUserLocationFastestInterval(int value) {
336
- if (getMapView() != null) {
337
- getMapView().setUserLocationFastestInterval(value);
338
- }
339
- userLocationFastestInterval = value;
340
- }
341
-
342
-
343
- public void setUserLocationPriority(@Nullable String value) {
344
- if (mapView != null) {
345
- mapView.setUserLocationPriority(MY_LOCATION_PRIORITY.get(value));
346
- } else {
347
- userLocationPriority = MY_LOCATION_PRIORITY.get(value);
348
- }
349
- }
350
-
351
-
352
- public void setUserLocationUpdateInterval(int value) {
353
- if (getMapView() != null) {
354
- getMapView().setUserLocationUpdateInterval(value);
355
- }
356
- userLocationUpdateInterval = value;
357
- }
358
-
359
-
360
- public void setZoomControlEnabled(boolean value) {
361
- getMapView().setZoomControlEnabled(value);
362
- }
363
-
364
-
365
- public void setZoomEnabled(boolean value) {
366
- getMapView().setZoomEnabled(value);
367
- }
368
-
369
- }