1

我遵循了所有在线解决方案,但是没有任何改变,我仍然不断在地图上看到灰色瓷砖,而且地图不起作用......

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

这是我的代码:

主.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;
}
}

主要.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 上开发(旧教程)

请帮助

4

2 回答 2

0

您正在混淆您为 Google Maps API V2 生成的实际密钥和您正在使用的代码,该代码是 Google Maps API V1 对象,如MapActivityMapView对象。

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

为了让您开始,您可以查看我写的关于如何在您的应用程序中集成 Google Maps API V2 的博客文章:

谷歌地图 API V2

于 2013-08-01T00:50:38.243 回答
0

我可以看到一堆东西不见了(比如清单上的 api 键)

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

于 2013-08-01T00:31:22.560 回答