对于ItemizedOverlay中的标记,必须使用boundCenter()/ boundCenterBottom()吗?

时间:2011-03-25 12:57:40

标签: android android-maps

除非您在默认标记上调用ItemizedOverlayboundCenter(),否则boundCenterBottom()中的标记似乎不会显示在地图中。

这是正确的,如果是的话,为什么?是否默认情况下根本没有设置(0,0)点,因此Android不知道如何放置标记?

更新

我看到你也有Drawable.setBounds(),所以我假设boundCenter()boundCenterBottom()正在调用这个方法。如何确定Drawable的哪个部分用作地图上的引脚点?

2 个答案:

答案 0 :(得分:3)

请参阅this example了解如何使用boundCenter()

我相信bindCenter()调用工作,你的Drawable应该有一些固有的宽度和高度。我猜这有点像这样:

public static Drawable boundCenter(Drawable d)
{
     d.setBounds(d.getIntrinsicWidth() /- 2, d.getIntrinsicHeight() / -2,
                 d.getIntrinsicWidth / 2, d.getIntrinsicHeight() / 2);
     return d;
}

将顶部/左侧边界偏移到底部/中心。

答案 1 :(得分:0)

如果希望它们出现,您必须以某种方式设置BOUNDS。使用哪种方法并不重要,但如果你的drawable没有边界,它的边界是0,0,0,0或类似的东西,你什么也看不见。