KNMapImage (Deprecated)
INFO
This English reference is based on Directions SDK 1.12.8-hotfix02. For the latest version, see the Korean reference.
Stores the information needed to render a map image. The resulting image adjusts its zoom level and position to fit the specified elements on screen.
Properties
| Name | Description | Type |
|---|---|---|
isVisibleTraffic | Whether traffic information is displayed on the map (default: false) | var isVisibleTraffic: Boolean |
isVisibleBuilding | Whether buildings are displayed on the map (default: true) | var isVisibleBuilding: Boolean |
isVisiblePOI | Whether POI icons are displayed on the map (default: true) | var isVisiblePOI: Boolean |
coordinate (readOnly) | KATEC coordinates of the map position set by moveCamera. Changes to this read-only value are not applied. | var coordinate: FloatPoint |
anchor (readOnly) | Screen coordinates of the map position set by moveCamera. Values range from (0, 0) at the upper-left corner to (1, 1) at the lower-right corner. Changes to this read-only value are not applied. | var anchor: FloatPoint |
bearing (readOnly) | Bearing set by moveCamera, in degrees | var bearing: Float |
zoom (readOnly) | Zoom level set by moveCamera. A larger value zooms in. | var zoom: Float |
tilt (readOnly) | Tilt set by moveCamera, in degrees | var tilt: Float |
mapTheme | Map theme (colors, day/night mode, and so on) | var mapTheme: KNMapTheme? |
imageSize | Size of map image | var imageSize: RectF |
routeTheme | Theme of the path (path thickness, color, etc.) | var routeTheme: KNMapRouteTheme? |
Constructor
TIP
The KNMapImage class must be created through KNSDK.
KNSDK.mapImageByActivityWithSize()
Creates a KNMapImage object set to initial values. The size value you enter determines the size of the image when creating it using the generateMapWithCompletion function.
TIP
The activity argument is the context needed to create the image of the map.
Example code — KNSDK.mapImageByActivityWithSize()
fun createMapImage(): KNMapImage? {
return KNSDK.mapImageByActivityWithSize(
activity,
KNMapTheme.driveNight(),
RectF(0f, 0f, 500f, 500f),
// minRect: Value used when the size cannot be measured correctly due to a coordinateLayout bug that returns abnormal height/width values
RectF(0f, 0f, 500f, 500f))
}KNSDK.mapImageByViewWithSize()
Creates a KNMapImage object set to initial values. The size value you enter determines the size of the image when creating it using the generateMapWithCompletion function.
TIP
The view argument is used to extract the context needed when creating a map image.
Example code — KNSDK.mapImageByViewWithSize()
fun createMapImage(): KNMapImage? {
return KNSDK.mapImageByViewWithSize(
// contentView
view,
KNMapTheme.driveNight(),
RectF(0f, 0f, 500f, 500f),
// minRect: Value used when the size cannot be measured correctly due to a coordinateLayout bug that returns abnormal height/width values
RectF(0f, 0f, 500f, 500f))
}Methods
setRoute
Sets a route on the map.
Example code — setRoute
fun createMapImage(): KNMapImage? {
return KNSDK.mapImageByViewWithSize(
// contentView
view,
KNMapTheme.driveNight(),
RectF(0f, 0f, 500f, 500f),
// minRect: Value used when the size cannot be measured correctly due to a coordinateLayout bug that returns abnormal height/width values
RectF(0f, 0f, 500f, 500f))
}
fun settingRouteWithImageMap(route: KNRoute) {
createMapImage()?.setRoute(route)
}fun setRoute( route: KNRoute )Parameters
| Name | Description |
|---|---|
route | path |
setRoutes
Receives a route list and Sets a route on the map.
Example code — setRoutes
fun createMapImage(): KNMapImage? {
return KNSDK.mapImageByViewWithSize(
// contentView
view,
KNMapTheme.driveNight(),
RectF(0f, 0f, 500f, 500f),
// minRect: Value used when the size cannot be measured correctly due to a coordinateLayout bug that returns abnormal height/width values
RectF(0f, 0f, 500f, 500f))
}
fun settingRouteWithImageMap(routes: List) {
createMapImage()?.setRoutes(routes)
}fun setRoutes( routes: List<KNRoute> )Parameters
| Name | Description |
|---|---|
routes | route list |
getRoutes()
Returns the list of all routes set on the map.
Example code — getRoutes():
fun createMapImage(route: List): KNMapImage? {
return KNSDK.mapImageByViewWithSize(
// contentView
view,
KNMapTheme.driveNight(),
RectF(0f, 0f, 500f, 500f),
// minRect: Value used when the size cannot be measured correctly due to a coordinateLayout bug (when abnormal height/width values are returned)
RectF(0f, 0f, 500f, 500f))?.apply {
setRoutes(route)
}
}
fun getRouteWithImageMap(routes: List): List {
return createMapImage(routes)?.getRoutes() ?: emptyList()
}fun getRoutes(): List<KNRoute>removeRoutesAll()
Deletes all routes registered on the map.
Example code — removeRoutesAll()
fun createMapImage(route: List): KNMapImage? {
return KNSDK.mapImageByViewWithSize(
// contentView
view,
KNMapTheme.driveNight(),
RectF(0f, 0f, 500f, 500f),
// minRect: Value used when the size cannot be measured correctly due to a coordinateLayout bug (when abnormal height/width values are returned)
RectF(0f, 0f, 500f, 500f))?.apply {
setRoutes(route)
}
}
fun removeRouteWithImageMap(routes: List) {
createMapImage(routes)?.removeRoutesAll()
}fun removeRoutesAll()cullPassedRoute
Cut the portion of the path taken by the user using the user location information entered. The starting position of the path is relative to KNLocation.
Example code — cullPassedRoute
fun createMapImage(route: List): KNMapImage? {
return KNSDK.mapImageByViewWithSize(
// contentView
view,
KNMapTheme.driveNight(),
RectF(0f, 0f, 500f, 500f),
// minRect: Value used when the size cannot be measured correctly due to a coordinateLayout bug that returns abnormal height/width values
RectF(0f, 0f, 500f, 500f))?.apply {
setRoutes(route)
}
}
fun cullingRouteWithImageMap(routes: List, cullLocation: KNLocation) {
createMapImage(routes)?.cullPassedRoute(cullLocation)
}fun cullPassedRoute( guideLocation: KNLocation )Parameters
| Name | Description |
|---|---|
guideLocation | Location information |
addMarker
Adds a marker to the map.
Example code — addMarker
fun createMapImage(): KNMapImage? {
return KNSDK.mapImageByViewWithSize(
// contentView
view,
KNMapTheme.driveNight(),
RectF(0f, 0f, 500f, 500f),
// minRect: Value used when the size cannot be measured correctly due to a coordinateLayout bug that returns abnormal height/width values
RectF(0f, 0f, 500f, 500f))
}
fun addMarkerWithImageMap(marker: KNMapMarker) {
createMapImage()?.addMarker(marker)
}fun addMarker( marker: KNMapMarker )Parameters
| Name | Description |
|---|---|
marker | Marker to add |
addMarkers
Adds a marker list to the map.
Example code — addMarkers
fun createMapImage(): KNMapImage? {
return KNSDK.mapImageByViewWithSize(
// contentView
view,
KNMapTheme.driveNight(),
RectF(0f, 0f, 500f, 500f),
// minRect: Value used when the size cannot be measured correctly due to a coordinateLayout bug that returns abnormal height/width values
RectF(0f, 0f, 500f, 500f))
}
fun addMarkerWithImageMap(markers: List) {
createMapImage()?.addMarkers(markers)
}fun addMarkers( markers: List<KNMapMarker> )Parameters
| Name | Description |
|---|---|
markers | Markers to add |
removeMarker
Removes a marker from the map.
Example code — removeMarker
fun createMapImage(): KNMapImage? {
return KNSDK.mapImageByViewWithSize(
// contentView
view,
KNMapTheme.driveNight(),
RectF(0f, 0f, 500f, 500f),
// minRect: Value used when the size cannot be measured correctly due to a coordinateLayout bug that returns abnormal height/width values
RectF(0f, 0f, 500f, 500f))
}
fun removeMarkerWithImageMap(marker: KNMapMarker) {
createMapImage()?.removeMarker(marker)
}fun removeMarker( marker: KNMapMarker )Parameters
| Name | Description |
|---|---|
marker | Marker to remove |
removeMarkersAll()
Removes all markers added to the map.
Example code — removeMarkersAll()
fun createMapImage(): KNMapImage? {
return KNSDK.mapImageByViewWithSize(
// contentView
view,
KNMapTheme.driveNight(),
RectF(0f, 0f, 500f, 500f),
// minRect: Value used when the size cannot be measured correctly due to a coordinateLayout bug that returns abnormal height/width values
RectF(0f, 0f, 500f, 500f))
}
fun removeMarkersAllWithImageMap() {
createMapImage()?.removeMarkersAll()
}fun removeMarkersAll()getMarkers()
Returns the list of markers added to the map. Returns an empty list if there are none.
Example code — getMarkers():
fun createMapImage(): KNMapImage? {
return KNSDK.mapImageByViewWithSize(
// contentView
view,
KNMapTheme.driveNight(),
RectF(0f, 0f, 500f, 500f),
// minRect: Value used when the size cannot be measured correctly due to a coordinateLayout bug that returns abnormal height/width values
RectF(0f, 0f, 500f, 500f))
}
fun getMarkersWithImageMap(): List {
return createMapImage()?.getMarkers() ?: emptyList()
}fun getMarkers(): List<KNMapMarker>addCircle
Adds a circle to the map.
Example code — addCircle
fun createMapImage(): KNMapImage? {
return KNSDK.mapImageByViewWithSize(
// contentView
view,
KNMapTheme.driveNight(),
RectF(0f, 0f, 500f, 500f),
// minRect: Value used when the size cannot be measured correctly due to a coordinateLayout bug that returns abnormal height/width values
RectF(0f, 0f, 500f, 500f))
}
fun addCircleWithImageMap(circle: KNMapCircle) {
createMapImage()?.addCircle(circle)
}fun addCircle( circle: KNMapCircle )Parameters
| Name | Description |
|---|---|
circle | won |
removeCircle
Removes a circle from the map.
Example code — removeCircle
fun createMapImage(): KNMapImage? {
return KNSDK.mapImageByViewWithSize(
// contentView
view,
KNMapTheme.driveNight(),
RectF(0f, 0f, 500f, 500f),
// minRect: Value used when the size cannot be measured correctly due to a coordinateLayout bug that returns abnormal height/width values
RectF(0f, 0f, 500f, 500f))
}
fun removeCircleWithImageMap(circle: KNMapCircle) {
createMapImage()?.removeCircle(circle)
}fun removeCircle( circle: KNMapCircle )Parameters
| Name | Description |
|---|---|
circle | won |
removeCirclesAll()
Removes all circles added to the map.
Example code — removeCirclesAll()
fun createMapImage(): KNMapImage? {
return KNSDK.mapImageByViewWithSize(
// contentView
view,
KNMapTheme.driveNight(),
RectF(0f, 0f, 500f, 500f),
// minRect: Value used when the size cannot be measured correctly due to a coordinateLayout bug that returns abnormal height/width values
RectF(0f, 0f, 500f, 500f))
}
fun removeCirclesAllWithImageMap() {
createMapImage()?.removeCirclesAll()
}fun removeCirclesAll()getCircles()
Returns the list of circles added to the map. Returns an empty list if there are none.
Example code — getCircles():
fun createMapImage(): KNMapImage? {
return KNSDK.mapImageByViewWithSize(
// contentView
view,
KNMapTheme.driveNight(),
RectF(0f, 0f, 500f, 500f),
// minRect: Value used when the size cannot be measured correctly due to a coordinateLayout bug that returns abnormal height/width values
RectF(0f, 0f, 500f, 500f))
}
fun getCirclesWithImageMap(): List {
return createMapImage()?.getCircles() ?: emptyList()
}fun getCircles(): List<KNMapCircle>addPolyline
Adds a polyline to the map.
Example code — addPolyline
fun createMapImage(): KNMapImage? {
return KNSDK.mapImageByViewWithSize(
// contentView
view,
KNMapTheme.driveNight(),
RectF(0f, 0f, 500f, 500f),
// minRect: Value used when the size cannot be measured correctly due to a coordinateLayout bug that returns abnormal height/width values
RectF(0f, 0f, 500f, 500f))
}
fun addPolylineWithImageMap(polyline: KNMapPolyline) {
createMapImage()?.addPolyline(polyline)
}fun addPolyline( polyline: KNMapPolyline )Parameters
| Name | Description |
|---|---|
polyline | Polyline |
removePolyline
Removes a polyline from the map.
Example code — removePolyline
fun createMapImage(): KNMapImage? {
return KNSDK.mapImageByViewWithSize(
// contentView
view,
KNMapTheme.driveNight(),
RectF(0f, 0f, 500f, 500f),
// minRect: Value used when the size cannot be measured correctly due to a coordinateLayout bug that returns abnormal height/width values
RectF(0f, 0f, 500f, 500f))
}
fun removePolylineWithImageMap(polyline: KNMapPolyline) {
createMapImage()?.removePolyline(polyline)
}fun removePolyline( polyline: KNMapPolyline )Parameters
| Name | Description |
|---|---|
polyline | Polyline |
removePolylinesAll()
Removes all polylines added to the map.
Example code — removePolylinesAll()
fun createMapImage(): KNMapImage? {
return KNSDK.mapImageByViewWithSize(
// contentView
view,
KNMapTheme.driveNight(),
RectF(0f, 0f, 500f, 500f),
// minRect: Value used when the size cannot be measured correctly due to a coordinateLayout bug that returns abnormal height/width values
RectF(0f, 0f, 500f, 500f))
}
fun removePolylinesAllWithImageMap() {
createMapImage()?.removePolylinesAll()
}fun removePolylinesAll()getPolylines()
Returns the list of polylines added to the map. Returns an empty list if there are none.
Example code — getPolylines():
fun createMapImage(): KNMapImage? {
return KNSDK.mapImageByViewWithSize(
// contentView
view,
KNMapTheme.driveNight(),
RectF(0f, 0f, 500f, 500f),
// minRect: Value used when the size cannot be measured correctly due to a coordinateLayout bug that returns abnormal height/width values
RectF(0f, 0f, 500f, 500f))
}
fun getPolylinesWithImageMap(): List {
return createMapImage()?.getPolylines() ?: emptyList()
}fun getPolylines(): List<KNMapPolyline>addPolygon
Adds a polygon to the map.
Example code — addPolygon
fun createMapImage(): KNMapImage? {
return KNSDK.mapImageByViewWithSize(
// contentView
view,
KNMapTheme.driveNight(),
RectF(0f, 0f, 500f, 500f),
// minRect: Value used when the size cannot be measured correctly due to a coordinateLayout bug that returns abnormal height/width values
RectF(0f, 0f, 500f, 500f))
}
fun addPolygonWithImageMap(polygon: KNMapPolygon) {
createMapImage()?.addPolygon(polygon)
}fun addPolygon( polygon: KNMapPolygon )Parameters
| Name | Description |
|---|---|
polygon | Polygon to add |
removePolygon
Removes a polygon from the map.
Example code — removePolygon
fun createMapImage(): KNMapImage? {
return KNSDK.mapImageByViewWithSize(
// contentView
view,
KNMapTheme.driveNight(),
RectF(0f, 0f, 500f, 500f),
// minRect: Value used when the size cannot be measured correctly due to a coordinateLayout bug that returns abnormal height/width values
RectF(0f, 0f, 500f, 500f))
}
fun removePolygonWithImageMap(polygon: KNMapPolygon) {
createMapImage()?.removeMarker(polygon)
}fun removePolygon( polygon: KNMapPolygon )Parameters
| Name | Description |
|---|---|
polygon | Polygon to remove |
removePolygonsAll()
Removes all polygons added to the map.
Example code — removePolygonsAll()
fun createMapImage(): KNMapImage? {
return KNSDK.mapImageByViewWithSize(
// contentView
view,
KNMapTheme.driveNight(),
RectF(0f, 0f, 500f, 500f),
// minRect: Value used when the size cannot be measured correctly due to a coordinateLayout bug that returns abnormal height/width values
RectF(0f, 0f, 500f, 500f))
}
fun removePolygonsAllWithImageMap() {
createMapImage()?.removePolygonsAll()
}fun removePolygonsAll()getPolygons()
Returns the list of polygons added to the map. Returns an empty list if there are none.
Example code — getPolygons():
fun createMapImage(): KNMapImage? {
return KNSDK.mapImageByViewWithSize(
// contentView
view,
KNMapTheme.driveNight(),
RectF(0f, 0f, 500f, 500f),
// minRect: Value used when the size cannot be measured correctly due to a coordinateLayout bug that returns abnormal height/width values
RectF(0f, 0f, 500f, 500f))
}
fun getPolygonsWithImageMap(): List {
return createMapImage()?.getPolygons() ?: emptyList()
}fun getPolygons(): List<KNMapPolygon>getScreenRect
Returns the screen rectangle (RectF) that encloses the KNMapCoordinateRegion.
Example code — getScreenRect:
fun createMapImage(): KNMapImage? {
return KNSDK.mapImageByViewWithSize(
// contentView
view,
KNMapTheme.driveNight(),
RectF(0f, 0f, 500f, 500f),
// minRect: Value used when the size cannot be measured correctly due to a coordinateLayout bug that returns abnormal height/width values
RectF(0f, 0f, 500f, 500f))
}
fun regionRectWithImageMap() {
createMapImage()?.apply {
val region = KNMapCoordinateRegion.initWithRoute(getRoutes())
region.mergeWithMarkers(getMarkers())
// Can be negative if the calculated area extends beyond the current screen.
val screenRectF = getScreenRect(region)
}
}fun getScreenRect( region: KNMapCoordinateRegion ): RectFParameters
| Name | Description |
|---|---|
region | Received coordinate region |
isOverlappedWithScreenRect
Returns whether the screen rectangle (RectF) intersects the KNMapCoordinateRegion.
Example code — isOverlappedWithScreenRect:
fun createMapImage(): KNMapImage? {
return KNSDK.mapImageByViewWithSize(
// contentView
view,
KNMapTheme.driveNight(),
RectF(0f, 0f, 500f, 500f),
// minRect: Value used when the size cannot be measured correctly due to a coordinateLayout bug that returns abnormal height/width values
RectF(0f, 0f, 500f, 500f))
}
fun areaCollisionWithImageMap() {
createMapImage()?.apply {
val region = KNMapCoordinateRegion.initWithRoute(getRoutes())
region.mergeWithMarkers(getMarkers())
val center = WGS84ToKATEC(127.11019081347423,37.3941851228957)
val screenPoint = katecToScreen(center)
val screeRectF = RectF(screenPoint.x - 50f, screenPoint.y - 50f, screenPoint.x + 50f, screenPoint.y + 50f)
val collision = isOverlappedWithScreenRect(screeRectF, region)
}
}fun isOverlappedWithScreenRect( screenRect: RectF,
region: KNMapCoordinateRegion ): BooleanParameters
| Name | Description |
|---|---|
screenRect | Screen rectangle (RectF) |
region | Received coordinate region |
isOverlappedWithScreenPoint
Returns whether the screen coordinates (FloatPoint) overlap with KNMapCoordinateRegion.
Example code — isOverlappedWithScreenPoint:
fun createMapImage(): KNMapImage? {
return KNSDK.mapImageByViewWithSize(
// contentView
view,
KNMapTheme.driveNight(),
RectF(0f, 0f, 500f, 500f),
// minRect: Value used when the size cannot be measured correctly due to a coordinateLayout bug that returns abnormal height/width values
RectF(0f, 0f, 500f, 500f))
}
fun pointCollisionWithImageMap() {
createMapImage()?.apply {
val region = KNMapCoordinateRegion.initWithRoute(getRoutes())
region.mergeWithMarkers(getMarkers())
val center = WGS84ToKATEC(127.11019081347423,37.3941851228957)
val screenPoint = katecToScreen(center)
val collision = isOverlappedWithScreenPoint(screenPoint, region)
}
}fun isOverlappedWithScreenPoint( screenPoint: FloatPoint,
region: KNMapCoordinateRegion ): BooleanParameters
| Name | Description |
|---|---|
screenPoint | Screen coordinates (FloatPoint) |
region | Received coordinate region |
moveCamera
Updates the map camera position with the KNMapCameraUpdate settings.
Example code — moveCamera
fun createMapImage(): KNMapImage? {
return KNSDK.mapImageByViewWithSize(
// contentView
view,
KNMapTheme.driveNight(),
RectF(0f, 0f, 500f, 500f),
// minRect: Value used when the size cannot be measured correctly due to a coordinateLayout bug that returns abnormal height/width values
RectF(0f, 0f, 500f, 500f))
}
fun moveCameraWithImageMap() {
createMapImage()?.apply {
val region = KNMapCoordinateRegion.initWithRoute(getRoutes())
region.mergeWithMarkers(getMarkers())
val update = KNMapCameraUpdate.
tiltTo(0f).
bearingTo(0f).
fitTo(region)
// If targetTo is added, the map adjusts the zoom level, moves to that position, and then, from the new position,
// readjusts the zoom level so that all objects are visible.
moveCamera(update)
}
}fun moveCamera( cameraUpdate: KNMapCameraUpdate )Parameters
| Name | Description |
|---|---|
cameraUpdate | KNMapCameraUpdate settings |
generateMapWithCompletion
Creates the map image. The completed image is delivered through KNMiniMapimageLoadListener; if creation fails, loadFailed is called.
Example code — generateMapWithCompletion
fun createMapImage(): KNMapImage? {
return KNSDK.mapImageByViewWithSize(
// contentView
view,
KNMapTheme.driveNight(),
RectF(0f, 0f, 500f, 500f),
// minRect: Value used when the size cannot be measured correctly due to a coordinateLayout bug that returns abnormal height/width values
RectF(0f, 0f, 500f, 500f))
}
fun regioRectWithImageMapGenerate(listener: KNMiniMapImageLoadListener) {
createMapImage()?.apply {
val region = KNMapCoordinateRegion.initWithRoute(getRoutes())
region.mergeWithMarkers(getMarkers())
// Can be negative if the calculated area extends beyond the current screen.
val screenRectF = getScreenRect(region)
generateMapWithCompletion(listener)
}
}fun generateMapWithCompletion( completion: KNMiniMapImageLoadListener )katecToScreen
Converts KATEC coordinates based on the current map to screen coordinates.
Example code — katecToScreen:
fun createMapImage(): KNMapImage? {
return KNSDK.mapImageByViewWithSize(
// contentView
view,
KNMapTheme.driveNight(),
RectF(0f, 0f, 500f, 500f),
// minRect: Value used when the size cannot be measured correctly due to a coordinateLayout bug that returns abnormal height/width values
RectF(0f, 0f, 500f, 500f))
}
fun katecToScreenWithImageMap(katec: FloatPoint): FloatPoint {
return createMapImage()?.katecToScreen(katec) ?: FloatPoint()
}fun katecToScreen( katec: FloatPoint ): FloatPointParameters
| Name | Description |
|---|---|
katec | KATEC coordinates |
screenToKatec
Converts screen coordinates based on the current map to KATEC coordinates.
Example code — screenToKatec:
fun createMapImage(): KNMapImage? {
return KNSDK.mapImageByViewWithSize(
// contentView
view,
KNMapTheme.driveNight(),
RectF(0f, 0f, 500f, 500f),
// minRect: Value used when the size cannot be measured correctly due to a coordinateLayout bug that returns abnormal height/width values
RectF(0f, 0f, 500f, 500f))
}
fun screenToKatecWithImageMap(screen: FloatPoint): FloatPoint {
return createMapImage()?.screenToKatec(screen) ?: FloatPoint()
}fun screenToKatec( screen: FloatPoint ): FloatPointParameters
| Name | Description |
|---|---|
screen | screen coordinates |