79526302

Date: 2025-03-21 18:16:27
Score: 3
Natty:
Report link

@kfir I'm working Kotlin so below is the converted code - took me a while because of the nullable variables. This works but it zooms to exactly the same level as setLinearZoom() in my original code - absolutely no difference. Really unclear as to why there are two ways to do exactly the same thing.

val P = zoomSliderPos * 100f // my slider value was already in the 0.0 - 1.0 range so this corrects it for your code

val minZoom = controller.cameraInfo?.zoomState?.value?.minZoomRatio
val maxZoom = controller.cameraInfo?.zoomState?.value?.maxZoomRatio
Log.d(TAG, "minZoom and maxZoom: $minZoom - $maxZoom")

if (minZoom != null && maxZoom != null) {

  val translatedValue = Math.pow((maxZoom / minZoom).toDouble(), (P / 100f).toDouble()).toFloat() * minZoom

  Log.d("translatedValue", "translatedValue: $translatedValue")

  controller.cameraControl?.setZoomRatio(translatedValue)
}
Reasons:
  • Blacklisted phrase (1): to do exactly the same
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @I'm
  • Self-answer (0.5):
  • Looks like a comment (1):
  • Low reputation (0.5):
Posted by: garrettlynchirl