【问题标题】:How do I make an image pin in google maps center align with the location rather than bottom align in Android如何使谷歌地图中心的图像引脚与位置对齐,而不是在 Android 中底部对齐
【发布时间】:2019-06-26 02:30:42
【问题描述】:

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

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

【问题讨论】:

标签: android google-maps google-maps-markers


【解决方案1】:

你可以用这个参数定位:

.anchor(x, y)

示例用法:

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

【讨论】:

  • 中心应该是 .anchor(0.5f, 0.5f) 但谢谢
猜你喜欢
  • 2016-07-23
  • 2017-02-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多