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及更高版本。 –