2013-07-31 96 views
0

地圖未顯示在我的應用程序中!地圖未顯示

佈局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context=".MainActivity" > 

<fragment 
    android:id="@+id/map" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    class="com.google.android.gms.maps.SupportMapFragment" /> 

</RelativeLayout> 

活動:

package com.example.vogellamapsv2; 

    import android.os.Bundle; 
    import android.view.Menu; 
    import android.support.v4.app.FragmentActivity; 

    import com.google.android.gms.maps.CameraUpdateFactory; 
    import com.google.android.gms.maps.GoogleMap; 
    import com.google.android.gms.maps.SupportMapFragment; 
    import com.google.android.gms.maps.model.BitmapDescriptorFactory; 
    import com.google.android.gms.maps.model.LatLng; 
    import com.google.android.gms.maps.model.Marker; 
    import com.google.android.gms.maps.model.MarkerOptions; 

    public class MainActivity extends FragmentActivity { 
     static final LatLng HAMBURG = new LatLng(53.558, 9.927); 
     static final LatLng KIEL = new LatLng(53.551, 9.993); 
     private GoogleMap map; 

     @Override 
     protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 


     map = ((SupportMapFragment)  getSupportFragmentManager().findFragmentById(R.id.map)).getMap(); 
     Marker hamburg = map.addMarker(new  MarkerOptions().position(HAMBURG).title("Hamburg")); 
    Marker kiel = map.addMarker(new MarkerOptions() 
     .position(KIEL) 
     .title("Kiel") 
    .snippet("Kiel is cool") 
    .icon(BitmapDescriptorFactory 
     .fromResource(R.drawable.ic_launcher))); 

    // Move the camera instantly to hamburg with a zoom of 15. 
    map.moveCamera(CameraUpdateFactory.newLatLngZoom(HAMBURG, 15)); 

    // Zoom in, animating the camera. 
     map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null); 

     } 

    @Override 
    public boolean onCreateOptionsMenu(Menu menu) { 

    return true; 
    } 

} 

清單:

<?xml version="1.0" encoding="utf-8"?> 
    <manifest xmlns:android="http://schemas.android.com/apk/res/android" 
     package="com.example.vogellamapsv2" 
     android:versionCode="1" 
     android:versionName="1.0" > 

     <uses-sdk 
      android:minSdkVersion="8" 
      android:targetSdkVersion="10" /> 

     <uses-feature 
      android:glEsVersion="0x00020000" 
      android:required="true" /> 

     <uses-permission android:name="com.example.vogellamapsv2.MAPS_RECEIVE" /> 
     <uses-permission android:name="android.permission.INTERNET" /> 
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
     <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> 
     <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 
     <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 

     <application 
      android:allowBackup="true" 
      android:icon="@drawable/ic_launcher" 
      android:label="@string/app_name" 
      android:theme="@style/AppTheme" > 
      <activity 
       android:name="com.example.vogellamapsv2.MainActivity" 
       android:label="@string/app_name" > 
       <intent-filter> 
        <action android:name="android.intent.action.MAIN" /> 

        <category android:name="android.intent.category.LAUNCHER" /> 
       </intent-filter> 
      </activity> 

      <meta-data 
       android:name="com.google.android.maps.v2.API_KEY" 
       android:value="AIzaSyBMXe0_OCa6HyvJO7kaP5u6-Dy3LZe3P1Y" /> 
      </application> 

    </manifest> 

我的問題是:

我已經在模擬器通過以下方式測試了這個應用程序和設備也是,但米ap沒有被顯示!

  1. 我已經把從調試證書的密鑰,並
  2. 我產生了我的應用程序的證書和生成的SHA1和提取谷歌控制檯的一個關鍵,我已經把這個鍵太多,但不顯示的地圖!

所有先決條件,如GoogleAPI目標,lib項目,..等等都是仔細設置的!

請回答可能的解決方案?

+0

我猜Google Maps不適用於模擬器! –

+0

我在真實設備上測試過... – ananth

回答

0

在我的Android清單我也行:

<uses-library android:name="com.google.android.maps" /> 

我這只是應用標籤之後。不知道這是否會解決它,但它是在我使用的教程。