use the following code in your activity/fragment where you would like to use Maps
<fragment
class="com.google.android.gms.maps.MapFragment"
android:name="com.google.android.gms.maps.MapFragment"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Then in your Fragment's onCreateView you can use the following code
private void setUpMapIfNeeded() {
// Do a null check to confirm that we have not already instantiated the
// map.
if (mMapFragment == null) {
// Try to obtain the map from the SupportMapFragment.
mMapFragment = ((MapFragment) getFragmentManager().findFragmentById(R.id.map));
// Check if we were successful in obtaining the map.
if (mMapFragment != null) {
setUpMap();
}
}
}
setup you map stuff in below mentioned method
private void setUpMap() {
mMapFragment.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap map) {
...
}
}
}
Hope it helps...