2012-01-20 37 views
0
public class Map extends MapActivity { 

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.map); 

    MapView mapView = (MapView) findViewById(R.id.myMapView1); 

      mapView.getController().animateTo(srcGeoPoint); 
    mapView.getController().setZoom(15); 

} 

的map.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:id="@+id/myMapView1" 
android:layout_width="fill_parent" 
    android:layout_x="0px" 
    android:enabled="true" 
    android:clickable="true" 
android:apiKey="Obtained Key here" android:layout_y="105px"    android:layout_height="fill_parent"> 
    </com.google.android.maps.MapView> 
</LinearLayout> 

我檢查日誌,只有一個紅色標誌內,無法找到用於com.google.settings供應商信息。一切似乎都很好。我想知道爲什麼地圖是空的看?當你的地圖API密鑰已過期或沒有與調試簽名密鑰匹配

+0

你運行它在谷歌API模擬器? – Spencer

+0

免費發佈api密鑰是否安全?只是質疑。 – yoshi

+0

你可能想要把它取下來。 :/ – Spencer

回答

4

的MapView是空的。 嘗試生成一個新的。

0

每MapActivity內部,isRouteDisplayed()是必需的方法, 所以重寫此方法:

@覆蓋保護布爾isRouteDisplayed(){ 返回假; }

要求此方法從地圖服務的一些覈算 看,如果你正在顯示任何路由信息。在這種情況下 ,你沒有,那麼返回false。

來源:http://developer.android.com/resources/tutorials/views/hello-mapview.html

附加的android:layout_x="0px看起來有點冒險。我認爲它只用於AbsoluteLayouts,所以刪除它不應該有害。

0

請檢查日誌是否沒有得到「無法驗證從谷歌服務器錯誤」。如果是,那麼地圖密鑰有問題。 地圖的關鍵應該是產生在這裏你正在運行的應用程序相同的系統上。 還要檢查是否有谷歌發揮帳戶登錄和位置設置被啓用。

請點擊這裏瞭解更多詳情: https://developers.google.com/maps/documentation/android/start