地图显示网格,未显示地图

时间:2011-12-02 03:51:25

标签: android google-maps maps

我在地图中查看地图,直到今天工作正常。请记住,我已经触及了地图视图中的任何代码,因为我已经开始工作了。突然之间,地图视图上什么都没有了,只是一个地图网格。会导致什么?我尝试了一个新的API密钥,它似乎不起作用。谷歌地图加载一切正常。我甚至在其他手机上试过它,还只是一个网格。

映射班级

package com.nyneaxis.api.gascloud;

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

import android.os.Bundle;
import android.widget.LinearLayout;

public class StationsMap extends MapActivity  {

    LinearLayout linearLayout;
        MapView mapView;

    public void onCreate(Bundle savedInstanceState){

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

    @Override
    protected boolean isRouteDisplayed() {
        // TODO Auto-generated method stub
        return false;
    }

}

maps.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mainlayout"
    android:orientation="vertical"
    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:clickable="true"
        android:apiKey="ABQIAAAAYc7mzgA4G-2FaBLUHTM_1xTjBItGPNb7O-Zq4IGUb6RxSdEi4RQ7Y-p4UARzkmuBTxknyrJRWOA31w"
    />

</RelativeLayout>

3 个答案:

答案 0 :(得分:1)

在应用程序代码

中的android-manifest文件中包含地图库
<uses-library android:name="com.google.android.maps" />

并授予Internet权限。如果你有正确的地图API密钥,那么除了这个

之外似乎没有错

答案 1 :(得分:0)

你有没有onCreate这个,因为我没有在你的代码中看到它:

super.onCreate(savedInstanceState);
        setContentView(R.layout.mainlayout);

答案 2 :(得分:0)

这是代码的问题。我用它来记录主类中的一些活动。在生成密钥库失败后,我终于开始深入研究代码并删除我认为可能是问题的代码。删除所有内容后,我只剩下这个了。我评论代码和地图再次工作。我替换了所有原始代码并删除了onResume。现在一切正常。

感谢所有人的帮助。是否有人能够告诉我为什么这一点代码会阻止地图加载?这实际上让我感到震惊了一个星期。

    public void onResume(){
    super.onStart();
    Log.v(tag, "Task was resume");
}
相关问题