Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Centering bitmap Marker (Google Maps Android API v2)

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. "