0

My map fragment is showing blank, all play services are added correctly and internet is also connected in Emulator.

MapActivity.java contains :

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    MapFragment map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map));
    map.getMapAsync(this);
}


@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;
    LatLng Device = new LatLng(21, 57);
    mMap.addMarker(new MarkerOptions().position(Device).title("Device Location"));
    mMap.moveCamera(CameraUpdateFactory.newLatLng(Device));
}

And my fragment in activity_main contains :

    <fragment
        android:id="@+id/map"
        class="com.google.android.gms.maps.MapFragment"
        android:layout_width="350dp"
        android:layout_height="230dp"
        tools:layout="@layout/activity_main" />

But my output in emulator is :

enter image description here

Srijan Chaudhary
  • 637
  • 1
  • 8
  • 18

2 Answers2

1

i think you forgot to add your Google maps API Key in manifest file just add in manifest file under application tag

<meta-data
      android:name="com.google.android.geo.API_KEY"
      android:value="@string/google_maps_key" />
AskNilesh
  • 67,701
  • 16
  • 123
  • 163
0

U must have API key to use google map, follow these steps https://developers.google.com/maps/documentation/android-api/signup

G.L
  • 139
  • 1
  • 4
  • 16