Android谷歌地图API冻结屏幕



我正在尝试制作一个使用Google Map API的简单应用程序。我按照指南中的所有步骤来生成地图,但当它加载到模拟器中时,它似乎被冻结了,无法导航。它也不响应任何进一步的控制,如启用缩放功能。我目前正在使用Google API Level 10(2.3.3)。我也知道它不是我的调试密钥库,因为我仔细检查了两次,两次都得到了相同的密钥。

以下是我希望地图显示的屏幕布局:

<?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);

}

你有什么建议吗?

尝试将其添加到布局文件中:

android:clickable = "true"

现在,你的地图应该是可移动和缩放的

尝试将布局更改为非常简单的东西,以确保问题不存在
类似这样的东西:

<?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..."
/>

最新更新