Google地图视图仅显示灰色图块

时间:2013-08-01 00:17:26

标签: android google-maps android-emulator intellij-idea google-maps-android-api-2

我遵循了所有在线解决方案,但没有任何变化我仍然在地图上得到灰色瓷砖,地图也不起作用......

教程指定我需要使用MD5指纹的api-key,但谷歌代码不接受它,而是需要SHA-1指纹......

这是我的代码:

Main.java:

package com.thenewboston.googleMaps;


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


public class Main extends MapActivity{

MapView map;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    map = (MapView)findViewById(R.id.mvMain);
    map.setTraffic(true);

    if(map.isShown()){
        System.out.println("Test1");
    }

    map.setBuiltInZoomControls(true);
    map.setSatellite(true);
}

@Override
protected boolean isRouteDisplayed() {
    return false;
}
}

main.xml中:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:orientation="vertical"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
    >


<com.google.android.maps.MapView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:apiKey="AIzaSyAms_xsUt-l-qlIR6fuAd0jfaYRsBIV3bg"
        android:id="@+id/mvMain"
        />
</LinearLayout>

清单:

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

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


<application android:label="@string/app_name">
    <uses-library android:name="com.google.android.maps"/>
    <activity
            android:name="Main"
            android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>

</application>
</manifest> 

注意:即时通讯使用linux和Intellij Idea,我正在开发API 8(旧教程)

PLZ帮助

2 个答案:

答案 0 :(得分:0)

我可以看到一堆东西在上升(如清单上的api键)

检查http://www.vogella.com/articles/AndroidGoogleMaps/article.html。它可能有所帮助。 Imo这个更好http://www.youtube.com/watch?v=awX5T-EwLPc

答案 1 :(得分:0)

您正在混合您为Google Maps API V2生成的实际密钥以及您正在使用的代码,例如MapActivityMapView对象等Google Maps API V1对象。< / p>

这就是您没有看到任何地图的原因,Google没有为Google Maps API V1提供API密钥,因为它现在被弃用了一段时间。因此,您必须将代码更改为Google Maps API V2对象。

为了帮助您入门,您可以查看我撰写的关于如何在您的应用中集成Google Maps API V2的博客文章:

Google Maps API V2

相关问题