2014-02-14 10 views
0

請問誰能告訴我是否有可能使用谷歌地圖api的功能(如聚焦和放大)而不是在地圖上,而是在用戶定義的圖像上(以.png或.png格式)。 jpeg格式)。如果是的話,該怎麼做?我一直在Google上搜索幾天,但我無法得到我的問題的確切答案。對不起,因爲很傻,但我是編程新手。希望有人能幫助我。Google maps api on用戶自定義圖像

+0

是的,我們能做到這一點? – Namy

+0

是否在你的xml中定義了你的圖片? 可以與我們分享您的xml嗎? – Namy

+0

沒有..我的意思是考慮一個正常的jpeg圖像(說別人的照片),我們可以在該圖像上應用谷歌地圖功能 – user2207125

回答

0

XML: -

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

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

    <RelativeLayout 
     android:id="@+id/relative_map" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentRight="true" 
     android:layout_marginBottom="45dp" 
     android:layout_marginRight="20dp" > 

     <ImageView 
      android:id="@+id/btn_zoom_in" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/btn_zoom_in" /> 

     <ImageView 
      android:id="@+id/btn_zoom_out" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_below="@+id/btn_location" 
      android:src="@drawable/btn_zoom_out" /> 

     <ImageView 
      android:id="@+id/btn_location" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_below="@+id/btn_zoom_in" 
      android:src="@drawable/btn_location" /> 
    </RelativeLayout> 

</RelativeLayout> 

你的活動: -

@Override 
public void onClick(View v) { 
    switch (v.getId()) { 
    case R.id.btn_location: 
     map.animateCamera(CameraUpdateFactory.newLatLng(new LatLng(location 
       .getLatitude(), location.getLongitude()))); 
     break; 
    case R.id.btn_zoom_in: 
     map.animateCamera(CameraUpdateFactory.zoomIn()); 
     break; 
    case R.id.btn_zoom_out: 
     map.animateCamera(CameraUpdateFactory.zoomOut()); 
     break; 

    default: 
     break; 
    } 
} 

我希望能解決你的問題.... :)

+0

感謝您的信息。我會試試看。但是當我說你點擊我的圖片時,我不明白你的意思。你能解釋一下嗎?正如我已經說過,我是編程新手:( – user2207125

+0

親愛的寫這個onClick方法.... – Namy

+0

看到我的更新的答案... – Namy

相關問題