It seems that markers in an ItemizedOverlay
are not shown in the map unless you call boundCenter()
or boundCenterBottom()
on the default marker.
Is this correct, and if so, why? Is it that a (0,0) point is not set at all by default, and thus Android has no idea how to place the markers?
Update:
I see that you also have Drawable.setBounds(), so I 开发者_JS百科assume boundCenter()
and boundCenterBottom()
is calling this method. How is it decided which part of the Drawable is used as the pin point on the map?
See this example of how to use the boundCenter()
I believe for the boundCenter() call to work, your Drawable should have some intrinsic width and height. I'm guessing it works something like this:
public static Drawable boundCenter(Drawable d)
{
d.setBounds(d.getIntrinsicWidth() /- 2, d.getIntrinsicHeight() / -2,
d.getIntrinsicWidth / 2, d.getIntrinsicHeight() / 2);
return d;
}
This offsets the bounds from Top/Left, to Bottom/Center.
You must set the BOUNDS in some fashion if you wish them to appear. It doesn't matter which method you use, but if there are no bounds on your drawable, its bounds are 0,0,0,0 or something like that, and you will see nothing.
精彩评论