使用设置范围在Google Android Maps API v2上映射标记

时间:2013-08-12 13:31:33

标签: android google-maps bounds

在APIv1中,我正在绘制这样的标记:

    Drawable flag = getResources().getDrawable(R.drawable.flagfinish);
    flag.setBounds(0, -flag.getIntrinsicHeight(), flag.getIntrinsicWidth(), 0);

它正在工作 - 图片左下角位于LatLng的中心。但是我如何在APIv2中绘制这样的东西呢?我试过这个:

Marker hc = mMap.addMarker(new MarkerOptions()
        .position(HC)
        .title("Hlohovec")
        .snippet("Hlohovec")
        .icon(BitmapDescriptorFactory.fromResource(R.drawable.flagfinish)));

但是这是向左移动的(我想在左边画一个带有杆子的旗子,这样就不会把它钉在我想要的地方)。

有没有办法做到这一点?我不想使用GroundOverlayOptions因为它正在随着缩放而改变。

感谢您的回答。

1 个答案:

答案 0 :(得分:3)

创建标记时需要更改标记图像的Anchor位置

来自文档:

The point on the image that will be placed at the LatLng position of the marker. This defaults to the middle of the bottom of the image.