Skip to content

Commit 7b29749

Browse files
committed
chore(demo): Initialize map fragment when map ID is null
Allows the demo application to run even when a map ID is not provided by instantiating the `SupportMapFragment` without `GoogleMapOptions`.
1 parent b858c08 commit 7b29749

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

demo/src/main/java/com/google/maps/android/utils/demo/BaseDemoActivity.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,19 @@ private void setUpMap(Bundle savedInstanceState) {
9797
// 2. Call the getMapId() method
9898
String mapId = app.getMapId();
9999

100+
// Create a new SupportMapFragment instance
101+
SupportMapFragment mapFragment;
102+
100103
if (mapId == null) {
101-
finish(); // Note the main application will inform the user of the need for the map ID.
102-
return;
104+
mapFragment = SupportMapFragment.newInstance();
105+
} else {
106+
// Create the map options
107+
GoogleMapOptions mapOptions = new GoogleMapOptions();
108+
mapOptions.mapId(mapId);
109+
// Create a new SupportMapFragment instance
110+
mapFragment = SupportMapFragment.newInstance(mapOptions);
103111
}
104112

105-
// Create the map options
106-
GoogleMapOptions mapOptions = new GoogleMapOptions();
107-
mapOptions.mapId(mapId);
108-
109-
// Create a new SupportMapFragment instance
110-
SupportMapFragment mapFragment = SupportMapFragment.newInstance(mapOptions);
111-
112113
// Add the fragment to the container (R.id.map)
113114
// Check savedInstanceState to prevent re-adding on rotation
114115
if (savedInstanceState == null) {

0 commit comments

Comments
 (0)