【问题标题】:Emulator displays a Blue screen and not displaying the google map模拟器显示蓝屏,不显示谷歌地图
【发布时间】:2012-06-02 20:29:39
【问题描述】:

我正在尝试非常基本的谷歌地图 api 代码。但它只是给了我一个空白的蓝页。

我的程序是这样的

Java 代码::

package com.project1;

import android.os.Bundle;

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

public class Testmap22Activity extends MapActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        MapView mapview = (MapView) findViewById(R.id.mapview);
        GeoPoint gp = new GeoPoint(130810,802740);
        MapController mvc = mapview.getController();
        mvc.setCenter(gp);
        mapview.setBuiltInZoomControls(true);
    }

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

main.xml 是

<?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:enabled="true"
                 android:clickable="true"
                 android:apiKey="Key"
                 />

清单文件

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

    <uses-sdk android:minSdkVersion="15" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.INTERNET"/>


    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".Testmap22Activity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <uses-library android:name="com.google.android.maps"/>
    </application>

</manifest>

我得到的只是一个启用缩放的空白蓝页。 需要您的帮助...

分部

【问题讨论】:

    标签: android google-maps google-maps-api-3 android-emulator android-mapview


    【解决方案1】:

    正如您所说,您输入了正确的地图密钥,并且构建目标已设置为 Google Api。那么这个蓝屏只有一种可能(经纬度参数错误):

               GeoPoint gp = new GeoPoint(130810,802740);
    

    您在 GeoPoint 构造函数中提供了错误的参数,这就是您的屏幕显示为蓝色的原因。在 GeoPoint 构造函数中传递正确的经纬度。

    【讨论】:

      【解决方案2】:

      错误就在这里

       android:apiKey="Key"
      

      参考这个链接..这里地图视图是一步一步解释的 http://developer.android.com/resources/tutorials/views/hello-mapview.html

      【讨论】:

      • 嘿,谢谢,但我的实际代码是, <?xml version="1.0" encoding="utf-8"?><com.google.android.maps.mapview xmlns: android="&lt;a href=" http: rel="nofollow" target="_blank">schemas.android.com/apk/res/android" android:id="@+id/mapview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:enabled="true" android:clickable="true" android:apiKey= "0F2bFdGVwAfpKIk-XsNQDyAWSFGWvTSkRulG_Ag" /&gt;代码&gt;</com.google.android.maps.mapview>
      • 将构建目标更改为“Google api”
      【解决方案3】:
       android:apiKey="Key"
      

      插入您的 MD5(映射键)而不是 "Key"

      如何获取MD5https://developers.google.com/maps/documentation/android/mapkey

      【讨论】:

      • 嗨,谢谢,我有来自谷歌的实际 MD5 密钥。这是我的实际布局。 'schemas.android.com/apk/res/android" android:id="@+id/mapview " android:layout_width="fill_parent" android:layout_height="fill_parent" android:enabled="true" android:clickable="true" android:apiKey="0F2bFdGVwAfpKIk-XsNQDyAWSFGWvTSkRulG_Ag" />'代码>
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-05-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-03
      • 2017-03-26
      相关资源
      最近更新 更多