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

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,13 +1,17 @@
1
1
  package com.rnmaps.fabric;
2
2
 
3
3
 
4
+ import android.util.Log;
4
5
  import android.view.View;
5
6
 
7
+ import androidx.annotation.NonNull;
6
8
  import androidx.annotation.Nullable;
7
9
 
8
10
  import com.facebook.react.bridge.ReactApplicationContext;
9
11
  import com.facebook.react.bridge.ReadableMap;
12
+ import com.facebook.react.bridge.UiThreadUtil;
10
13
  import com.facebook.react.module.annotations.ReactModule;
14
+ import com.facebook.react.uimanager.LayoutShadowNode;
11
15
  import com.facebook.react.uimanager.ThemedReactContext;
12
16
  import com.facebook.react.uimanager.ViewGroupManager;
13
17
  import com.facebook.react.uimanager.ViewManagerDelegate;
@@ -15,23 +19,31 @@ import com.facebook.react.viewmanagers.RNMapsMapViewManagerInterface;
15
19
  import com.facebook.react.viewmanagers.RNMapsMapViewManagerDelegate;
16
20
  import com.google.android.gms.maps.GoogleMap;
17
21
  import com.google.android.gms.maps.GoogleMapOptions;
22
+ import com.google.android.gms.maps.MapsInitializer;
23
+ import com.google.android.gms.maps.model.CameraPosition;
18
24
  import com.rnmaps.maps.MapView;
25
+ import com.rnmaps.maps.SizeReportingShadowNode;
19
26
 
27
+ import java.util.List;
20
28
  import java.util.Map;
21
29
 
22
30
  @ReactModule(name = MapViewManager.REACT_CLASS)
