1

我照着所有的在線解決方案,但是沒有什麼變化,我仍然不斷收到地圖和地圖不工作的青瓦......谷歌地圖視圖只顯示灰瓦

的教程規定,我需要一個API - 使用MD5指紋鑰匙,但谷歌代碼犯規接受它,而是它需要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的和IM即時通訊上的API 8(舊教程)

PLZ幫助發展中國家

回答

0

你是混合了你就必須產生實際的關鍵是谷歌地圖API V2和您使用的是像MapActivityMapView對象谷歌地圖API V1對象的代碼。

而這就是您沒有看到任何地圖的原因,Google不提供Google Maps API V1的API密鑰,因爲它現在已經過時。因此,您必須將代碼更改爲Google Maps API V2對象。

爲了讓您一開始,你可以看看這個博客文章中,我就如何谷歌地圖API V2在你的應用程序中集成寫道:

Google Maps API V2

+0

事情是我在這裏閱讀: https://developers.google.com/maps/documentation/android/start#the_google_maps_api_key V2和此代碼僅支持API 12或更高版本...即時通訊使用API​​ 8。 。 這會是一個問題嗎? –

+0

指南中提供的代碼將適用於API 8及更高版本。 –