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 @@ -462,20 +462,27 @@ public void animateToCoordinate(LatLng coordinate, int duration) {
462462
463463 public void fitToElements (boolean animated ) {
464464 LatLngBounds .Builder builder = new LatLngBounds .Builder ();
465+
466+ boolean addedPosition = false ;
467+
465468 for (AirMapFeature feature : features ) {
466469 if (feature instanceof AirMapMarker ) {
467470 Marker marker = (Marker ) feature .getFeature ();
468471 builder .include (marker .getPosition ());
472+ addedPosition = true ;
469473 }
470474 // TODO(lmr): may want to include shapes / etc.
471475 }
472- LatLngBounds bounds = builder .build ();
473- CameraUpdate cu = CameraUpdateFactory .newLatLngBounds (bounds , 50 );
474- if (animated ) {
475- startMonitoringRegion ();
476- map .animateCamera (cu );
477- } else {
478- map .moveCamera (cu );
476+
477+ if (addedPosition ) {
478+ LatLngBounds bounds = builder .build ();
479+ CameraUpdate cu = CameraUpdateFactory .newLatLngBounds (bounds , 50 );
480+ if (animated ) {
481+ startMonitoringRegion ();
482+ map .animateCamera (cu );
483+ } else {
484+ map .moveCamera (cu );
485+ }
479486 }
480487 }
481488
You can’t perform that action at this time.
0 commit comments