File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed
android/src/main/java/com/airbnb/android/react/maps Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -497,20 +497,27 @@ public void animateToCoordinate(LatLng coordinate, int duration) {
497497
498498 public void fitToElements (boolean animated ) {
499499 LatLngBounds .Builder builder = new LatLngBounds .Builder ();
500+
501+ boolean addedPosition = false ;
502+
500503 for (AirMapFeature feature : features ) {
501504 if (feature instanceof AirMapMarker ) {
502505 Marker marker = (Marker ) feature .getFeature ();
503506 builder .include (marker .getPosition ());
507+ addedPosition = true ;
504508 }
505509 // TODO(lmr): may want to include shapes / etc.
506510 }
507- LatLngBounds bounds = builder .build ();
508- CameraUpdate cu = CameraUpdateFactory .newLatLngBounds (bounds , 50 );
509- if (animated ) {
510- startMonitoringRegion ();
511- map .animateCamera (cu );
512- } else {
513- map .moveCamera (cu );
511+
512+ if (addedPosition ) {
513+ LatLngBounds bounds = builder .build ();
514+ CameraUpdate cu = CameraUpdateFactory .newLatLngBounds (bounds , 50 );
515+ if (animated ) {
516+ startMonitoringRegion ();
517+ map .animateCamera (cu );
518+ } else {
519+ map .moveCamera (cu );
520+ }
514521 }
515522 }
516523
You can’t perform that action at this time.
0 commit comments