Centering bitmap Marker (Google Maps Android API v2)

前端 未结 2 524
误落风尘
误落风尘 2021-02-01 12:19

When I add a marker from a custom Bitmap, the marker is not centered at the point I specify.

I\'m adding it like this:

    // ID tramo
    final int tram         


        
相关标签:
2条回答
  • 2021-02-01 12:55

    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.

    0 讨论(0)
  • 2021-02-01 13:01

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

    0 讨论(0)
提交回复
热议问题