2011-05-07 99 views
0

親愛的,我想顯示谷歌地圖上我的應用程序正在模擬器上運行...但哪個api鍵我沒有工作,並在模擬器只有瓷磚顯示不地圖顯示什麼要在我的模擬器中顯示地圖,我在android和java中都是新的,所以請簡要地介紹一下exlinse中的thanklin ...我已經閱讀了「獲取MD5指紋」,但沒有站在如何實現它,所以逐步解釋.. .PLS PSL請.. 我的main.xml是什麼是關鍵商店和如何實施谷歌地圖

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

<com.google.android.maps.MapView 
    android:id="@+id/mapview" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:clickable="true" 
    android:enabled="true" 
    android:apiKey="0mT--u1GbHdhnBJgPZU8zhoF2e4qdpCag32e7lQ" /> 

和java文件

package de.vogella.android.locationapi.maps; 

import android.content.Context; 
import android.location.Location; 
import android.location.LocationListener; 
import android.location.LocationManager; 
import android.os.Bundle; 
import android.widget.RelativeLayout; 

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 ShowMap extends MapActivity { 

private MapController mapController; 
private MapView mapView; 
private LocationManager locationManager; 

public void onCreate(Bundle bundle) { 
    super.onCreate(bundle); 
    setContentView(R.layout.main); // bind the layout to the activity 

    // create a map view 
    RelativeLayout linearLayout = (RelativeLayout) findViewById(R.id.mainlayout); 
    mapView = (MapView) findViewById(R.id.mapview); 
    mapView.setBuiltInZoomControls(true); 
    mapView.setStreetView(true); 
    mapController = mapView.getController(); 
    mapController.setZoom(14); // Zoon 1 is world view 
    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); 
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 
      0, new GeoUpdateHandler()); 
} 

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

public class GeoUpdateHandler implements LocationListener { 

    @Override 
    public void onLocationChanged(Location location) { 
     int lat = (int) (location.getLatitude() * 1E6); 
     int lng = (int) (location.getLongitude() * 1E6); 
     GeoPoint point = new GeoPoint(lat, lng); 
     mapController.animateTo(point); // mapController.setCenter(point); 
    } 

    @Override 
    public void onProviderDisabled(String provider) { 
    } 

    @Override 
    public void onProviderEnabled(String provider) { 
    } 

    @Override 
    public void onStatusChanged(String provider, int status, Bundle extras) { 
    } 
} 

}

+0

我投票關閉這一問題作爲題外話,因爲它很舊,根據特徵的棄用目前並不合適,所以它沒有更多的有用.. – SRam 2015-06-10 12:22:47

回答

0

我設計出磚將顯示而不是實際的地圖圖像的NI鐵路應用程序時出現了問題。這似乎是因爲我正在使用我團隊中另一個人創建的調試密鑰庫。一旦我們創建了發佈密鑰庫和發佈API密鑰,地圖就可以正常工作。對你來說可能是一個類似的問題。

0

首先,您需要獲取調試密鑰庫的MD5指紋。這是怎麼做的:http://code.google.com/intl/ru-RU/android/add-ons/google-apis/mapkey.html#getdebugfingerprint

請注意,如果您使用發行密鑰庫和構建應用程序對它(如使用ant版本),你需要獲得指紋發佈密鑰庫(但你是sayng你是新來的Android我懷疑你現在正在使用發行密鑰庫)

然後,你需要在谷歌註冊密鑰,並獲得地圖的關鍵。請點擊這個鏈接:http://code.google.com/intl/ru-RU/android/add-ons/google-apis/mapkey.html#registering

另外,請告訴我,你在哪裏得到你當前的地圖的關鍵?如果按上述方法獲取,可能是您的應用在AndroidManifest.xml文件中缺少INTERNET權限。

確保你有下面這行你的清單

<uses-permission android:name="android.permission.INTERNET" />