2011-06-05 96 views
0

我正在嘗試製作一個簡單的應用程序,該應用程序使用Google Map API。我遵循指南中的所有步驟來獲取地圖生成,但是當它加載到仿真器中時,它似乎凍結並且不可導航。它也不會響應任何進一步的控制,如啓用縮放功能。我目前正在使用Google API Level 10(2.3.3)。我也知道它不是我的調試密鑰庫,因爲我再次檢查了兩次,並且兩次都獲得了相同的密鑰。Android Google Maps API凍結屏幕

這裏是什麼,因爲我希望地圖顯示在屏幕上的佈局看起來像:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <TextView android:layout_width="wrap_content" android:id="@+id/googleMapsText"   
    android:layout_height="wrap_content" android:text="@string/google_maps"></TextView> 
    <com.google.android.maps.MapView 
      android:id="@+id/mapView" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:apiKey="0F1mnkApH3dcLN2F0bGSIh_oaj2soQyFGSrEN3w" 
      /> 

</RelativeLayout> 

我的清單文件也有正確的權限。那就是:

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

,我用我的java文件以創建映射的代碼也很簡單:

private MapView mapView; 

/** Called when the activity is first created. */ 
@Override 
public void onCreate(Bundle savedInstanceState) 
{ 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.google_maps); 

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


} 

你對我有什麼建議嗎?

回答

0

嘗試佈局更改爲財產以後很簡單,以確保該問題不存在...
事情是這樣的:

<?xml version="1.0" encoding="utf-8"?> 
<com.google.android.maps.MapView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/mapview" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:apiKey="...your key here..." 
/> 
+0

謝謝你的迴應,但沒有奏效。 – 2011-06-05 20:57:04

3

嘗試將其添加到您的佈局文件:

android:clickable = "true" 

現在,你的地圖應該是可移動和可縮放的

+0

哇......這對我有效。我不知道爲什麼android:clickable =「true」不是默認值。 – fsaint 2011-11-21 20:26:54