2

In APIv1 I was drawing markers like this:

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

and it was working - left bottom corner of picture was in center of LatLng. But how could I draw something like this in APIv2? I tried this:

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

but this is moved to left (I want to draw a flag with pole on left so this doesn't pin it where I want).

Is there any possible way to do this? And I don't want to use GroundOverlayOptions because it is changing with zoom.

Thanks for any answers.

Tunerx
  • 619
  • 9
  • 21

1 Answers1

3

you need to change the Anchor position of the marker image when you create the marker

from the docs:

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.

tyczj
  • 71,600
  • 54
  • 194
  • 296
  • Thank You very much! Exactly what I was looking for. For complete information if needed: left bottom corner of image -> `.anchor(0, 1)` – Tunerx Aug 12 '13 at 13:46
  • 2
    @Tunerx Note that you will have an issue like [Issue 5131](http://code.google.com/p/gmaps-api-issues/issues/detail?id=5131) if you use info window. – MaciejGórski Aug 12 '13 at 15:15
  • thanks, the problem is there... but it is not that big an issue, it doesn't look very bad with my icons :) – Tunerx Aug 13 '13 at 06:24