2012-02-26 104 views
0

我遇到了MapView的問題..我之前使用過MapView,所以我真的不知道問題是什麼,它可能是我忽略的一些簡單東西,但它讓我瘋狂。該應用程序安裝並運行樂趣,但MapView瓷磚不加載。我看到的只是一個空網格。我知道API密鑰(調試密鑰庫)很有趣,因爲我有另一個使用它的項目,可以很好地工作。我已經包含了我的清單,佈局和活動文件,以幫助診斷問題。我會很感激任何幫助 - 我很困惑!MapView問題/空瓷磚

清單:

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

<uses-sdk android:minSdkVersion="10" /> 
<uses-permission android:name="android.permission.INTERNET"/> 

<application 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@android:style/Theme.NoTitleBar" > 
    <uses-library android:name="com.google.android.maps" /> 
    <activity 
     android:name=".StudyBuddy" 
     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=".MapInterface" > 
    </activity> 
    <service 
     android:name=".FriendService" > 
     <intent-filter> 
      <action 
       android:name="com.***.studybuddy.FriendService" /> 
     </intent-filter> 
    </service> 
</application> 

佈局:

<?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" 
    android:orientation="vertical" > 
    <LinearLayout 
     android:id="@+id/sideMenuInterface" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:background="#FFFFFF" > 
    </LinearLayout> 
    <LinearLayout 
     android:id="@+id/mapInterface" 
     android:layout_alignLeft="@id/sideMenuInterface" 
     android:layout_alignTop="@id/sideMenuInterface" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical" > 
     <RelativeLayout 
      android:id="@+id/topMenu" 
      android:layout_width="fill_parent" 
      android:layout_height="30dp" 
      android:clickable="true" 
      android:onClick="onClick" > 
     </RelativeLayout> 
     <com.google.android.maps.MapView 
      android:id="@+id/mapView" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:clickable="true" 
      android:apiKey="0f6nuBOcz_OlhAQm3B3Xljy5hDOVrR1FO3KM***" 
     /> 
    </LinearLayout> 
</RelativeLayout> 

活性:

package com.***.studybuddy; 

import android.content.Intent; 
import android.os.Bundle; 
import android.view.View; 
import android.view.View.OnClickListener; 

import com.google.android.maps.MapActivity; 
import com.google.android.maps.MapView; 

public class MapInterface extends MapActivity implements OnClickListener { 
    static int USER_ID = 1; 
    static MapView mapView; 


    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.mapinterface); 

     configure(); 
    } 

    @Override 
    protected boolean isRouteDisplayed() { 
     return false; 
    } 

    private void configure() { 
     findViews(); 
     startService(new Intent(FriendService.class.getName())); 
     mapView.setBuiltInZoomControls(true); 
     mapView.setSatellite(true); 
    } 

    private void findViews() { 
     mapView = (MapView) findViewById(R.id.mapView); 
    } 

    @Override 
    public void onClick(View view) { 
     switch(view.getId()) { 
     case R.id.topMenu: 
      ((View)view.getParent()).setVisibility(View.GONE); 
      break; 
     } 

    } 
} 

截圖: Empty Tiles

回答

0

我曾經有一個問題,我錯過了一些權限。我需要這3個權限(你錯過了前兩個)。:

<uses-permission android:name=」android.permission.ACCESS_COARSE_LOCATION」></uses-permission> 
<uses-permission android:name=」android.permission.ACCESS_FINE_LOCATION」></uses-permission> 
<uses-permission android:name=」android.permission.INTERNET」></uses-permission> 
+0

添加了權限,沒有更改...地圖仍然是空的。 – user1118042 2012-02-26 16:08:15

+0

那麼我可以想象的唯一事情就是簽署你的應用程序出錯了。您所做的描述如下:http://code.google.com/android/add-ons/google-apis/mapkey.html? – Moritz 2012-02-26 16:21:25

+0

是的..我會嘗試生成一個新的調試密鑰庫..我會讓你知道,如果這樣做的作品 – user1118042 2012-02-26 16:39:36