Moving the center point
Use the anchorTo (KO) function of the KNMapCameraUpdate (KO) class to move the center point of the screen. Adjust the value from the exact center (0.5, 0.5) to move the center point. Screen values are expressed as (x-axis, y-axis), where the bottom-left corner is (0, 0) and the top-right corner is (1, 1). To move to the right, add 0.1 to the x-axis; to move upward, add 0.1 to the y-axis.
private fun moveAnchor() {
mapView.animateCamera(if (mapView.anchor.y == 0.5f) {
KNMapCameraUpdate.anchorTo(FloatPoint(0.5f, 0.8f))
} else {
KNMapCameraUpdate.anchorTo(FloatPoint(0.5f, 0.5f))
}, animTime, false)
}Zooming in
Use the zoomTo (KO) function of the KNMapCameraUpdate (KO) class to zoom in on the screen.
private fun zoomIn() {
mapView.animateCamera(KNMapCameraUpdate.zoomTo( mapView.zoom * .5f), animTime, false)
}Zooming out
Use the zoomTo (KO) function of the KNMapCameraUpdate (KO) class to zoom out of the screen.
private fun zoomOut() {
mapView.animateCamera(KNMapCameraUpdate.zoomTo( mapView.zoom * 2f), animTime, false)
}Switching to bird's eye view
Use the tiltTo (KO) function of the KNMapCameraUpdate (KO) class to set a bird's eye view screen that gives a sense of perspective and depth.
private fun birdView() {
if (mapView.tilt == 50f) return
mapView.animateCamera(KNMapCameraUpdate.tiltTo(50f), animTime, false)
}Switching to top view
Use the tiltTo (KO) function of the KNMapCameraUpdate (KO) class to set a top view screen that looks down on the map as a flat plane.
private fun topView() {
if (mapView.tilt == 0f) return
mapView.animateCamera(KNMapCameraUpdate.tiltTo(0f), animTime, false)
}Rotating the map
Use the bearingTo (KO) function of the KNMapCameraUpdate (KO) class to rotate the map by the angle you set. The rotation can be set within a range of 0 to 360, and the map rotates around its current position.
private fun rotate() {
mapView.animateCamera(KNMapCameraUpdate.bearingTo(mapView.bearing + 45f % 360f), animTime, false)
}