KNMapCameraUpdate
INFO
This English reference is based on Directions SDK 1.12.12. For the latest version, see the Korean reference.
Configures the Camera used by the 3D map. Set the Zoom level, position, Tilt, rotation angle, anchor, or a region to fit on screen.
Constructor
+ cameraUpdate
Creates a KNMapCameraUpdate object with default values.
+ (KNMapCameraUpdate*)cameraUpdateExample code — + cameraUpdate
KNMapCameraUpdate* cameraUpdate = [KNMapCameraUpdate cameraUpdate];
[mapView moveCamera:cameraUpdate withUserLocation:true];+ targetTo
Creates a KNMapCameraUpdate object initialized with a position in KATEC coordinates.
Example code — + targetTo:
FloatPoint target; // Move from the current position to a new position (x:321384, y:533054)
target.x = 321384;
target.y = 533054;
KNMapCameraUpdate* cameraUpdate = [KNMapCameraUpdate targetTo:target];
[mapView moveCamera:cameraUpdate withUserLocation:true];+ (KNMapCameraUpdate*) targetTo: (FloatPoint) aPositionParameters
| Name | Description |
|---|---|
aPosition | KATEC coordinates of the location to move to |
+ zoomTo
Creates a KNMapCameraUpdate object initialized with the specified Zoom level. The valid range follows setZoomRange in KNMapView.
Example code — + zoomTo:
KNMapCameraUpdate* cameraUpdate = [KNMapCameraUpdate zoomTo:5.0]; // Set the zoom level to 5
[mapView moveCamera:cameraUpdate withUserLocation:true];+ (KNMapCameraUpdate*) zoomTo: (Float) aZoomParameters
| Name | Description |
|---|---|
aZoom | Zoom level to apply to the map |
+ tiltTo
Creates a KNMapCameraUpdate object initialized with the specified Tilt.
Example code — + tiltTo:
KNMapCameraUpdate* cameraUpdate = [KNMapCameraUpdate tiltTo:45.0]; // Set the tilt to 45
[mapView moveCamera:cameraUpdate withUserLocation:true];+ (KNMapCameraUpdate*) tiltTo: (Float) aDegreeParameters
| Name | Description |
|---|---|
aDegree | Screen tilt to apply to the map |
+ bearingTo
Creates a KNMapCameraUpdate object initialized with the specified rotation angle.
Example code — + bearingTo:
KNMapCameraUpdate* cameraUpdate = [KNMapCameraUpdate bearingTo:30.0]; // Set the rotation angle to 30
[mapView moveCamera:cameraUpdate withUserLocation:true];+ (KNMapCameraUpdate*) bearingTo: (Float) aDegreeParameters
| Name | Description |
|---|---|
aDegree | Rotation angle to apply to the map |
+ anchorTo
Creates a KNMapCameraUpdate object initialized with an anchor for Zoom, Tilt, and rotation. The default anchor is the center (0.5, 0.5).
Screen coordinates use (x, y): the lower-left corner is (0, 0), and the upper-right corner is (1, 1). Increasing x moves right; increasing y moves up.
Example code — + anchorTo:
FloatPoint anchor; // Set a new anchor point by moving it up from the center
anchor = 0.5;
anchor = 0.7;
KNMapCameraUpdate* cameraUpdate = [KNMapCameraUpdate anchorTo:anchor];
[mapView moveCamera:cameraUpdate withUserLocation:true];+ (KNMapCameraUpdate*) anchorTo: (FloatPoint) aAnchorParameters
| Name | Description |
|---|---|
aAnchor | Anchor point (x, y), from the lower-left corner (0, 0) to the upper-right corner (1, 1) |
+ fitToRegion
Fits the coordinate region from KNMapCoordinateRegion to the screen.
+ (KNMapCameraUpdate*) fitToRegion: (KNMapCoordinateRegion*) aRegionParameters
| Name | Description |
|---|---|
aRegion | Object containing the route, Marker, or other area to fit |
+ fitToFittingRect:region
Fits the coordinate region from KNMapCoordinateRegion into the specified screen rectangle (CGRect).
Example code — + fitToFittingRect:region:
NSArray* markers = [mapView getMarkers];
NSArray* routes = [mapView getRoutes];
KNMapCoordinateRegion* region = [KNMapCoordinateRegion region];
// Set the marker area
[region mergeWithMarkers:markers];
// Set the marker and route area
[region mergeWithRoutes:routes)];
// Set a specific rectangular area on the map
CGRect originalRect = screenRect;
// Set the padding
UIEdgeInsets insets = UIEdgeInsetsMake(5, 5, -5, -5);
CGRect fittingScreenRect = UIEdgeInsetsInsetRect(originalRect, insets);
// Fit the marker and route area to the screen
KNMapCameraUpdate* cameraUpdate = [[KNMapCameraUpdate tiltTo:45.0] fitToFittingRect:fittingScreenRect region:region];
// Apply the camera update to mapView
[mapView moveCamera:cameraUpdate withUserLocation:true];+ (KNMapCameraUpdate*) fitToFittingRect: (CGRect) aRect
region: (KNMapCoordinateRegion*) aRegionParameters
| Name | Description |
|---|---|
aRect | Screen rectangle used when updating the Camera |
aRegion | Object containing the route, Marker, or other area to fit |
Methods
targetTo
Moves the Camera to a new position in KATEC coordinates.
- (KNMapCameraUpdate*) targetTo: (FloatPoint) aPositionParameters
| Name | Description |
|---|---|
aPosition | KATEC coordinates of the location to move to |
zoomTo
Sets the Zoom level around the current map position.
- (KNMapCameraUpdate*) zoomTo: (Float) aZoomParameters
| Name | Description |
|---|---|
aZoom | Zoom level to apply to the map (range: 0.1–2000) |
tiltTo
Sets the Tilt around the current map position.
- (KNMapCameraUpdate*) tiltTo: (Float) aDegreeParameters
| Name | Description |
|---|---|
aDegree | Tilt to apply to the map (range: 0–50) |
bearingTo
Sets the rotation angle around the current map position.
- (KNMapCameraUpdate*) bearingTo: (Float) aDegreeParameters
| Name | Description |
|---|---|
aDegree | Rotation angle to apply to the map (range: 0–360) |
anchorTo
Sets the anchor for Zoom, Tilt, and rotation. The default anchor is the center (0.5, 0.5).
Screen coordinates use (x, y): the lower-left corner is (0, 0), and the upper-right corner is (1, 1). Increasing x moves right; increasing y moves up.
- (KNMapCameraUpdate*) anchorTo: (FloatPoint) aAnchorParameters
| Name | Description |
|---|---|
aAnchor | Anchor point (x, y), from the lower-left corner (0, 0) to the upper-right corner (1, 1) |
fitToRegion
Fits the coordinate region from KNMapCoordinateRegion to the screen.
- (KNMapCameraUpdate*) fitToRegion: (KNMapCoordinateRegion*) aRegionParameters
| Name | Description |
|---|---|
aRegion | Object containing the route, Marker, or other area to fit |
fitToFittingRect:region
Fits the coordinate region from KNMapCoordinateRegion into the specified screen rectangle (CGRect).
Example code — - fitToFittingRect:region:
// Move the map to zoom level 30 at position (x:321384, y:533054)
FloatPoint target;
target.x = 321384;
target.y = 533054;
KNMapCameraUpdate* cameraUpdate1 = [[KNMapCameraUpdate zoomTo: 30.0] targetTo:target];
[mapView moveCamera:cameraUpdate1 withUserLocation:true];
// Move the map to tilt 45, rotation 30, zoom level 20 at position (x:321384, y:533054)
KNMapCameraUpdate* cameraUpdate2 = [[[[KNMapCameraUpdate targetTo:target] zoomTo:20.0] bearingTo:30.0] tiltTo:45.0];
[mapView moveCamera:cameraUpdate2 withUserLocation:true];
// With the map tilted 45 degrees, fit the screen to the route and marker area set in KNMapCoordinateRegion
NSArray* markers = [mapView getMarkers];
NSArray* routes = [mapView getRoutes];
KNMapCoordinateRegion* region = [KNMapCoordinateRegion region];
[region mergeWithMarkers:markers];
[region mergeWithRoutes:routes)];
// Set a specific rectangular area on the map
CGRect originalRect = screenRect;
// Set the padding
UIEdgeInsets insets = UIEdgeInsetsMake(5, 5, -5, -5);
CGRect fittingScreenRect = UIEdgeInsetsInsetRect(originalRect, insets);
// Fit the marker and route area to the screen
KNMapCameraUpdate* cameraUpdate = [[KNMapCameraUpdate tiltTo:45.0] fitToFittingRect:fittingScreenRect region:region];
// Apply the camera update to mapView
[mapView moveCamera:cameraUpdate withUserLocation:true];- (KNMapCameraUpdate*) fitToFittingRect: (CGRect) aRect
region: (KNMapCoordinateRegion*) aRegionParameters
| Name | Description |
|---|---|
aRect | Screen rectangle used when updating the Camera |
aRegion | Object containing the route, Marker, or other area to fit |