I have realised that either way one can arrive at the same result, a map inside an Activity, alongside other UI Components. Whether Google Maps Activity is used or if an Empty Activity is created and map code implemented in it. My code is included below. I chose an Empty Activity (Android 2.1.2) and then brought in the map code into the .java file and placed the map fragment with tag in the XML Layout of the activity.
The error was that I had used
android:name="com.google.android.gms.maps.MapFragment"
in the XML Layout but declared and initialised mapFragment(the object instance) with SupportMapFragment. The mix up came while copying and pasting code from the Google Documentation. As I was trying to update my post here I spotted the error. The correct thing to do is if you are using MapFragment(API level 12 and over) use it all through. If you decide to use SupportMapFragment(below API level 12) use SupportMapFragment all through.
The code below is the correction. Just in case anyone has the same issue.
XML Layout (activity_main.xml)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.myapp.MainActivity">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/teachers_link"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/parent_link"
android:layout_marginLeft="20dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="340dp"
android:orientation="vertical">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="135dp"
android:layout_marginTop="12dp"
android:orientation="vertical">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/search_term" />
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:id="@+id/select_level"
android:entries="@array/select_level"></Spinner>
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/select_course"
android:entries="@array/select_course"></Spinner>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/btn_search" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
.java file (MainActivity.java)
package name;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
public class MainActivity extends AppCompatActivity implements OnMapReadyCallback{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
@Override
public void onMapReady(GoogleMap map) {
map.addMarker(new MarkerOptions()
.position(new LatLng(0, 0))
.title("Marker"));
}
}