Skip to content

Commit 72e7948

Browse files
Merge pull request react-native-maps#1096 from thegdznet/master
Crash in our App fix
2 parents 298bd9c + e2db7b6 commit 72e7948

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

android/src/main/java/com/airbnb/android/react/maps/AirMapView.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import com.google.android.gms.maps.model.Marker;
4343
import com.google.android.gms.maps.model.Polygon;
4444
import com.google.android.gms.maps.model.Polyline;
45+
import com.google.android.gms.maps.model.VisibleRegion;
4546

4647
import java.util.ArrayList;
4748
import java.util.Arrays;
@@ -672,9 +673,12 @@ public void stopMonitoringRegion() {
672673
@Override
673674
public void run() {
674675

675-
LatLngBounds bounds = map.getProjection().getVisibleRegion().latLngBounds;
676-
if (lastBoundsEmitted == null ||
677-
LatLngBoundsUtils.BoundsAreDifferent(bounds, lastBoundsEmitted)) {
676+
Projection projection = map.getProjection();
677+
VisibleRegion region = (projection != null) ? projection.getVisibleRegion() : null;
678+
LatLngBounds bounds = (region != null) ? region.latLngBounds : null;
679+
680+
if ((bounds != null) &&
681+
(lastBoundsEmitted == null || LatLngBoundsUtils.BoundsAreDifferent(bounds, lastBoundsEmitted))) {
678682
LatLng center = map.getCameraPosition().target;
679683
lastBoundsEmitted = bounds;
680684
eventDispatcher.dispatchEvent(new RegionChangeEvent(getId(), bounds, center, true));

0 commit comments

Comments
 (0)