我遇到了问题,我想将GoogleMap显示为片段。但是在启动应用程序时,地图会保持黑色。仅显示小型Google徽标。 所以我这样做:
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();
}
}
我只发布了最重要的东西,还有更多,比如精灵层,但我认为这不是问题......
当我启动应用程序时,我的地图看起来像这样黑:
它有什么问题:/?我已经在清单中添加了这样的API密钥:
<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" />
答案 0 :(得分:0)