【问题标题】:Google maps utility library IconGenerator setColor not working properlyGoogle 地图实用程序库 IconGenerator setColor 无法正常工作
【发布时间】:2022-01-09 21:50:13
【问题描述】:

我正在使用 Google 地图实用程序库为我的标记生成图标,但 setColor 不起作用,我设置的每种颜色都是不同的蓝色阴影,这不是我的颜色,而且它还有黑色到处乱跑,我不想要。

这是代码:

for (place in location.locations) {
                    val locationPoz = LatLng(place.lat, place.long)
                    boundsBuilder.include(locationPoz)

                    //Here is the icon part
                    val icon = IconGenerator(requireContext())
                    icon.setColor(R.color.red)
                    val fIcon = icon.makeIcon("${place.price}€")

                    val marker = MarkerOptions()
                        .position(locationPoz)
                        .title(place.name)
                        .icon(BitmapDescriptorFactory.fromBitmap(fIcon))
                        .alpha(5f)

                    googleMap.addMarker(marker)
                }

这就是我的地图的样子

【问题讨论】:

    标签: android kotlin google-maps icons


    【解决方案1】:

    我认为您只能使用https://googlemaps.github.io/android-maps-utils/javadoc/com/google/maps/android/ui/IconGenerator.html 中提供的值之一

    试试

    ~icon.setColor(IconGenerator.STYLE_RED)~

    编辑:我看错了,我想。 STYLE_* 值必须像这样使用 icon.setStyle(IconGenerator.STYLE_RED)

    这还不能解决您不想要的边框问题,因此,您需要使用 setBackground 提供自己的背景可绘制对象

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-26
    • 1970-01-01
    • 2023-01-25
    • 2016-09-28
    • 2021-01-13
    相关资源
    最近更新 更多