2012-01-30 109 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

相关问题