2012-01-30 111 views
1

如何在MapView中間放置圖釘,以便我們可以移動導航位置到該圖釘來選擇該位置。如何在MapView上放置不隨地圖移動的圖釘?

+0

不知道我理解的問題。你想在地圖上貼一個圖釘,然後當地圖滾動時自動移動這個圖釘,這樣這個圖釘在屏幕上的相同位置始終可見? – 2012-01-30 11:56:31

+1

@AleksG:是的。 – Akram 2012-01-30 11:58:19

+0

在地圖上添加視圖嗎?首先使用 – Warpzit 2012-01-30 12:03:28

回答

3

有很多方法可以實現此目的。

  1. 您可以添加的MapView和圖釘(圖像視圖)相對佈局,並在父母推銷中心的設置屬性,在點擊圖釘計算地圖的中點,並相應地工作。

  2. 計算MapView的中心點,並在該點上添加疊加層。覆蓋觸摸事件和onKeyUp事件,重新計算中點,並重繪覆蓋。

+1

希望它能起作用。 – Akram 2012-01-30 12:10:25

+0

第一種方法效果很好,不能在這裏放置佈局xml,所以把它放在下一個答案 - 以防萬一任何人想看到它。 – 2012-05-11 00:24:13

1

要在截拳道的1月30日答覆擴大,這裏的一些佈局XML做的第一個方法 - 我相信這是更容易,會更好看,比移動第二個建議順暢。

很簡單,但也許會救一個人幾分鐘:

<RelativeLayout ...> 

    <com.google.android.maps.MapView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     ... /> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" > 

     <ImageView 
      android:id="@+id/map_location_label" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerInParent="true" 
      android:src="@drawable/map_location_pin" /> 
    </RelativeLayout> 
</RelativeLayout> 
+0

偉大的,正是我所做的。將很快發佈第二部分。+ 1 – Akram 2012-05-11 13:15:53

相關問題