如何使 google 地图中的图像图钉与位置中心对齐而不是底部对齐 Android

How do I make an image pin in google maps center align with the location rather than bottom align in Android

我正在制作一个 android 应用程序并且我有一个图像标记(一个圆圈)。当它在地图上时,圆圈的底部与位置对齐,而不是圆圈的中心。我该如何解决这个问题?

mMap!!.addMarker(
                MarkerOptions().position(LatLng(location!!.latitude, location!!.longitude)).title("Me").snippet("My Location").icon(
                    BitmapDescriptorFactory.fromResource(R.drawable.circle)
                )
            )

可以通过这个参数定位:

.anchor(x, y)

用法示例:

googleMap.addMarker(new MarkerOptions()
                    .position(new LatLng(latitude, longitude))
                    .anchor(0.5f, 1.0f)
                    .title("title")
                    .snippet("snippet"));