MapView问题/清空瓷砖

时间:2012-02-26 15:46:42

标签: android map android-mapview api-key

我遇到了MapView的问题..我之前使用过MapView,所以我真的不知道问题是什么,它可能是一些简单的东西,我忽略了但它让我疯了。该应用程序安装并运行有趣,但MapView磁贴不会加载。我只看到一个空格子。我知道API密钥(调试密钥库)很有趣,因为我有另一个使用它的项目完美无缺。我已经包含了我的清单,布局和活动文件来帮助诊断问题。我很感激任何帮助 - 我很困惑!

清单:

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

1 个答案:

答案 0 :(得分: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>