0

I have an problem, i want to display the GoogleMap into an Fragment. But when starting the app, the Map stays black. Only the little Google Logo is shown. So im doing it like this :

public class AndroidLauncher extends AndroidApplication implements RequestHandler,LocationListener,
    GoogleApiClient.ConnectionCallbacks, OnMapReadyCallback {

private MapFragment mMapFragment;

public GoogleMap googleMap;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);

    setContentView(R.layout.main);

    mMapFragment = ((MapFragment) getFragmentManager().findFragmentById(R.id.map));

    if (mMapFragment == null) {
        mMapFragment = (MapFragment) MapFragment.newInstance();

        mMapFragment.getMapAsync(this);


        FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();

        // flMap.getID(); returns the FrameLayout ID.

        fragmentTransaction.replace(flMap.getId(), mMapFragment, MAP_FRAGMENT_TAG);
        fragmentTransaction.commit();

    }

}

@Override
public void onMapReady(GoogleMap gMap) {

    googleMap = gMap;

    if (googleMap != null) {

        final LatLng markerPosition = new LatLng(26.9124857, -101.4180168);
        googleMap.addMarker(new MarkerOptions().position(markerPosition)).showInfoWindow();

    }

}

I only posted the most important stuff, there more, like an Layer for sprites, but i think thats not the problem...

When i start the app, my map looks black like this :

Picture of the blank Map

Whats wrong with it :/ ? I already added the API key like this in the manifest :

<meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="@string/google_maps_key" />
<meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
Kaushik NP
  • 6,733
  • 9
  • 31
  • 60
genaray
  • 1,080
  • 1
  • 9
  • 30

1 Answers1

0

You should check out for these guides: https://developers.google.com/maps/documentation/android-api/start

https://developer.android.com/training/building-location.html

Nemus
  • 3,879
  • 12
  • 38
  • 57
  • Im not sure, how this should help me, as i said.. i already added the api key. And this tutorial doesnt show how to add GoogleMaps to an fragment.. – genaray Feb 18 '17 at 17:40
  • Under section "creating map" you have that: https://developers.google.com/maps/documentation/android-api/start – Nemus Feb 18 '17 at 17:54
  • As you can see, im trying to add GoogleMaps into an Fragment. Im not using FragmentActivity. And my question is, why its black, when added to an fragment ... – genaray Feb 18 '17 at 18:02