23
- public class MapViewManager extends ViewGroupManager<MapView> implements RNMapsMapViewManagerInterface<MapView> {
31
+ public class MapViewManager extends ViewGroupManager<MapViewWrapper> implements RNMapsMapViewManagerInterface<MapViewWrapper> {
32
+
33
+ private GoogleMapOptions options;
34
+ private boolean rendererInitialized = false;
35
+ private final RNMapsMapViewManagerDelegate<MapViewWrapper, MapViewManager> delegate =
36
+ new RNMapsMapViewManagerDelegate<>(this);
24
37
 
25
38
 
26
- public MapViewManager(ReactApplicationContext context){
39
+ public MapViewManager(ReactApplicationContext context) {
27
40
  super(context);
41
+ options = new GoogleMapOptions();
28
42
  }
29
- private GoogleMapOptions options;
30
- private final RNMapsMapViewManagerDelegate<MapView, MapViewManager> delegate =
31
- new RNMapsMapViewManagerDelegate<>(this);
43
+
32
44
 
33
45
  @Override
34
- public ViewManagerDelegate<MapView> getDelegate() {
46
+ public ViewManagerDelegate<MapViewWrapper> getDelegate() {
35
47
  return delegate;
36
48
  }
37
49
 
@@ -41,8 +53,9 @@ public class MapViewManager extends ViewGroupManager<MapView> implements RNMapsM
41
53
  }
42
54
 
43
55
  @Override
44
- public MapView createViewInstance(ThemedReactContext context) {
45
- return new MapView(context, options);
56
+ public MapViewWrapper createViewInstance(ThemedReactContext context) {
57
+ Log.e(MapViewManager.class.getName(), "createViewInstance");
58
+ return new MapViewWrapper(context);
46
59
  }
47
60
 
48
61
 
@@ -54,6 +67,14 @@ public class MapViewManager extends ViewGroupManager<MapView> implements RNMapsM
54
67
  return MapView.getExportedCustomBubblingEventTypeConstants();
55
68
  }
56
69
 
70
+
71
+ @Override
72
+ public LayoutShadowNode createShadowNodeInstance() {
73
+ // A custom shadow node is needed in order to pass back the width/height of the map to the
74
+ // view manager so that it can start applying camera moves with bounds.
75
+ return new SizeReportingShadowNode();
76
+ }
77
+
57
78
  @Nullable
58
79
  @Override
59
80
  public Map<String, Object> getExportedCustomDirectEventTypeConstants() {
@@ -61,288 +82,396 @@ public class MapViewManager extends ViewGroupManager<MapView> implements RNMapsM
61
82
  }
62
83
 
63
84
  @Override
64
- public void setCacheEnabled(MapView view, boolean value) {
85
+ public void setCacheEnabled(MapViewWrapper view, boolean value) {
65
86
  view.setCacheEnabled(value);
66
87
  }
67
88
 
68
89
  @Override
69
- public void setCamera(MapView view, @Nullable ReadableMap value) {
90
+ public void setCamera(MapViewWrapper view, @Nullable ReadableMap value) {
70
91
  view.setCamera(value);
71
92
  }
72
93
 
73
94
  @Override
74
- public void setCompassOffset(MapView view, @Nullable ReadableMap value) {
75
-
95
+ public void setCompassOffset(MapViewWrapper view, @Nullable ReadableMap value) {
96
+ // not supported
76
97
  }
77
98
 
78
99
  @Override
79
- public void setFollowsUserLocation(MapView view, boolean value) {
80
-
100
+ public void setFollowsUserLocation(MapViewWrapper view, boolean value) {
101
+ // not supported
81
102
  }
82
103
 
83
104
  @Override
84
- public void setPoiClickEnabled(MapView view, boolean value) {
105
+ public void setPoiClickEnabled(MapViewWrapper view, boolean value) {
85
106
  view.setPoiClickEnabled(value);
86
107
  }
87
108
 
88
109
  @Override
89
- public void setInitialCamera(MapView view, @Nullable ReadableMap value) {
90
- view.setInitialCamera(value);
110
+ public void setInitialCamera(MapViewWrapper view, @Nullable ReadableMap value) {
111
+ CameraPosition camera = MapView.cameraPositionFromMap(value);
112
+ if (camera != null){
113
+ options.camera(camera);
114
+ view.setInitialCameraSet(true);
115
+ }
116
+ }
117
+
118
+ @Override
119
+ protected MapViewWrapper recycleView(@NonNull ThemedReactContext var1, @NonNull MapViewWrapper wrapper){
120
+ wrapper.prepareToRecycleView();
121
+ return wrapper;
91
122
  }
92
123
 
124
+
93
125
  @Override
94
- public void setInitialRegion(MapView view, @Nullable ReadableMap value) {
126
+ public void setInitialRegion(MapViewWrapper view, @Nullable ReadableMap value) {
95
127
  view.setInitialRegion(value);
96
128
  }
97
129
 
98
130
  @Override
99
- public void setKmlSrc(MapView view, @Nullable String value) {
131
+ public void setKmlSrc(MapViewWrapper view, @Nullable String value) {
100
132
  view.setKmlSrc(value);
101
133
  }
102
134
 
103
135
  @Override
104
- public void setLegalLabelInsets(MapView view, @Nullable ReadableMap value) {
105
-
136
+ public void setLegalLabelInsets(MapViewWrapper view, @Nullable ReadableMap value) {
137
+ // not supported
106
138
  }
107
139
 
108
140
  @Override
109
- public void setLiteMode(MapView view, boolean value) {
110
-
141
+ public void setLiteMode(MapViewWrapper view, boolean value) {
142
+ options.liteMode(value);
111
143
  }
112
144
 
113
145
  @Override
114
- public void setGoogleMapId(MapView view, @Nullable String value) {
115
-
146
+ public void setGoogleMapId(MapViewWrapper view, @Nullable String value) {
147
+ options.mapId(value);
116
148
  }
117
149
 
118
150
  @Override
119
- public void setGoogleRenderer(MapView view, @Nullable String value) {
151
+ public void setGoogleRenderer(MapViewWrapper view, @Nullable String value) {
152
+ if (!rendererInitialized) {
153
+ MapsInitializer.Renderer renderer = MapsInitializer.Renderer.LATEST;
154
+ if ("LEGACY".equals(value)){
155
+ renderer = MapsInitializer.Renderer.LEGACY;
156
+ }
157
+ MapsInitializer.initialize(getReactApplicationContext(), renderer, r -> Log.d("AirMapRenderer", "Init with renderer: " + r));
158
+ rendererInitialized = true;
159
+ }
120
160
 
121
161
  }
122
162
 
123
163
  @Override
124
- public void setLoadingBackgroundColor(MapView view, @Nullable Integer value) {
125
-
164
+ public void setLoadingBackgroundColor(MapViewWrapper view, @Nullable Integer value) {
165
+ view.setLoadingBackgroundColor(value);
126
166
  }
127
167
 
128
168
  @Override
129
- public void setLoadingEnabled(MapView view, boolean value) {
130
-
169
+ public void setLoadingEnabled(MapViewWrapper view, boolean value) {
170
+ view.setLoadingEnabled(value);
131
171
  }
132
172
 
133
173
  @Override
134
- public void setLoadingIndicatorColor(MapView view, @Nullable Integer value) {
174
+ public void setLoadingIndicatorColor(MapViewWrapper view, @Nullable Integer value) {
175
+ view.setLoadingIndicatorColor(value);
176
+ }
135
177
 
178
+ @Override
179
+ public void setMapPadding(MapViewWrapper view, @Nullable ReadableMap padding) {
180
+ view.setMapPadding(padding);
136
181
  }
137
182
 
138
183
  @Override
139
- public void setMapPadding(MapView view, @Nullable ReadableMap value) {
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);
140
187
 
141
188
  }
142
-
143
189
  @Override
144
- public void addView(MapView parent, View child, int index) {
145
- parent.addFeature(child, index);
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());
194
+ }
195
+
146
196
  }
147
197
 
198
+
148
199
  @Override
149
- public void setMapType(MapView view, @Nullable String value) {
200
+ public void setMapType(MapViewWrapper view, @Nullable String value) {
201
+ int mapType;
150
202
  //hybrid | none | satellite | standard | terrain
151
- if ("hybrid".equals(value)){
152
- view.setMapType(GoogleMap.MAP_TYPE_HYBRID);
153
- } else if ("none".equals(value)){
154
- view.setMapType(GoogleMap.MAP_TYPE_NONE);
155
- } else if ("satellite".equals(value)){
156
- view.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
157
- } else if ("standard".equals(value)){
158
- view.setMapType(GoogleMap.MAP_TYPE_NORMAL);
159
- } else if ("terrain".equals(value)){
160
- view.setMapType(GoogleMap.MAP_TYPE_TERRAIN);
203
+ if ("hybrid".equals(value)) {
204
+ mapType = GoogleMap.MAP_TYPE_HYBRID;
205
+ } else if ("none".equals(value)) {
206
+ mapType = GoogleMap.MAP_TYPE_NONE;
207
+ } else if ("satellite".equals(value)) {
208
+ mapType = GoogleMap.MAP_TYPE_SATELLITE;
209
+ } else if ("standard".equals(value)) {
210
+ mapType = GoogleMap.MAP_TYPE_NORMAL;
211
+ } else if ("terrain".equals(value)) {
212
+ mapType = GoogleMap.MAP_TYPE_TERRAIN;
213
+ } else {
214
+ mapType = GoogleMap.MAP_TYPE_NORMAL;
215
+ }
216
+ options.mapType(mapType);
217
+ if (view.getMapView() != null){
218
+ view.getMapView().setMapType(mapType);
161
219
  }
162
220
  }
163
221
 
164
222
  @Override
165
- public void setMaxDelta(MapView view, double value) {
166
-
223
+ public void setMaxDelta(MapViewWrapper view, double value) {
224
+ // not supported
167
225
  }
168
226
 
169
227
  @Override
170
- public void setMaxZoom(MapView view, float value) {
171
-
228
+ public void setMaxZoom(MapViewWrapper view, float value) {
229
+ options.maxZoomPreference(value);
230
+ if (view.getMapView() != null) {
231
+ view.getMapView().setMaxZoomLevel(value);
232
+ }
172
233
  }
173
234
 
174
235
  @Override
175
- public void setMinDelta(MapView view, double value) {
176
-
236
+ public void setMinDelta(MapViewWrapper view, double value) {
237
+ // not supported
177
238
  }
178
239
 
179
240
  @Override
180
- public void setMinZoom(MapView view, float value) {
181
-
241
+ public void setMinZoom(MapViewWrapper view, float value) {
242
+ options.minZoomPreference(value);
243
+ if (view.getMapView() != null) {
244
+ view.getMapView().setMinZoomLevel(value);
245
+ }
182
246
  }
183
247
 
184
248
  @Override
185
- public void setMoveOnMarkerPress(MapView view, boolean value) {
186
-
249
+ public void setMoveOnMarkerPress(MapViewWrapper view, boolean value) {
250
+ view.setMoveOnMarkerPress(value);
187
251
  }
188
252
 
189
253
  @Override
190
- public void setHandlePanDrag(MapView view, boolean value) {
191
-
254
+ public void setHandlePanDrag(MapViewWrapper view, boolean value) {
255
+ view.setHandlePanDrag(value);
192
256
  }
193
257
 
194
258
  @Override
195
- public void setPaddingAdjustmentBehavior(MapView view, @Nullable String value) {
196
-
259
+ public void setPaddingAdjustmentBehavior(MapViewWrapper view, @Nullable String value) {
260
+ // not supported
197
261
  }
198
262
 
199
263
  @Override
200
- public void setPitchEnabled(MapView view, boolean value) {
201
-
264
+ public void setPitchEnabled(MapViewWrapper view, boolean value) {
265
+ options.tiltGesturesEnabled(value);
266
+ if (view.getMapView() != null) {
267
+ view.getMapView().setPitchEnabled(value);
268
+ }
202
269
  }
203
270
 
204
271
  @Override
205
- public void setRegion(MapView view, @Nullable ReadableMap value) {
206
-
272
+ public void setRegion(MapViewWrapper view, @Nullable ReadableMap value) {
273
+ view.setRegion(value);
207
274
  }
208
275
 
209
276
  @Override
210
- public void setRotateEnabled(MapView view, boolean value) {
211
-
277
+ public void setRotateEnabled(MapViewWrapper view, boolean value) {
278
+ options.rotateGesturesEnabled(value);
279
+ if (view.getMapView() != null) {
280
+ view.getMapView().setRotateEnabled(value);
281
+ }
212
282
  }
213
283
 
214
284
  @Override
215
- public void setScrollDuringRotateOrZoomEnabled(MapView view, boolean value) {
216
-
285
+ public void setScrollDuringRotateOrZoomEnabled(MapViewWrapper view, boolean value) {
286
+ options.scrollGesturesEnabledDuringRotateOrZoom(value);
287
+ if (view.getMapView() != null) {
288
+ view.getMapView().setScrollDuringRotateOrZoomEnabled(value);
289
+ }
217
290
  }
218
291
 
219
292
  @Override
220
- public void setScrollEnabled(MapView view, boolean value) {
221
-
293
+ public void setScrollEnabled(MapViewWrapper view, boolean value) {
294
+ options.scrollGesturesEnabled(value);
295
+ if (view.getMapView() != null) {
296
+ view.getMapView().setScrollEnabled(value);
297
+ }
222
298
  }
223
299
 
224
300
  @Override
225
- public void setShowsBuildings(MapView view, boolean value) {
226
-
301
+ public void setShowsBuildings(MapViewWrapper view, boolean value) {
302
+ view.setShowsBuildings(value);
227
303
  }
228
304
 
229
305
  @Override
230
- public void setShowsCompass(MapView view, boolean value) {
231
-
306
+ public void setShowsCompass(MapViewWrapper view, boolean value) {
307
+ options.compassEnabled(value);
308
+ view.setShowsCompass(value);
232
309
  }
233
310
 
234
311
  @Override
235
- public void setShowsIndoorLevelPicker(MapView view, boolean value) {
236
-
312
+ public void setShowsIndoorLevelPicker(MapViewWrapper view, boolean value) {
313
+ view.setShowsIndoorLevelPicker(value);
237
314
  }
238
315
 
239
316
  @Override
240
- public void setShowsIndoors(MapView view, boolean value) {
241
-
317
+ public void setShowsIndoors(MapViewWrapper view, boolean value) {
318
+ view.setShowsIndoors(value);
242
319
  }
243
320
 
244
321
  @Override
245
- public void setShowsMyLocationButton(MapView view, boolean value) {
246
-
322
+ public void setShowsMyLocationButton(MapViewWrapper view, boolean value) {
323
+ view.setShowsMyLocationButton(value);
247
324
  }
248
325
 
249
326
  @Override
250
- public void setShowsScale(MapView view, boolean value) {
251
-
327
+ public void setShowsScale(MapViewWrapper view, boolean value) {
328
+ // not supported
252
329
  }
253
330
 
254
331
  @Override
255
- public void setShowsUserLocation(MapView view, boolean value) {
256
-
332
+ public void setShowsUserLocation(MapViewWrapper view, boolean value) {
333
+ view.setShowsUserLocation(value);
257
334
  }
258
335
 
259
336
  @Override
260
- public void setTintColor(MapView view, @Nullable Integer value) {
261
-
337
+ public void setTintColor(MapViewWrapper view, @Nullable Integer value) {
338
+ // not supported
262
339
  }
263
340
 
264
341
  @Override
265
- public void setToolbarEnabled(MapView view, boolean value) {
266
-
342
+ public void setToolbarEnabled(MapViewWrapper view, boolean value) {
343
+ options.mapToolbarEnabled(value);
344
+ if (view.getMapView() != null) {
345
+ view.getMapView().setToolbarEnabled(value);
346
+ }
267
347
  }
268
348
 
269
349
  @Override
270
- public void setUserInterfaceStyle(MapView view, @Nullable String value) {
271
-
350
+ public void setUserInterfaceStyle(MapViewWrapper view, @Nullable String value) {
351
+ // todo update google maps SDK and add support for MapColorScheme
272
352
  }
273
353
 
274
354
  @Override
275
- public void setUserLocationAnnotationTitle(MapView view, @Nullable String value) {
276
-
355
+ public void setUserLocationAnnotationTitle(MapViewWrapper view, @Nullable String value) {
356
+ // not supported
277
357
  }
278
358
 
279
359
  @Override
280
- public void setUserLocationCalloutEnabled(MapView view, boolean value) {
281
-
360
+ public void setUserLocationCalloutEnabled(MapViewWrapper view, boolean value) {
361
+ // not supported
282
362
  }
283
363
 
284
364
  @Override
285
- public void setUserLocationFastestInterval(MapView view, int value) {
286
-
365
+ public void setUserLocationFastestInterval(MapViewWrapper view, int value) {
366
+ view.setUserLocationFastestInterval(value);
287
367
  }
288
368
 
289
369
  @Override
290
- public void setUserLocationPriority(MapView view, @Nullable String value) {
370
+ public void setUserLocationPriority(MapViewWrapper view, @Nullable String value) {
371
+ view.setUserLocationPriority(value);
372
+ }
291
373
 
374
+ @Override
375
+ public void setUserLocationUpdateInterval(MapViewWrapper view, int value) {
376
+ view.setUserLocationUpdateInterval(value);
292
377
  }
293
378
 
294
379
  @Override
295
- public void setUserLocationUpdateInterval(MapView view, int value) {
380
+ public void setZoomControlEnabled(MapViewWrapper view, boolean value) {
381
+ options.zoomControlsEnabled(value);
382
+ if (view.getMapView() != null) {
383
+ view.setZoomControlEnabled(value);
384
+ }
385
+ }
296
386
 
387
+ @Override
388
+ public void setZoomEnabled(MapViewWrapper view, boolean value) {
389
+ options.zoomGesturesEnabled(value);
390
+ if (view.getMapView() != null) {
391
+ view.setZoomEnabled(value);
392
+ }
297
393
  }
298
394
 
299
395
  @Override
300
- public void setZoomControlEnabled(MapView view, boolean value) {
396
+ public void setZoomTapEnabled(MapViewWrapper view, boolean value) {
397
+ // not supported
398
+ }
301
399
 
400
+ @Override
401
+ public void setCameraZoomRange(MapViewWrapper view, @Nullable ReadableMap value) {
402
+ // not supported
302
403
  }
303
404
 
304
405
  @Override
305
- public void setZoomEnabled(MapView view, boolean value) {
406
+ public void animateToRegion(MapViewWrapper view, String regionJSON, int duration) {
306
407
 
307
408
  }
308
409
 
309
410
  @Override
310
- public void setZoomTapEnabled(MapView view, boolean value) {
411
+ public void setCamera(MapViewWrapper view, String cameraJSON) {
311
412
 
312
413
  }
313
414
 
314
415
  @Override
315
- public void setCameraZoomRange(MapView view, @Nullable ReadableMap value) {
416
+ public void animateCamera(MapViewWrapper view, String cameraJSON, int duration) {
316
417
 
317
418
  }
318
419
 
319
420
  @Override
320
- public void animateToRegion(MapView view, String regionJSON, int duration) {
421
+ public void fitToElements(MapViewWrapper view, String edgePaddingJSON, boolean animated) {
321
422
 
322
423
  }
323
424
 
324
425
  @Override
325
- public void setCamera(MapView view, String cameraJSON) {
426
+ public void fitToSuppliedMarkers(MapViewWrapper view, String markersJSON, String edgePaddingJSON, boolean animated) {
326
427
 
327
428
  }
328
429
 
329
430
  @Override
330
- public void animateCamera(MapView view, String cameraJSON, int duration) {
431
+ public void fitToCoordinates(MapViewWrapper view, String coordinatesJSON, String edgePaddingJSON, boolean animated) {
331
432
 
332
433
  }
333
-
334
434
  @Override
335
- public void fitToElements(MapView view, String edgePaddingJSON, boolean animated) {
435
+ public int getChildCount(MapViewWrapper parent) {
436
+ if (parent.getMapView() != null) {
437
+ return parent.getMapView().getChildCount();
438
+ }
439
+ return 0;
440
+ }
336
441
 
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;
337
448
  }
338
449
 
339
450
  @Override
340
- public void fitToSuppliedMarkers(MapView view, String markersJSON, String edgePaddingJSON, boolean animated) {
451
+ public void removeViewAt(MapViewWrapper parent, int index) {
452
+ if (parent.getMapView() != null) {
453
+ parent.getMapView().removeViewAt(index);
454
+ }
455
+ }
341
456
 
457
+ public void removeView(MapViewWrapper parent, View view) {
458
+ if (parent.getMapView() != null) {
459
+ parent.getMapView().removeView(view);
460
+ }
342
461
  }
343
462
 
344
- @Override
345
- public void fitToCoordinates(MapView view, String coordinatesJSON, String edgePaddingJSON, boolean animated) {
346
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
+ @Override
473
+ public void onDropViewInstance(MapViewWrapper view) {
474
+ super.onDropViewInstance(view);
475
+ view.prepareToRecycleView();
347
476
  }
348
- }
477
+ }
@@ -0,0 +1,369 @@
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
+ }
@@ -42,7 +42,7 @@ public class MapManager extends ViewGroupManager<MapView> {
42
42
  "none", GoogleMap.MAP_TYPE_NONE
43
43
  );
44
44
 
45
- private final Map<String, Integer> MY_LOCATION_PRIORITY = MapBuilder.of(
45
+ public static final Map<String, Integer> MY_LOCATION_PRIORITY = MapBuilder.of(
46
46
  "balanced", Priority.PRIORITY_BALANCED_POWER_ACCURACY,
47
47
  "high", Priority.PRIORITY_HIGH_ACCURACY,
48
48
  "low", Priority.PRIORITY_LOW_POWER,
@@ -240,47 +240,47 @@ public class MapManager extends ViewGroupManager<MapView> {
240
240
 
241
241
  @ReactProp(name = "showsBuildings", defaultBoolean = false)
242
242
  public void setShowBuildings(MapView view, boolean showBuildings) {
243
- view.map.setBuildingsEnabled(showBuildings);
243
+ view.setShowBuildings(showBuildings);
244
244
  }
245
245
 
246
246
  @ReactProp(name = "showsIndoors", defaultBoolean = false)
247
247
  public void setShowIndoors(MapView view, boolean showIndoors) {
248
- view.map.setIndoorEnabled(showIndoors);
248
+ view.setShowIndoors(showIndoors);
249
249
  }
250
250
 
251
251
  @ReactProp(name = "showsIndoorLevelPicker", defaultBoolean = false)
252
252
  public void setShowsIndoorLevelPicker(MapView view, boolean showsIndoorLevelPicker) {
253
- view.map.getUiSettings().setIndoorLevelPickerEnabled(showsIndoorLevelPicker);
253
+ view.setShowsIndoorLevelPicker(showsIndoorLevelPicker);
254
254
  }
255
255
 
256
256
  @ReactProp(name = "showsCompass", defaultBoolean = false)
257
257
  public void setShowsCompass(MapView view, boolean showsCompass) {
258
- view.map.getUiSettings().setCompassEnabled(showsCompass);
258
+ view.setShowsCompass(showsCompass);
259
259
  }
260
260
 
261
261
  @ReactProp(name = "scrollEnabled", defaultBoolean = false)
262
262
  public void setScrollEnabled(MapView view, boolean scrollEnabled) {
263
- view.map.getUiSettings().setScrollGesturesEnabled(scrollEnabled);
263
+ view.setScrollEnabled(scrollEnabled);
264
264
  }
265
265
 
266
266
  @ReactProp(name = "zoomEnabled", defaultBoolean = false)
267
267
  public void setZoomEnabled(MapView view, boolean zoomEnabled) {
268
- view.map.getUiSettings().setZoomGesturesEnabled(zoomEnabled);
268
+ view.setZoomEnabled(zoomEnabled);
269
269
  }
270
270
 
271
271
  @ReactProp(name = "zoomControlEnabled", defaultBoolean = true)
272
272
  public void setZoomControlEnabled(MapView view, boolean zoomControlEnabled) {
273
- view.map.getUiSettings().setZoomControlsEnabled(zoomControlEnabled);
273
+ view.setZoomControlEnabled(zoomControlEnabled);
274
274
  }
275
275
 
276
276
  @ReactProp(name = "rotateEnabled", defaultBoolean = false)
277
277
  public void setRotateEnabled(MapView view, boolean rotateEnabled) {
278
- view.map.getUiSettings().setRotateGesturesEnabled(rotateEnabled);
278
+ view.setRotateEnabled(rotateEnabled);
279
279
  }
280
280
 
281
281
  @ReactProp(name = "scrollDuringRotateOrZoomEnabled", defaultBoolean = true)
282
282
  public void setScrollDuringRotateOrZoomEnabled(MapView view, boolean scrollDuringRotateOrZoomEnabled) {
283
- view.map.getUiSettings().setScrollGesturesEnabledDuringRotateOrZoom(scrollDuringRotateOrZoomEnabled);
283
+ view.setScrollDuringRotateOrZoomEnabled(scrollDuringRotateOrZoomEnabled);
284
284
  }
285
285
 
286
286
  @ReactProp(name = "cacheEnabled", defaultBoolean = false)
@@ -295,7 +295,7 @@ public class MapManager extends ViewGroupManager<MapView> {
295
295
 
296
296
  @ReactProp(name = "loadingEnabled", defaultBoolean = false)
297
297
  public void setLoadingEnabled(MapView view, boolean loadingEnabled) {
298
- view.enableMapLoading(loadingEnabled);
298
+ view.setLoadingEnabled(loadingEnabled);
299
299
  }
300
300
 
301
301
  @ReactProp(name = "moveOnMarkerPress", defaultBoolean = true)
@@ -315,17 +315,17 @@ public class MapManager extends ViewGroupManager<MapView> {
315
315
 
316
316
  @ReactProp(name = "pitchEnabled", defaultBoolean = false)
317
317
  public void setPitchEnabled(MapView view, boolean pitchEnabled) {
318
- view.map.getUiSettings().setTiltGesturesEnabled(pitchEnabled);
318
+ view.setPitchEnabled(pitchEnabled);
319
319
  }
320
320
 
321
321
  @ReactProp(name = "minZoomLevel")
322
322
  public void setMinZoomLevel(MapView view, float minZoomLevel) {
323
- view.map.setMinZoomPreference(minZoomLevel);
323
+ view.setMinZoomLevel(minZoomLevel);
324
324
  }
325
325
 
326
326
  @ReactProp(name = "maxZoomLevel")
327
327
  public void setMaxZoomLevel(MapView view, float maxZoomLevel) {
328
- view.map.setMaxZoomPreference(maxZoomLevel);
328
+ view.setMaxZoomLevel(maxZoomLevel);
329
329
  }
330
330
 
331
331
  @ReactProp(name = "kmlSrc")
@@ -37,14 +37,12 @@ import com.facebook.react.bridge.WritableNativeArray;
37
37
  import com.facebook.react.bridge.WritableNativeMap;
38
38
  import com.facebook.react.uimanager.ThemedReactContext;
39
39
  import com.facebook.react.uimanager.UIManagerHelper;
40
- import com.facebook.react.uimanager.common.UIManagerType;
41
40
  import com.facebook.react.uimanager.events.Event;
42
41
  import com.facebook.react.uimanager.events.EventDispatcher;
43
42
  import com.google.android.gms.maps.CameraUpdate;
44
43
  import com.google.android.gms.maps.CameraUpdateFactory;
45
44
  import com.google.android.gms.maps.GoogleMap;
46
45
  import com.google.android.gms.maps.GoogleMapOptions;
47
- import com.google.android.gms.maps.MapsInitializer;
48
46
  import com.google.android.gms.maps.OnMapReadyCallback;
49
47
  import com.google.android.gms.maps.Projection;
50
48
  import com.google.android.gms.maps.model.BitmapDescriptorFactory;
@@ -69,7 +67,6 @@ import com.google.maps.android.collections.PolylineManager;
69
67
  import com.google.maps.android.data.kml.KmlContainer;
70
68
  import com.google.maps.android.data.kml.KmlLayer;
71
69
  import com.google.maps.android.data.kml.KmlPlacemark;
72
- import com.google.maps.android.data.kml.KmlStyle;
73
70
 
74
71
  import org.xmlpull.v1.XmlPullParserException;
75
72
 
@@ -141,6 +138,18 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
141
138
 
142
139
  private final ViewAttacherGroup attacherGroup;
143
140
  private LatLng tapLocation;
141
+ private Float maxZoomLevel;
142
+ private Float minZoomLevel;
143
+ private Boolean pitchEnabled;
144
+ private Boolean showsCompass;
145
+ private Boolean rotateEnabled;
146
+ private Boolean zoomEnabled;
147
+ private Boolean zoomControlEnabled;
148
+ private Boolean setShowBuildings;
149
+ private Boolean showsIndoorLevelPicker;
150
+ private Boolean showIndoors;
151
+ private Boolean scrollEnabled;
152
+ private Boolean scrollDuringRotateOrZoomEnabled;
144
153
 
145
154
  private static boolean contextHasBug(Context context) {
146
155
  return context == null ||
@@ -175,7 +184,6 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
175
184
  GoogleMapOptions googleMapOptions) {
176
185
  super(context, googleMapOptions);
177
186
  // todo add support for legacy renderer
178
- MapsInitializer.initialize(context, MapsInitializer.Renderer.LATEST, renderer -> Log.d("AirMapRenderer", renderer.toString()));
179
187
  this.context = context;
180
188
  super.onCreate(null);
181
189
  super.onResume();
@@ -260,6 +268,42 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
260
268
  return;
261
269
  }
262
270
  this.map = map;
271
+ if (maxZoomLevel != null){
272
+ setMaxZoomLevel(maxZoomLevel);
273
+ }
274
+ if (minZoomLevel != null){
275
+ setMinZoomLevel(minZoomLevel);
276
+ }
277
+ if (pitchEnabled != null){
278
+ setPitchEnabled(pitchEnabled);
279
+ }
280
+ if (showsCompass != null){
281
+ setShowsCompass(showsCompass);
282
+ }
283
+ if (rotateEnabled != null){
284
+ setRotateEnabled(rotateEnabled);
285
+ }
286
+ if (zoomEnabled != null){
287
+ setZoomEnabled(zoomEnabled);
288
+ }
289
+ if (zoomControlEnabled != null){
290
+ setZoomControlEnabled(zoomControlEnabled);
291
+ }
292
+ if (setShowBuildings != null){
293
+ setShowBuildings(setShowBuildings);
294
+ }
295
+ if (showsIndoorLevelPicker != null){
296
+ setShowsIndoorLevelPicker(showsIndoorLevelPicker);
297
+ }
298
+ if (showIndoors != null){
299
+ setShowIndoors(showIndoors);
300
+ }
301
+ if (scrollEnabled != null){
302
+ setScrollEnabled(scrollEnabled);
303
+ }
304
+ if (scrollDuringRotateOrZoomEnabled != null){
305
+ setScrollDuringRotateOrZoomEnabled(scrollDuringRotateOrZoomEnabled);
306
+ }
263
307
 
264
308
  markerManager = new MarkerManager(map);
265
309
  markerCollection = markerManager.newCollection();
@@ -588,6 +632,10 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
588
632
  onDestroy();
589
633
  }
590
634
 
635
+ public void setInitialCameraSet(boolean initialCameraSet){
636
+ this.initialCameraSet = initialCameraSet;
637
+ }
638
+
591
639
  public void setInitialRegion(ReadableMap initialRegion) {
592
640
  this.initialRegion = initialRegion;
593
641
  // Theoretically onMapReady might be called before setInitialRegion
@@ -623,18 +671,23 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
623
671
  }
624
672
  this.setPoiClickEnabled(poiClickEnabled);
625
673
  }
626
-
674
+ public static LatLngBounds latLngBoundsFromRegion(ReadableMap region){
675
+ if (region == null) return null;
676
+
677
+ double lng = region.getDouble("longitude");
678
+ double lat = region.getDouble("latitude");
679
+ double lngDelta = region.getDouble("longitudeDelta");
680
+ double latDelta = region.getDouble("latitudeDelta");
681
+ return new LatLngBounds(
682
+ new LatLng(lat - latDelta / 2, lng - lngDelta / 2), // southwest
683
+ new LatLng(lat + latDelta / 2, lng + lngDelta / 2) // northeast
684
+ );
685
+ }
627
686
  private void moveToRegion(ReadableMap region) {
628
- if (region == null) return;
629
-
687
+ LatLngBounds bounds = latLngBoundsFromRegion(region);
688
+ if (bounds == null) return;
630
689
  double lng = region.getDouble("longitude");
631
690
  double lat = region.getDouble("latitude");
632
- double lngDelta = region.getDouble("longitudeDelta");
633
- double latDelta = region.getDouble("latitudeDelta");
634
- LatLngBounds bounds = new LatLngBounds(
635
- new LatLng(lat - latDelta / 2, lng - lngDelta / 2), // southwest
636
- new LatLng(lat + latDelta / 2, lng + lngDelta / 2) // northeast
637
- );
638
691
  if (super.getHeight() <= 0 || super.getWidth() <= 0) {
639
692
  // in this case, our map has not been laid out yet, so we save the bounds in a local
640
693
  // variable, and make a guess of zoomLevel 10. Not to worry, though: as soon as layout
@@ -724,18 +777,24 @@ public static CameraPosition cameraPositionFromMap(ReadableMap camera){
724
777
  }
725
778
 
726
779
  public void setShowsMyLocationButton(boolean showMyLocationButton) {
727
- if (hasPermissions() || !showMyLocationButton) {
728
- map.getUiSettings().setMyLocationButtonEnabled(showMyLocationButton);
780
+ if (map != null) {
781
+ if (hasPermissions() || !showMyLocationButton) {
782
+ map.getUiSettings().setMyLocationButtonEnabled(showMyLocationButton);
783
+ }
729
784
  }
730
785
  }
731
786
 
732
787
  public void setToolbarEnabled(boolean toolbarEnabled) {
733
- if (hasPermissions() || !toolbarEnabled) {
734
- map.getUiSettings().setMapToolbarEnabled(toolbarEnabled);
788
+ if (map != null) {
789
+ if (hasPermissions() || !toolbarEnabled) {
790
+ map.getUiSettings().setMapToolbarEnabled(toolbarEnabled);
791
+ }
735
792
  }
736
793
  }
737
794
  public void setMapType(int mapType){
738
- map.setMapType(mapType);
795
+ if (map != null) {
796
+ map.setMapType(mapType);
797
+ }
739
798
  }
740
799
 
741
800
  public void setCacheEnabled(boolean cacheEnabled) {
@@ -745,10 +804,12 @@ public static CameraPosition cameraPositionFromMap(ReadableMap camera){
745
804
 
746
805
  public void setPoiClickEnabled(boolean poiClickEnabled) {
747
806
  this.poiClickEnabled = poiClickEnabled;
748
- map.setOnPoiClickListener(poiClickEnabled ? this : null);
807
+ if (map != null) {
808
+ map.setOnPoiClickListener(poiClickEnabled ? this : null);
809
+ }
749
810
  }
750
811
 
751
- public void enableMapLoading(boolean loadingEnabled) {
812
+ public void setLoadingEnabled(boolean loadingEnabled) {
752
813
  if (loadingEnabled && !this.isMapLoaded) {
753
814
  this.getMapLoadingLayoutView().setVisibility(View.VISIBLE);
754
815
  }
@@ -757,6 +818,79 @@ public static CameraPosition cameraPositionFromMap(ReadableMap camera){
757
818
  public void setMoveOnMarkerPress(boolean moveOnPress) {
758
819
  this.moveOnMarkerPress = moveOnPress;
759
820
  }
821
+ public void setMaxZoomLevel(float maxZoomLevel){
822
+ this.maxZoomLevel = maxZoomLevel;
823
+ if (map != null) {
824
+ map.setMaxZoomPreference(maxZoomLevel);
825
+ }
826
+ }
827
+ public void setMinZoomLevel(float minZoomLevel){
828
+ this.minZoomLevel = minZoomLevel;
829
+ if (map != null) {
830
+ map.setMinZoomPreference(minZoomLevel);
831
+ }
832
+ }
833
+ public void setPitchEnabled(boolean pitchEnabled){
834
+ this.pitchEnabled = pitchEnabled;
835
+ if (map != null) {
836
+ map.getUiSettings().setTiltGesturesEnabled(pitchEnabled);
837
+ }
838
+ }
839
+ public void setShowsCompass(boolean showsCompass){
840
+ this.showsCompass = showsCompass;
841
+ if (map != null) {
842
+ map.getUiSettings().setCompassEnabled(showsCompass);
843
+ }
844
+ }
845
+ public void setRotateEnabled(boolean rotateEnabled){
846
+ this.rotateEnabled = rotateEnabled;
847
+ if (map != null) {
848
+ map.getUiSettings().setRotateGesturesEnabled(rotateEnabled);
849
+ }
850
+ }
851
+ public void setZoomEnabled(boolean zoomEnabled){
852
+ this.zoomEnabled = zoomEnabled;
853
+ if (map != null) {
854
+ map.getUiSettings().setZoomGesturesEnabled(zoomEnabled);
855
+ }
856
+ }
857
+ public void setZoomControlEnabled(boolean zoomControlEnabled){
858
+ this.zoomControlEnabled = zoomControlEnabled;
859
+ if (map != null) {
860
+ map.getUiSettings().setZoomControlsEnabled(zoomControlEnabled);
861
+ }
862
+ }
863
+ public void setScrollDuringRotateOrZoomEnabled(boolean scrollDuringRotateOrZoomEnabled){
864
+ this.scrollDuringRotateOrZoomEnabled = scrollDuringRotateOrZoomEnabled;
865
+ if (map != null) {
866
+ map.getUiSettings().setScrollGesturesEnabledDuringRotateOrZoom(scrollDuringRotateOrZoomEnabled);
867
+ }
868
+ }
869
+ public void setScrollEnabled(boolean scrollEnabled){
870
+ this.scrollEnabled = scrollEnabled;
871
+ if (map != null) {
872
+ map.getUiSettings().setScrollGesturesEnabled(scrollEnabled);
873
+ }
874
+ }
875
+ public void setShowIndoors(boolean showIndoors){
876
+ this.showIndoors = showIndoors;
877
+ if (map != null) {
878
+ map.setIndoorEnabled(showIndoors);
879
+ }
880
+ }
881
+ public void setShowsIndoorLevelPicker(boolean showsIndoorLevelPicker) {
882
+ this.showsIndoorLevelPicker = showsIndoorLevelPicker;
883
+ if (map != null) {
884
+ map.getUiSettings().setIndoorLevelPickerEnabled(showsIndoorLevelPicker);
885
+ }
886
+ }
887
+ public void setShowBuildings(boolean showBuildings) {
888
+ this.setShowBuildings = showBuildings;
889
+ if (map != null) {
890
+ map.setBuildingsEnabled(showBuildings);
891
+ }
892
+ }
893
+
760
894
 
761
895
  public void setLoadingBackgroundColor(Integer loadingBackgroundColor) {
762
896
  this.loadingBackgroundColor = loadingBackgroundColor;
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.53",
8
+ "version": "1.21.0-alpha.55",
9
9
  "license": "MIT",
10
10
  "scripts": {
11
11
  "lint": "eslint . --max-warnings 0",