KNMapCameraUpdate
INFO
This English reference is based on Directions SDK 1.12.8-hotfix02. For the latest version, see the Korean reference.
Sets the map camera (user viewpoint), including its target position, zoom level, tilt, and bearing.
Use fitTo to adjust the camera position and zoom level so the specified map area fits within a target screen area.
Constructor
KNMapCameraUpdate()
Creates a KNMapCameraUpdate object with default values.
Example code — KNMapCameraUpdate()
fun createKNCameraUpdate(): KNMapCameraUpdate {
return KNMapCameraUpdate()
}
fun moveMap(withUserLocation: Boolean) {
mapView.moveCamera(createKNCameraUpdate(), withUserLocation)
}KNMapCameraUpdate.targetTo
Creates a KNMapCameraUpdate initialized with the specified KATEC coordinates.
Example code — KNMapCameraUpdate.targetTo:
fun positionWithKNMapCameraUpdate(coordinate: FloatPoint): KNMapCameraUpdate {
return KNMapCameraUpdate.targetTo(coordinate)
}
fun moveMap(withUserLocation: Boolean, isAnimate: Boolean) {
val coordinate = WGS84ToKATEC(127.11019081347423,37.3941851228957)
if (isAnimate) {
mapView.animateCamera(positionWithKNMapCameraUpdate(coordinate), 500L, withUserLocation)
} else {
mapView.moveCamera(positionWithKNMapCameraUpdate(coordinate), withUserLocation)
}
}KNMapCameraUpdate.targetTo( coordinate: FloatPoint ): KNMapCameraUpdateParameters
| Name | Description |
|---|---|
coordinate | KATEC coordinates of the location to move to |
KNMapCameraUpdate.zoomTo
Creates a KNMapCameraUpdate object initialized with the entered zoom level value. The range of zoom level settings follows the range set in setZoomRange of the KNMapView class.
Example code — KNMapCameraUpdate.zoomTo:
fun zoomWithKNMapCameraUpdate(zoom:Float): KNMapCameraUpdate {
return KNMapCameraUpdate.zoomTo(zoom)
}
fun zoomToWithMoveMap(withUserLocation: Boolean, isAnimate: Boolean, isZoomIn: Boolean) {
val coordinate = WGS84ToKATEC(127.11019081347423,37.3941851228957)
val zoom = if (isZoomIn) { mapView.zoom * .5f } else { mapView.zoom * 2f }
if (isAnimate) {
mapView.animateCamera(zoomWithKNMapCameraUpdate(zoom).targetTo(coordinate), 500L, withUserLocation)
} else {
mapView.moveCamera(zoomWithKNMapCameraUpdate(zoom).targetTo(coordinate), withUserLocation)
}
}KNMapCameraUpdate.zoomTo( zoom: Float ): KNMapCameraUpdateParameters
| Name | Description |
|---|---|
zoom | Zoom level to apply to the map |
KNMapCameraUpdate.tiltTo
Creates a KNMapCameraUpdate initialized with the specified tilt. (Tilt range: 0~50)
Example code — KNMapCameraUpdate.tiltTo:
fun tiltWithKNMapCameraUpdate(tilt:Float): KNMapCameraUpdate {
return KNMapCameraUpdate.tiltTo(tilt)
}
fun tiltWithMoveMap(withUserLocation: Boolean, isAnimate: Boolean, isBirdView: Boolean) {
val coordinate = WGS84ToKATEC(127.11019081347423,37.3941851228957)
val tilt = if (isBirdView) { 50f } else { 0f }
if (isAnimate) {
mapView.animateCamera(tiltWithKNMapCameraUpdate(tilt).targetTo(coordinate), 500L, withUserLocation)
} else {
mapView.moveCamera(tiltWithKNMapCameraUpdate(tilt).targetTo(coordinate), withUserLocation)
}
}KNMapCameraUpdate.tiltTo( tilt: Float ): KNMapCameraUpdateParameters
| Name | Description |
|---|---|
tilt | Screen tilt to apply to the map(Tilt setting range: 0~50) |
KNMapCameraUpdate.bearingTo
Creates a KNMapCameraUpdate object initialized with the input rotation value. (Rotation angle setting range: 0~360)
Example code — KNMapCameraUpdate.bearingTo:
fun bearingWithKNMapCameraUpdate(bearing:Float): KNMapCameraUpdate {
return KNMapCameraUpdate.bearingTo(bearing)
}
fun bearing45WithMoveMap(withUserLocation: Boolean, isAnimate: Boolean) {
val coordinate = WGS84ToKATEC(127.11019081347423,37.3941851228957)
val bearing = mapView.bearing + 45f // Set the rotation angle to 45
if (isAnimate) {
mapView.animateCamera(bearingWithKNMapCameraUpdate(bearing).targetTo(coordinate), 500L, withUserLocation)
} else {
mapView.moveCamera(bearingWithKNMapCameraUpdate(bearing).targetTo(coordinate), withUserLocation)
}
}KNMapCameraUpdate.bearingTo( bearing: Float ): KNMapCameraUpdateParameters
| Name | Description |
|---|---|
bearing | Rotation angle to apply to the map (rotation angle setting range: 0~360) |
KNMapCameraUpdate.anchorTo
Creates a KNMapCameraUpdate object initialized with the entered anchor value and sets the reference point for zoom, tilt, and rotation of the screen. The default is the exact center (0.5, 0.5), and the zoom level, tilt, and rotation direction are operated around the newly set reference point.
The values on the screen are displayed as (x-axis, y-axis), with the lower left corner being (0, 0) and the upper right corner being (1, 1). When moving to the right, the x-axis is +0.1, and when moving up, the y-axis is +0.1.
Example code — KNMapCameraUpdate.anchorTo:
fun anchorWithKNMapCameraUpdate(anchor:FloatPoint): KNMapCameraUpdate {
return KNMapCameraUpdate.anchorTo(anchor)
}
fun anchorToWithMoveMap(withUserLocation: Boolean, isAnimate: Boolean, isDownToAnchor: Boolean) {
val coordinate = WGS84ToKATEC(127.11019081347423,37.3941851228957)
val anchor = if (isDownToAnchor) { FloatPoint(0.5f, 0.8f) } else { FloatPoint(0.5f, 0.5f) }
if (isAnimate) {
mapView.animateCamera(anchorWithKNMapCameraUpdate(anchor).targetTo(coordinate), 500L, withUserLocation)
} else {
mapView.moveCamera(anchorWithKNMapCameraUpdate(anchor).targetTo(coordinate), withUserLocation)
}
}KNMapCameraUpdate.anchorTo( anchor: FloatPoint ): KNMapCameraUpdateParameters
| Name | Description |
|---|---|
anchor | Reference point (x-axis, y-axis), lower-left corner value (0, 0), upper-right corner value (1, 1) |
KNMapCameraUpdate.fitTo
Fits the coordinate area received from KNMapCoordinateRegion to the screen or to a specific rectangular area (RectF) within the screen. (If RectF is null, it applies to the entire map size)
KNMapCameraUpdate.fitTo( regionMap: KNMapCoordinateRegion,
fittingRect: RectF? = null ): KNMapCameraUpdateParameters
| Name | Description |
|---|---|
regionMap | Objects used to calculate the screen area, such as routes and markers |
fittingRect | Target screen area for the camera update |
Methods
targetTo
Moves the map camera to the specified KATEC coordinates.
Example code — targetTo:
fun positionWithKNMapCameraUpdate(coordinate: FloatPoint): KNMapCameraUpdate {
return KNMapCameraUpdate.targetTo(coordinate)
}
fun moveMap(withUserLocation: Boolean, isAnimate: Boolean) {
val coordinate = WGS84ToKATEC(127.11019081347423,37.3941851228957)
if (isAnimate) {
mapView.animateCamera(positionWithKNMapCameraUpdate(coordinate), 500L, withUserLocation)
} else {
mapView.moveCamera(positionWithKNMapCameraUpdate(coordinate), withUserLocation)
}
}fun targetTo( position: FloatPoint ): KNMapCameraUpdateParameters
| Name | Description |
|---|---|
position | KATEC coordinates of the location to move to |
zoomTo
Sets the zoom level around the current map position. (Zoom range: 0.1~2000)
Example code — zoomTo:
fun zoomWithKNMapCameraUpdate(zoom:Float): KNMapCameraUpdate {
return KNMapCameraUpdate().zoomTo(zoom)
}
fun zoomToWithMoveMap(withUserLocation: Boolean, isAnimate: Boolean, isZoomIn: Boolean) {
val coordinate = WGS84ToKATEC(127.11019081347423,37.3941851228957)
val zoom = if (isZoomIn) { mapView.zoom * .5f } else { mapView.zoom * 2f }
if (isAnimate) {
mapView.animateCamera(zoomWithKNMapCameraUpdate(zoom).targetTo(coordinate), 500L, withUserLocation)
} else {
mapView.moveCamera(zoomWithKNMapCameraUpdate(zoom).targetTo(coordinate), withUserLocation)
}
}fun zoomTo( zoom: Float ): KNMapCameraUpdateParameters
| Name | Description |
|---|---|
zoom | Zoom level to apply to the map(Zoom level setting range: 0.1~2000) |
tiltTo
Sets the screen tilt around the current map position. (Tilt range: 0~50)
Example code — tiltTo:
fun tiltWithKNMapCameraUpdate(tilt:Float): KNMapCameraUpdate {
return KNMapCameraUpdate().tiltTo(tilt)
}
fun tiltWithMoveMap(withUserLocation: Boolean, isAnimate: Boolean, isBirdView: Boolean) {
val coordinate = WGS84ToKATEC(127.11019081347423,37.3941851228957)
val tilt = if (isBirdView) { 50f } else { 0f }
if (isAnimate) {
mapView.animateCamera(tiltWithKNMapCameraUpdate(tilt).targetTo(coordinate), 500L, withUserLocation)
} else {
mapView.moveCamera(tiltWithKNMapCameraUpdate(tilt).targetTo(coordinate), withUserLocation)
}
}fun tiltTo( degree: Float ): KNMapCameraUpdateParameters
| Name | Description |
|---|---|
degree | Screen tilt to apply to the map(Tilt setting range: 0~50) |
bearingTo
Sets the bearing around the current map position. (Bearing range: 0~360)
Example code — bearingTo:
fun bearingWithKNMapCameraUpdate(bearing:Float): KNMapCameraUpdate {
return KNMapCameraUpdate().bearingTo(bearing)
}
fun bearing45WithMoveMap(withUserLocation: Boolean, isAnimate: Boolean) {
val coordinate = WGS84ToKATEC(127.11019081347423,37.3941851228957)
val bearing = mapView.bearing + 45f
if (isAnimate) {
mapView.animateCamera(bearingWithKNMapCameraUpdate(bearing).targetTo(coordinate), 500L, withUserLocation)
} else {
mapView.moveCamera(bearingWithKNMapCameraUpdate(bearing).targetTo(coordinate), withUserLocation)
}
}fun bearingTo( degree: Float ): KNMapCameraUpdateParameters
| Name | Description |
|---|---|
degree | Rotation angle to apply to the map (rotation angle setting range: 0~360) |
anchorTo
Sets the anchor for zoom, tilt, and rotation. The default is the screen center (0.5, 0.5).
The values on the screen are displayed as (x-axis, y-axis), with the lower left corner being (0, 0) and the upper right corner being (1, 1). When moving to the right, the x-axis is +0.1, and when moving up, the y-axis is +0.1.
Example code — anchorTo:
fun anchorWithKNMapCameraUpdate(anchor:FloatPoint): KNMapCameraUpdate {
return KNMapCameraUpdate().anchorTo(anchor)
}
fun anchorToWithMoveMap(withUserLocation: Boolean, isAnimate: Boolean, isDownToAnchor: Boolean) {
val coordinate = WGS84ToKATEC(127.11019081347423,37.3941851228957)
val anchor = if (isDownToAnchor) { FloatPoint(0.5f, 0.8f) } else { FloatPoint(0.5f, 0.5f)
}
if (isAnimate) {
mapView.animateCamera(anchorWithKNMapCameraUpdate(anchor).targetTo(coordinate), 500L, withUserLocation)
} else {
mapView.moveCamera(anchorWithKNMapCameraUpdate(anchor).targetTo(coordinate), withUserLocation)
}
}fun anchorTo( anchor: FloatPoint ): KNMapCameraUpdateParameters
| Name | Description |
|---|---|
anchor | Reference point (x-axis, y-axis), lower-left corner value (0, 0), upper-right corner value (1, 1) |
fitTo
Fits the coordinate area received from KNMapCoordinateRegion to the screen or to a specific rectangular area (RectF) within the screen. (If RectF is null, it applies to the entire map size)
fun fitTo( regionMap: KNMapCoordinateRegion,
fittingRect: RectF? = null ): KNMapCameraUpdateParameters
| Name | Description |
|---|---|
regionMap | Objects used to calculate the screen area, such as routes and markers |
fittingRect | Target screen area for the camera update |