react-native-maps 2.0.0-beta.6 → 2.0.0-beta.7

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,5 @@
1
1
  package com.rnmaps.maps;
2
2
 
3
- import android.app.Activity;
4
3
  import android.graphics.Bitmap;
5
4
  import android.graphics.Point;
6
5
  import android.location.Address;
@@ -10,52 +9,52 @@ import android.util.Base64;
10
9
  import android.util.DisplayMetrics;
11
10
  import android.util.Log;
12
11
 
13
- import androidx.annotation.Nullable;
14
12
  import androidx.annotation.NonNull;
13
+ import androidx.annotation.Nullable;
15
14
 
16
15
  import com.facebook.react.bridge.Promise;
17
16
  import com.facebook.react.bridge.ReactApplicationContext;
18
17
  import com.facebook.react.bridge.ReactContextBaseJavaModule;
19
18
  import com.facebook.react.bridge.ReactMethod;
19
+ import com.facebook.react.bridge.ReadableArray;
20
20
  import com.facebook.react.bridge.ReadableMap;
21
21
  import com.facebook.react.bridge.WritableMap;
22
22
  import com.facebook.react.bridge.WritableNativeMap;
23
- import com.facebook.react.module.annotations.ReactModule;
24
23
  import com.facebook.react.uimanager.NativeViewHierarchyManager;
25
24
  import com.facebook.react.uimanager.UIBlock;
26
25
  import com.facebook.react.uimanager.UIManagerModule;
26
+ import com.google.android.gms.maps.CameraUpdate;
27
+ import com.google.android.gms.maps.CameraUpdateFactory;
27
28
  import com.google.android.gms.maps.GoogleMap;
28
29
  import com.google.android.gms.maps.MapsInitializer;
29
30
  import com.google.android.gms.maps.OnMapsSdkInitializedCallback;
30
31
  import com.google.android.gms.maps.model.CameraPosition;
31
32
  import com.google.android.gms.maps.model.LatLng;
33
+ import com.google.android.gms.maps.model.LatLngBounds;
34
+ import com.google.android.gms.maps.model.Marker;
32
35
 
33
36
  import java.io.ByteArrayOutputStream;
34
37
  import java.io.Closeable;
35
38
  import java.io.File;
36
39
  import java.io.FileOutputStream;
37
40
  import java.io.IOException;
38
-
41
+ import java.util.Arrays;
42
+ import java.util.HashMap;
39
43
  import java.util.List;
40
44
  import java.util.Map;
41
- import java.util.HashMap;
42
45
 
