2013-04-21 162 views
0

我想加載谷歌地圖。我使用<uses-library android:name="com.google.android.maps" />庫,這是MapView的xml。谷歌地圖不顯示

<?xml version="1.0" encoding="utf-8"?> 
    <com.google.android.maps.MapView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/mapView" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:clickable="true" 
    android:apiKey="AIzaSyDvTjB5XuzifATB4G50qBc7TTRo5luhV9o" 
    /> 

我的活動來延長MapActivity as public class Geofencesetup extends MapActivity {}。但是當我運行的代碼,我只拿到了小小的格子,看不到地圖。 我的應用程序有兩個個XML,一個具有片段另一個地圖顯示應用程序,遵循

<fragment 
     android:id="@+id/map" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     class="com.google.android.gms.maps.SupportMapFragment" /> 

我想在MapView的添加,因爲它是使覆蓋地理圍欄設置更好。對於片段,我可以看到整個地圖,但對於MapView,我只能看到網格。 我的查詢是 (1)我可以在同一個應用程序中使用com.google.android.gms.maps.SupportMapFragmentcom.google.android.maps.MapView嗎? (2)爲什麼我只能在MapView中看到網格? 謝謝

回答

0

據我所知,不可能在同一個應用程序中使用這兩個API。即使你可以這樣做,那麼你不能使用Google Map API V1與它的MapViewMapActivity對象,因爲這個API已被谷歌棄用,你不能得到一個新的API鍵。這可能是你看到的只是網格而不是地圖的原因。

因此,我們鼓勵並推薦將您的應用程序移至僅使用Google Maps API V2

+0

謝謝,如果像這樣如何在GoogleMap上疊加。我無法在GoogleMap地圖上找到getOverlays()API; – Bryanyan 2013-04-21 14:27:13

+0

很抱歉,此選項在Google Maps API V2中不可用。要在地圖上繪製線條,您應該使用Polyline對象。 – 2013-04-21 14:28:07

+0

如何使用Overlay在GoogleMap上實現用戶界面?當用戶觸摸矩形的一個角的地圖上的一個點並且用戶拖動並釋放時。用戶觸摸地圖的最後一點是矩形的另一個角落。該矩形是用半透明顏色繪製的。這可以使用MapView輕鬆實現。如何在Google Maps API V2上實施。任何想法?謝謝。 – Bryanyan 2013-04-21 14:32:03