2013-03-15 116 views
0

嗨,我是新的android編程,我遵循從許多教程中的步驟,但我只設法顯示谷歌地圖,只顯示模擬器和設備上的瓷磚。提前謝謝了!Android地圖只顯示瓷磚

繼承人我的清單:

 <?xml version="1.0" encoding="utf-8"?> 
    <manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="bi.com.biosensors" 
    android:versionCode="1" 
    android:versionName="1.0" > 
    <uses-feature   
     android:glEsVersion="0x00020000"   
     android:required="true"/> 


    <uses-permission android:name="bi.com.biosensors.mapdemo.permission.MAPS_RECEIVE"/> 
<uses-permission android:name="android.permission.CALL_PHONE" /> 
<uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> 
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/> 
    <uses-sdk 
     android:minSdkVersion="7" 
     android:targetSdkVersion="17" /> 

    <application 
     android:allowBackup="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme" > 
     <uses-library android:name="com.google.android.maps" /> 



     <activity 
      android:name=".SplashScreen" 
      android:label="@string/app_name" > 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

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

     </activity> 
     <activity android:name=".BiMain" 
      android:configChanges="keyboardHidden|orientation" 
      android:screenOrientation="portrait" 
      android:label="@string/app_name" > 

</activity> 
     <activity android:name=".Products" > 
</activity> 
<activity android:name=".ContactUs" > 
</activity> 
<activity android:name=".WebMapViewActivity" > 
</activity> 
<activity android:name=".WebViewActivity" > 
</activity> 
<activity android:name=".openAccuActivity" > 
</activity> 
<activity android:name=".BusesNearby" > 
</activity> 
<activity android:name=".openBiotransActivity" > 
</activity> 

<activity android:name=".openMultiLuActivity" > 
</activity> 
<activity android:name=".openThermoActivity" > 
</activity> 
<activity android:name=".openBiotrayActivity" > 
</activity> 
<activity android:name=".openBipolarActivity" > 
</activity> 
<activity android:name=".openEmboActivity" > 
</activity> 
<activity android:name=".openBioflexActivity" > 
</activity> 
<activity android:name=".openAxxessActivity" > 
</activity> 
<activity android:name=".openGazelleActivity" > 
</activity> 
<activity android:name=".openPowerlActivity" > 
</activity> 
<activity android:name=".AlertCaution" > 
</activity> 
<activity android:name=".BusRoutes" > 
</activity> 
<activity android:name=".AllBuses" > 
</activity> 
<activity android:name=".bus5route" > 
</activity> 
<activity android:name=".bus15route" > 
</activity> 
<activity android:name=".bus58route" > 
</activity> 
<activity android:name=".bus59route" > 
</activity> 
<activity android:name=".bus87route" > 
      </activity> 
       <activity android:name=".mrtMap" android:screenOrientation="portrait" > 
       </activity> 
       <meta-data android:name="com.google.android.maps.v2.API_KEY" 
    android:value="AIzaSyCFLLz6m3N1WEKNG6KnwvoQvMBTC4r9AzA"/> 
      </application> 
    </manifest> 

我的XML(Im相當肯定我有正確的API密鑰):

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 

<com.google.android.maps.MapView 
    android:id="@+id/mapView" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:enabled="true" 
    android:clickable="true" 
    android:apiKey="***************" 
    /> 

</RelativeLayout> 

和我的Java代碼:

public class WebMapViewActivity extends MapActivity { 

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) 
@Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.mapview); 
     getActionBar(); 
     ActionBar actionBar = getActionBar(); 
     actionBar.setIcon(R.drawable.ic_menu_mapmode); 
     actionBar.setTitle("Map"); 

MapView mapView = (MapView) findViewById(R.id.mapView); 
mapView.setBuiltInZoomControls(true); 

List<Overlay> mapOverlays = mapView.getOverlays(); 
Drawable drawable = this.getResources().getDrawable(R.drawable.ic_launcher); 
HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(drawable,this); 
GeoPoint point = new GeoPoint(133339,-10390584); 
OverlayItem overlayitem = new OverlayItem(point, "Hello!","This is Biosensors Interventional Singapore !"); 

itemizedoverlay.addOverlay(overlayitem); 
MapController mapController = mapView.getController(); 
mapController.setCenter(point); 

mapOverlays.add(itemizedoverlay); 
} 
@Override 
protected boolean isRouteDisplayed() 
{ 
return false; 
} 

     } 
+0

什麼是你的目標呢? –

+0

嗯,很遺憾地告訴你,但瓷磚通常是錯誤的API密鑰的後果。它可能過期了嗎? – tolgap

回答

0

看到一些更多的信息作爲@DavidBriggs說你混合從API V1和V2代碼。

如果你想使用谷歌地圖API V2,因爲它看起來你的所有清單配置那麼這裏是一個博客帖子我就寫了如何添加:

Google Map API V2 to your App.

0

從我可以看到你在這個代碼中混合了API v1和v2。

在您的佈局中刪除的MapView和補充一點:

<fragment xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@+id/map" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:name="com.google.android.gms.maps.MapFragment"/> 

和擴展活動不MapActivity(或FragmentActivity如果您使用的支持庫)。

您可以在Maps API page