我正在使用 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)
}
這就是我的地圖的樣子

uj5u.com熱心網友回復:
我認為您只能使用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
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/373647.html
