Centering bitmap Marker (Google Maps Android API v2)

别来无恙 提交于 2019-12-02 18:42:00

Simply set anchor point for you marker to 0.5 and 0.5 (middle of your icon).

...
MarkerOptions m = new MarkerOptions();
m.anchor(0.5f, 0.5f);
...

The default anchor value is (0.5f, 1.0f). You can read about marker here.

If you use Marker you'll need to respecify the Anchor in order to center your image. As the documentation says : "Anchor : The point on the image that will be placed at the LatLng position of the marker. This defaults to 50% from the left of the image and at the bottom of the image.".

You should maybe consider using GroundOverlay instead of Marker if you want the image to be centered by default. See GroundOverlay, "The anchor is by default 50% from the top of the image and 50% from the left of the image. "

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!