KNMapUserLocation
INFO
This English reference is based on Directions SDK 1.12.12. For the latest version, see the Korean reference.
It shows the current location of the user. It doesn't allow the use of more than two user locations on one map.
Properties
| Name | Description | Type |
|---|---|---|
icon | Image used to display the user location. Uses the default image if no custom image is set. | @property (nonatomic, assign, nonnull) UIImage* icon |
coordinate | KATEC coordinates of the user location | @property (nonatomic, assign) FloatPoint coordinate |
pixelOffset | Pixel offset of the user-location image, expressed as (x, y). The origin is the bottom center of the image; +1 on x moves right and +1 on y moves down. (default: origin) | @property (nonatomic, assign) IntPoint pixelOffset |
isVisible | Whether the user location is visible. Setting NO also hides the guide line.(default: YES) | @property (nonatomic, assign) BOOL isVisible |
priority | Display priority of the user location. Higher values appear on top. (default: 65535, range: 0–65535) | @property (nonatomic, assign) NSInteger priority |
guideLineColor | Color of the guide line connecting the current user location to the Destination (default: blue) | @property (nonatomic, assign, nonnull) UIColor* guideLineColor |
guideLineGoal | Destination coordinates for the guide line. If unset, the route endpoint is used. | @property (nonatomic, assign) FloatPoint guideLineGoal; |
guideLineWidth | Width of the guide line connecting the current user location to the Destination (range: 1–5) | @property (nonatomic, assign) float guideLineWidth |
guideLineDashType | Style of the guide line connecting the current user location to the Destination (default: KNLineDashType_Dashed) | @property (nonatomic, assign) KNLineDashType guideLineDashType |
isVisibleGuideLine | Whether the guide line is visible. If isVisible is NO, the guide line remains hidden and changes to this property take effect only after isVisible becomes YES.(default: YES) | @property (nonatomic, assign) BOOL isVisibleGuideLine |
angle | Direction of the user-location image. (range: 0–360; 0 points north) | @property (nonatomic, assign) float angle |
isFlat | Whether the vehicle icon follows the screen Tilt. If YES, Tilt affects the icon. (default: YES) | @property (nonatomic, assign) BOOL isFlat; |
useSingleTapped | Whether single-tap events are enabled. If NO, KNMapUserLocationEventListener does not receive single-tap events.(default: YES) | @property (nonatomic, readwrite, assign) bool useSingleTapped |
useDoubleTapped | Whether double-tap events are enabled. If NO, KNMapUserLocationEventListener does not receive double-tap events.(default: YES) | @property (nonatomic, readwrite, assign) bool useDoubleTapped |
useLongPressed | Whether long-press events are enabled. If NO, KNMapUserLocationEventListener does not receive long-press events.(default: YES) | @property (nonatomic, readwrite, assign) bool useLongPressed |
eventListener | Listener for user-location touch and animation completion events | @property (nonatomic, nullable, readwrite, weak) id<KNMapUserLocationEventListener> eventListener |
Example code — KNMapUserLocation Example code for using the property
objc
// Set the user location image
userLocation.icon = newImage;
// User location in KATEC coordinates
userLocation.coordinate = newValue;
FloatPoint coordinate = userLocation.coordinate;
// Move the origin down
userLocation.pixelOffset = IntPointMake(0, 10);
// Set whether to show the user location
userLocation.isVisible = newValue;
Bool isVisible = userLocation.isVisible;
// Set the display priority of the user location
userLocation.priority = newValue;
NSInteger priority = userLocation.priority;
// Set the guide line color to blue
userLocation.guideLineColor = UIColor.blue;
// Route event delegation
- (void)guidanceGuideStarted:(KNGuidance *)aGuidance {
// Draw the route on mapView
[mapView setRoutes:aGuidance.routesOnGuide];
// New destination position
FloatPoint goalPos = FloatPointMakeWithIntPoint(aGuidance.trip.goal.pos);
// Set the guide line to the newly set destination instead of the destination of the setRoute/setRoutes route
self->mapView.userLocation.guideLineGoal = goalPos;
}
// Set the guide line width to 3
userLocation.guideLineWidth = 3.0;
// Set the guide line to a solid line
userLocation.guideLineDashType = .solid;
// Hide the guide line
userLocation.isVisibleGuideLine = NO;
// Set the rotation angle of the icon image
float angle = userLocation.angle;Methods
animateWithCoordinate:angle:duration
With the animation effect, it moves from the current location to the Destination at the angles and times that it enters.
objc
- (void) animateWithCoordinate: (FloatPoint) aCoordinate
angle: (float) aAngle
duration: (float) aDurationParameters
| Name | Description |
|---|---|
aCoordinate | KATEC coordinates of the location to move to |
aAngle | The angle of rotation |
aDuration | Animation duration(unit: ms) |
animateWithCoordinate:duration
With the animation effect, it moves from the current location to the Destination during the time you enter it.
Example code — - animateWithCoordinate:duration:
objc
// Rotate 35 degrees and move to the destination over 500 ms
[self->mapView.userLocation animateWithCoordinate:pos angle:35.0 duration:500];objc
- (void) animateWithCoordinate: (FloatPoint) aCoordinate
duration: (float) aDurationParameters
| Name | Description |
|---|---|
aCoordinate | KATEC coordinates of the location to move to |
aDuration | Animation duration(unit: ms) |