Я обнаружил, что MarkerOptions.anchor() может помочь, поэтому попробовал его с разными значениями. Когда я изменил значения, я понял, что маркер движется в других направлениях.
Вот мой код:
Код: Выделить всё
override fun onMapReady(googleMap: GoogleMap) {
map = googleMap
val startpoint = LatLng(lat, lng)
val option = MarkerOptions().position(startpoint).title(title).icon(bitMapFromVector(R.drawable.baseline_flag_24))
map.addMarker(option)
map.moveCamera(CameraUpdateFactory.newLatLngZoom(startpoint, 15F))
}
private fun bitMapFromVector(vectorResID:Int): BitmapDescriptor {
val vectorDrawable =ContextCompat.getDrawable(requireContext(),vectorResID)
vectorDrawable!!.setBounds(0,0, vectorDrawable.intrinsicWidth,vectorDrawable.intrinsicHeight)
val bitmap = Bitmap.createBitmap(vectorDrawable.intrinsicWidth,vectorDrawable.intrinsicHeight,Bitmap.Config.ARGB_8888)
val canvas = Canvas(bitmap)
vectorDrawable.draw(canvas)
return BitmapDescriptorFactory.fromBitmap(bitmap)
}
Базовый флаг Android
Согласно к этой документации https://developers.google.com/android/r ... 20float%29
Я так и думал
Код: Выделить всё
.anchor(0.0f, 1.0f)
Есть ли у вас идеи, как я могу остановить это или как найти правильные значения привязки?
Подробнее здесь: https://stackoverflow.com/questions/790 ... r-for-icon
Мобильная версия