43
- @ReactModule(name = MapViewModule.NAME)
44
46
  public class MapViewModule extends ReactContextBaseJavaModule {
45
47
 
46
- public static final String NAME = "RNMMapViewModule";
47
- private static final String SNAPSHOT_RESULT_FILE = "file";
48
- private static final String SNAPSHOT_RESULT_BASE64 = "base64";
49
- private static final String SNAPSHOT_FORMAT_PNG = "png";
50
- private static final String SNAPSHOT_FORMAT_JPG = "jpg";
48
+ private final ReactApplicationContext context;
51
49
 
52
50
  public MapViewModule(ReactApplicationContext reactContext) {
53
51
  super(reactContext);
52
+ context = reactContext;
54
53
  }
55
54
 
56
55
  @Override
57
56
  public String getName() {
58
- return NAME;
57
+ return "RNMMapViewModule";
59
58
  }
60
59
 
61
60
  @Override
@@ -65,10 +64,6 @@ public class MapViewModule extends ReactContextBaseJavaModule {
65
64
  return constants;
66
65
  }
67
66
 
68
- public Activity getActivity() {
69
- return getCurrentActivity();
70
- }
71
-
72
67
  public static void closeQuietly(Closeable closeable) {
73
68
  if (closeable == null) return;
74
69
  try {
@@ -79,24 +74,21 @@ public class MapViewModule extends ReactContextBaseJavaModule {
79
74
 
80
75
  @ReactMethod
81
76
  public void takeSnapshot(final int tag, final ReadableMap options, final Promise promise) {
82
-
83
77
  // Parse and verity options
84
- final ReactApplicationContext context = getReactApplicationContext();
85
78
  final String format = options.hasKey("format") ? options.getString("format") : "png";
86
79
  final Bitmap.CompressFormat compressFormat =
87
- format.equals(SNAPSHOT_FORMAT_PNG) ? Bitmap.CompressFormat.PNG :
88
- format.equals(SNAPSHOT_FORMAT_JPG) ? Bitmap.CompressFormat.JPEG : null;
80
+ format.equals("png") ? Bitmap.CompressFormat.PNG :
81
+ format.equals("jpg") ? Bitmap.CompressFormat.JPEG : null;
89
82
  final double quality = options.hasKey("quality") ? options.getDouble("quality") : 1.0;
90
83
  final DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
91
84
  final Integer width =
92
- options.hasKey("width") ? (int) (displayMetrics.density * options.getDouble("width")) : 0;
85
+ options.hasKey("width") ? (int) (displayMetrics.density * options.getDouble("width")) : 0;
93
86
  final Integer height =
94
- options.hasKey("height") ? (int) (displayMetrics.density * options.getDouble("height")) : 0;
87
+ options.hasKey("height") ? (int) (displayMetrics.density * options.getDouble("height")) : 0;
95
88
  final String result = options.hasKey("result") ? options.getString("result") : "file";
96
89
 
97
90
  // Add UI-block so we can get a valid reference to the map-view
98
- UIManagerModule uiManager = context.getNativeModule(UIManagerModule.class);
99
- uiManager.addUIBlock(new UIBlock() {
91
+ context.getNativeModule(UIManagerModule.class).addUIBlock(new UIBlock() {
100
92
  public void execute(NativeViewHierarchyManager nvhm) {
101
93
  MapView view = (MapView) nvhm.resolveView(tag);
102
94
  if (view == null) {
@@ -116,17 +108,17 @@ public class MapViewModule extends ReactContextBaseJavaModule {
116
108
  return;
117
109
  }
118
110
  if ((width != 0) && (height != 0) &&
119
- (width != snapshot.getWidth() || height != snapshot.getHeight())) {
111
+ (width != snapshot.getWidth() || height != snapshot.getHeight())) {
120
112
  snapshot = Bitmap.createScaledBitmap(snapshot, width, height, true);
121
113
  }
122
114
 
123
115
  // Save the snapshot to disk
124
- if (result.equals(SNAPSHOT_RESULT_FILE)) {
116
+ if (result.equals("file")) {
125
117
  File tempFile;
126
118
  FileOutputStream outputStream;
127
119
  try {
128
120
  tempFile =
129
- File.createTempFile("RNMMapSnapshot", "." + format, context.getCacheDir());
121
+ File.createTempFile("RNMMapSnapshot", "." + format, context.getCacheDir());
130
122
  outputStream = new FileOutputStream(tempFile);
131
123
  } catch (Exception e) {
132
124
  promise.reject(e);
@@ -136,7 +128,7 @@ public class MapViewModule extends ReactContextBaseJavaModule {
136
128
  closeQuietly(outputStream);
137
129
  String uri = Uri.fromFile(tempFile).toString();
138
130
  promise.resolve(uri);
139
- } else if (result.equals(SNAPSHOT_RESULT_BASE64)) {
131
+ } else if (result.equals("base64")) {
140
132
  ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
141
133
  snapshot.compress(compressFormat, (int) (100.0 * quality), outputStream);
142
134
  closeQuietly(outputStream);
@@ -152,14 +144,9 @@ public class MapViewModule extends ReactContextBaseJavaModule {
152
144
 
153
145
  @ReactMethod
154
146
  public void getCamera(final int tag, final Promise promise) {
155
- final ReactApplicationContext context = getReactApplicationContext();
156
-
157
- UIManagerModule uiManager = context.getNativeModule(UIManagerModule.class);
158
- uiManager.addUIBlock(new UIBlock()
159
- {
147
+ context.getNativeModule(UIManagerModule.class).addUIBlock(new UIBlock() {
160
148
  @Override
161
- public void execute(NativeViewHierarchyManager nvhm)
162
- {
149
+ public void execute(NativeViewHierarchyManager nvhm) {
163
150
  MapView view = (MapView) nvhm.resolveView(tag);
164
151
  if (view == null) {
165
152
  promise.reject("RNMMapView not found");
@@ -178,9 +165,9 @@ public class MapViewModule extends ReactContextBaseJavaModule {
178
165
 
179
166
  WritableMap cameraJson = new WritableNativeMap();
180
167
  cameraJson.putMap("center", centerJson);
181
- cameraJson.putDouble("heading", (double)position.bearing);
182
- cameraJson.putDouble("zoom", (double)position.zoom);
183
- cameraJson.putDouble("pitch", (double)position.tilt);
168
+ cameraJson.putDouble("heading", (double) position.bearing);
169
+ cameraJson.putDouble("zoom", (double) position.zoom);
170
+ cameraJson.putDouble("pitch", (double) position.tilt);
184
171
 
185
172
  promise.resolve(cameraJson);
186
173
  }
@@ -189,14 +176,9 @@ public class MapViewModule extends ReactContextBaseJavaModule {
189
176
 
190
177
  @ReactMethod
191
178
  public void getAddressFromCoordinates(final int tag, final ReadableMap coordinate, final Promise promise) {
192
- final ReactApplicationContext context = getReactApplicationContext();
193
-
194
- UIManagerModule uiManager = context.getNativeModule(UIManagerModule.class);
195
- uiManager.addUIBlock(new UIBlock()
196
- {
179
+ context.getNativeModule(UIManagerModule.class).addUIBlock(new UIBlock() {
197
180
  @Override
198
- public void execute(NativeViewHierarchyManager nvhm)
199
- {
181
+ public void execute(NativeViewHierarchyManager nvhm) {
200
182
  MapView view = (MapView) nvhm.resolveView(tag);
201
183
  if (view == null) {
202
184
  promise.reject("RNMMapView not found");
@@ -215,7 +197,7 @@ public class MapViewModule extends ReactContextBaseJavaModule {
215
197
  Geocoder geocoder = new Geocoder(context);
216
198
  try {
217
199
  List<Address> list =
218
- geocoder.getFromLocation(coordinate.getDouble("latitude"),coordinate.getDouble("longitude"),1);
200
+ geocoder.getFromLocation(coordinate.getDouble("latitude"), coordinate.getDouble("longitude"), 1);
219
201
  if (list.isEmpty()) {
220
202
  promise.reject("Can not get address location");
221
203
  return;
@@ -244,20 +226,16 @@ public class MapViewModule extends ReactContextBaseJavaModule {
244
226
 
245
227
  @ReactMethod
246
228
  public void pointForCoordinate(final int tag, ReadableMap coordinate, final Promise promise) {
247
- final ReactApplicationContext context = getReactApplicationContext();
248
- final double density = (double) context.getResources().getDisplayMetrics().density;
229
+ final double density = context.getResources().getDisplayMetrics().density;
249
230
 
250
231
  final LatLng coord = new LatLng(
251
232
  coordinate.hasKey("latitude") ? coordinate.getDouble("latitude") : 0.0,
252
233
  coordinate.hasKey("longitude") ? coordinate.getDouble("longitude") : 0.0
253
234
  );
254
235
 
255
- UIManagerModule uiManager = context.getNativeModule(UIManagerModule.class);
256
- uiManager.addUIBlock(new UIBlock()
257
- {
236
+ context.getNativeModule(UIManagerModule.class).addUIBlock(new UIBlock() {
258
237
  @Override
259
- public void execute(NativeViewHierarchyManager nvhm)
260
- {
238
+ public void execute(NativeViewHierarchyManager nvhm) {
261
239
  MapView view = (MapView) nvhm.resolveView(tag);
262
240
  if (view == null) {
263
241
  promise.reject("RNMMapView not found");
@@ -271,8 +249,8 @@ public class MapViewModule extends ReactContextBaseJavaModule {
271
249
  Point pt = view.map.getProjection().toScreenLocation(coord);
272
250
 
273
251
  WritableMap ptJson = new WritableNativeMap();
274
- ptJson.putDouble("x", (double)pt.x / density);
275
- ptJson.putDouble("y", (double)pt.y / density);
252
+ ptJson.putDouble("x", (double) pt.x / density);
253
+ ptJson.putDouble("y", (double) pt.y / density);
276
254
 
277
255
  promise.resolve(ptJson);
278
256
  }
@@ -281,28 +259,22 @@ public class MapViewModule extends ReactContextBaseJavaModule {
281
259
 
282
260
  @ReactMethod
283
261
  public void coordinateForPoint(final int tag, ReadableMap point, final Promise promise) {
284
- final ReactApplicationContext context = getReactApplicationContext();
285
- final double density = (double) context.getResources().getDisplayMetrics().density;
262
+ final double density = context.getResources().getDisplayMetrics().density;
286
263
 
287
264
  final Point pt = new Point(
288
- point.hasKey("x") ? (int)(point.getDouble("x") * density) : 0,
289
- point.hasKey("y") ? (int)(point.getDouble("y") * density) : 0
265
+ point.hasKey("x") ? (int) (point.getDouble("x") * density) : 0,
266
+ point.hasKey("y") ? (int) (point.getDouble("y") * density) : 0
290
267
  );
291
268
 
292
- UIManagerModule uiManager = context.getNativeModule(UIManagerModule.class);
293
- uiManager.addUIBlock(new UIBlock()
294
- {
269
+ context.getNativeModule(UIManagerModule.class).addUIBlock(new UIBlock() {
295
270
  @Override
296
- public void execute(NativeViewHierarchyManager nvhm)
297
- {
271
+ public void execute(NativeViewHierarchyManager nvhm) {
298
272
  MapView view = (MapView) nvhm.resolveView(tag);
299
- if (view == null)
300
- {
273
+ if (view == null) {
301
274
  promise.reject("RNMMapView not found");
302
275
  return;
303
276
  }
304
- if (view.map == null)
305
- {
277
+ if (view.map == null) {
306
278
  promise.reject("RNMMapView.map is not valid");
307
279
  return;
308
280
  }
@@ -320,14 +292,9 @@ public class MapViewModule extends ReactContextBaseJavaModule {
320
292
 
321
293
  @ReactMethod
322
294
  public void getMapBoundaries(final int tag, final Promise promise) {
323
- final ReactApplicationContext context = getReactApplicationContext();
324
-
325
- UIManagerModule uiManager = context.getNativeModule(UIManagerModule.class);
326
- uiManager.addUIBlock(new UIBlock()
327
- {
295
+ context.getNativeModule(UIManagerModule.class).addUIBlock(new UIBlock() {
328
296
  @Override
329
- public void execute(NativeViewHierarchyManager nvhm)
330
- {
297
+ public void execute(NativeViewHierarchyManager nvhm) {
331
298
  MapView view = (MapView) nvhm.resolveView(tag);
332
299
  if (view == null) {
333
300
  promise.reject("RNMMapView not found");
@@ -359,14 +326,9 @@ public class MapViewModule extends ReactContextBaseJavaModule {
359
326
 
360
327
  @ReactMethod
361
328
  public void enableLatestRenderer(final Promise promise) {
362
- final ReactApplicationContext context = getReactApplicationContext();
363
-
364
- UIManagerModule uiManager = context.getNativeModule(UIManagerModule.class);
365
- uiManager.addUIBlock(new UIBlock()
366
- {
329
+ context.getNativeModule(UIManagerModule.class).addUIBlock(new UIBlock() {
367
330
  @Override
368
- public void execute(NativeViewHierarchyManager nvhm)
369
- {
331
+ public void execute(NativeViewHierarchyManager nvhm) {
370
332
  MapsInitializer.initialize(context, MapsInitializer.Renderer.LATEST, new OnMapsSdkInitializedCallback() {
371
333
  @Override
372
334
  public void onMapsSdkInitialized(@NonNull MapsInitializer.Renderer renderer) {
@@ -377,4 +339,260 @@ public class MapViewModule extends ReactContextBaseJavaModule {
377
339
  }
378
340
  });
379
341
  }
342
+
343
+ @ReactMethod
344
+ public void animateToRegion(final int tag, ReadableMap region, int duration, final Promise promise) {
345
+ double lng = region.getDouble("longitude");
346
+ double lat = region.getDouble("latitude");
347
+ double lngDelta = region.getDouble("longitudeDelta");
348
+ double latDelta = region.getDouble("latitudeDelta");
349
+ LatLngBounds bounds = new LatLngBounds(
350
+ new LatLng(lat - latDelta / 2, lng - lngDelta / 2), // southwest
351
+ new LatLng(lat + latDelta / 2, lng + lngDelta / 2) // northeast
352
+ );
353
+
354
+ context.getNativeModule(UIManagerModule.class).addUIBlock(new UIBlock() {
355
+ @Override
356
+ public void execute(NativeViewHierarchyManager nativeViewHierarchyManager) {
357
+ MapView view = (MapView) nativeViewHierarchyManager.resolveView(tag);
358
+ if (view == null) {
359
+ promise.reject("RNMMapView not found");
360
+ return;
361
+ }
362
+ if (view.map == null) {
363
+ promise.reject("RNMMapView.map is not valid");
364
+ return;
365
+ }
366
+ if (duration <= 0) {
367
+ view.map.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0));
368
+ promise.resolve(null);
369
+ } else {
370
+ view.map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0), duration, new GoogleMap.CancelableCallback() {
371
+ @Override
372
+ public void onCancel() {
373
+ promise.resolve(null);
374
+ }
375
+
376
+ @Override
377
+ public void onFinish() {
378
+ promise.resolve(null);
379
+ }
380
+ });
381
+ }
382
+ }
383
+ });
384
+ }
385
+
386
+ @ReactMethod
387
+ public void animateCamera(final int tag, ReadableMap camera, int duration, final Promise promise) {
388
+ context.getNativeModule(UIManagerModule.class).addUIBlock(new UIBlock() {
389
+ @Override
390
+ public void execute(NativeViewHierarchyManager nativeViewHierarchyManager) {
391
+ MapView view = (MapView) nativeViewHierarchyManager.resolveView(tag);
392
+ if (view == null) {
393
+ promise.reject("RNMMapView not found");
394
+ return;
395
+ }
396
+ if (view.map == null) {
397
+ promise.reject("RNMMapView.map is not valid");
398
+ return;
399
+ }
400
+
401
+ CameraUpdate update = view.buildCameraUpdate(camera);
402
+
403
+ if (duration <= 0) {
404
+ view.map.moveCamera(update);
405
+ promise.resolve(null);
406
+ } else {
407
+ view.map.animateCamera(update, duration, new GoogleMap.CancelableCallback() {
408
+ @Override
409
+ public void onCancel() {
410
+ promise.resolve(null);
411
+ }
412
+
413
+ @Override
414
+ public void onFinish() {
415
+ promise.resolve(null);
416
+ }
417
+ });
418
+ }
419
+ }
420
+ });
421
+ }
422
+
423
+ @ReactMethod
424
+ public void fitToElements(final int tag, ReadableMap edgePadding, int duration, final Promise promise) {
425
+ context.getNativeModule(UIManagerModule.class).addUIBlock(new UIBlock() {
426
+ @Override
427
+ public void execute(NativeViewHierarchyManager nativeViewHierarchyManager) {
428
+ MapView view = (MapView) nativeViewHierarchyManager.resolveView(tag);
429
+ if (view == null) {
430
+ promise.reject("RNMMapView not found");
431
+ return;
432
+ }
433
+ if (view.map == null) {
434
+ promise.reject("RNMMapView.map is not valid");
435
+ return;
436
+ }
437
+ LatLngBounds.Builder builder = new LatLngBounds.Builder();
438
+
439
+ boolean addedPosition = false;
440
+
441
+ for (MapFeature feature : view.features) {
442
+ if (feature instanceof MapMarker) {
443
+ Marker marker = (Marker) feature.getFeature();
444
+ builder.include(marker.getPosition());
445
+ addedPosition = true;
446
+ }
447
+ // TODO(lmr): may want to include shapes / etc.
448
+ }
449
+ if (addedPosition) {
450
+ LatLngBounds bounds = builder.build();
451
+ CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, view.baseMapPadding);
452
+
453
+ if (edgePadding != null) {
454
+ view.map.setPadding(edgePadding.getInt("left"), edgePadding.getInt("top"),
455
+ edgePadding.getInt("right"), edgePadding.getInt("bottom"));
456
+ }
457
+
458
+ if (duration > 0) {
459
+ view.map.animateCamera(cu, duration, new GoogleMap.CancelableCallback() {
460
+ @Override
461
+ public void onCancel() {
462
+ promise.resolve(null);
463
+ }
464
+
465
+ @Override
466
+ public void onFinish() {
467
+ promise.resolve(null);
468
+ }
469
+ });
470
+ } else {
471
+ view.map.moveCamera(cu);
472
+ promise.resolve(null);
473
+ }
474
+ }
475
+ }
476
+ });
477
+
478
+ }
479
+
480
+ @ReactMethod
481
+ public void fitToSuppliedMarkers(final int tag, ReadableArray markersIds, ReadableMap edgePadding, int duration, final Promise promise) {
482
+ context.getNativeModule(UIManagerModule.class).addUIBlock(new UIBlock() {
483
+ @Override
484
+ public void execute(NativeViewHierarchyManager nativeViewHierarchyManager) {
485
+ MapView view = (MapView) nativeViewHierarchyManager.resolveView(tag);
486
+ if (view == null) {
487
+ promise.reject("RNMMapView not found");
488
+ return;
489
+ }
490
+ if (view.map == null) {
491
+ promise.reject("RNMMapView.map is not valid");
492
+ return;
493
+ }
494
+ LatLngBounds.Builder builder = new LatLngBounds.Builder();
495
+
496
+ String[] markerIDs = new String[markersIds.size()];
497
+ for (int i = 0; i < markersIds.size(); i++) {
498
+ markerIDs[i] = markersIds.getString(i);
499
+ }
500
+
501
+ boolean addedPosition = false;
502
+
503
+ List<String> markerIDList = Arrays.asList(markerIDs);
504
+
505
+ for (MapFeature feature : view.features) {
506
+ if (feature instanceof MapMarker) {
507
+ String identifier = ((MapMarker) feature).getIdentifier();
508
+ Marker marker = (Marker) feature.getFeature();
509
+ if (markerIDList.contains(identifier)) {
510
+ builder.include(marker.getPosition());
511
+ addedPosition = true;
512
+ }
513
+ }
514
+ }
515
+
516
+ if (addedPosition) {
517
+ LatLngBounds bounds = builder.build();
518
+ CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, view.baseMapPadding);
519
+
520
+ if (edgePadding != null) {
521
+ view.map.setPadding(edgePadding.getInt("left"), edgePadding.getInt("top"),
522
+ edgePadding.getInt("right"), edgePadding.getInt("bottom"));
523
+ }
524
+
525
+ if (duration > 0) {
526
+ view.map.animateCamera(cu, duration, new GoogleMap.CancelableCallback() {
527
+ @Override
528
+ public void onCancel() {
529
+ promise.resolve(null);
530
+ }
531
+
532
+ @Override
533
+ public void onFinish() {
534
+ promise.resolve(null);
535
+ }
536
+ });
537
+ } else {
538
+ view.map.moveCamera(cu);
539
+ promise.resolve(null);
540
+ }
541
+ }
542
+ }
543
+ });
544
+ }
545
+
546
+ @ReactMethod
547
+ public void fitToCoordinates(final int tag, ReadableArray coordinates, ReadableMap edgePadding, int duration, Promise promise) {
548
+ context.getNativeModule(UIManagerModule.class).addUIBlock(new UIBlock() {
549
+ @Override
550
+ public void execute(NativeViewHierarchyManager nativeViewHierarchyManager) {
551
+ MapView view = (MapView) nativeViewHierarchyManager.resolveView(tag);
552
+ if (view == null) {
553
+ promise.reject("RNMMapView not found");
554
+ return;
555
+ }
556
+ if (view.map == null) {
557
+ promise.reject("RNMMapView.map is not valid");
558
+ return;
559
+ }
560
+
561
+ LatLngBounds.Builder builder = new LatLngBounds.Builder();
562
+
563
+ for (int i = 0; i < coordinates.size(); i++) {
564
+ ReadableMap latLng = coordinates.getMap(i);
565
+ double lat = latLng.getDouble("latitude");
566
+ double lng = latLng.getDouble("longitude");
567
+ builder.include(new LatLng(lat, lng));
568
+ }
569
+
570
+ LatLngBounds bounds = builder.build();
571
+ CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, view.baseMapPadding);
572
+
573
+ if (edgePadding != null) {
574
+ view.appendMapPadding(edgePadding.getInt("left"), edgePadding.getInt("top"), edgePadding.getInt("right"), edgePadding.getInt("bottom"));
575
+ }
576
+
577
+ if (duration > 0) {
578
+ view.map.animateCamera(cu, duration, new GoogleMap.CancelableCallback() {
579
+ @Override
580
+ public void onCancel() {
581
+ promise.resolve(null);
582
+ }
583
+
584
+ @Override
585
+ public void onFinish() {
586
+ promise.resolve(null);
587
+ }
588
+ });
589
+ } else {
590
+ view.map.moveCamera(cu);
591
+ promise.resolve(null);
592
+ }
593
+ // Move the google logo to the default base padding value.
594
+ view.map.setPadding(view.baseLeftMapPadding, view.baseTopMapPadding, view.baseRightMapPadding, view.baseBottomMapPadding);
595
+ }
596
+ });
597
+ }
380
598
  }