Constructor 링크 복사
KNMapView
클래스는 KNSDK
를 통해 생성되어야 합니다.
KNMapView* mapView = [[KNSDK sharedInstance] makeMapViewWithFrame:[UIScreen mainScreen].bounds];
KNMapView* mapView = [[KNSDK sharedInstance] makeMapViewWithFrame:[UIScreen mainScreen].bounds];
함수 링크 복사
지도에 경로를 설정합니다.
- (void) | setRoute: | (KNRoute*) | aRoute |
// 경로 이벤트 델리게이션
- (void)guidanceGuideStarted:(KNGuidance *)aGuidance {
[mapView setRoute:aGuidance.routesOnGuide[0]]; // mapView에 경로 그리기
}
// 경로 이벤트 델리게이션
- (void)guidanceGuideStarted:(KNGuidance *)aGuidance {
[mapView setRoute:aGuidance.routesOnGuide[0]]; // mapView에 경로 그리기
}
- aRoute
- 경로
경로 리스트를 전달받아 지도에 경로를 설정합니다.
- (void) | setRoutes: | (NSArray<KNRoute*>*) | aRoutes |
// 경로 이벤트 델리게이션
- (void)guidanceGuideStarted:(KNGuidance *)aGuidance {
[mapView setRoutes:aGuidance.routesOnGuide]; // mapView에 경로 그리기
}
// 경로 이벤트 델리게이션
- (void)guidanceGuideStarted:(KNGuidance *)aGuidance {
[mapView setRoutes:aGuidance.routesOnGuide]; // mapView에 경로 그리기
}
- aRoutes
- 경로 리스트
지도에 설정된 모든 경로 리스트를 반환합니다.
- (NSArray<KNRoute*>*) | getRoutes |
NSArray<KNRoute*>* routes = [self->mapView getRoutes];
NSArray<KNRoute*>* routes = [self->mapView getRoutes];
지도에 등록된 모든 경로를 삭제합니다.
- (void) | removeRoutesAll |
지도의 줌 레벨 최소, 최댓값을 설정하여 범위를 제한합니다. 범위는 서버 설정에 따라 0.1에서 9999.0까지 지정할 수 있으며 이 범위를 벗어나는 설정은 무시됩니다.
- (void) | setZoomRangeWithMinimum: | (float) | aMinimum |
maximum: | (float) | aMaximum |
[self->mapView setZoomRangeWithMinimum:aMinimum maximum:aMaximum];
[self->mapView setZoomRangeWithMinimum:aMinimum maximum:aMaximum];
- aMinimum
- 줌 레벨 최솟값(0.1)
- aMaximum
- 줌 레벨 최댓값(9999.0)
입력 받은 사용자의 위치 정보를 통해 사용자가 지나간 경로 부분을 자릅니다. isAnimate
가 활성화(YES
)된 경우, 500 ms를 기준으로 서서히 경로가 잘리게 되며 비활성화(NO
)된 경우 즉시 잘립니다. 경로의 시작 위치는 KNLocation
을 기준으로 합니다.
- (void) | cullPassedRouteWithLocation: | (KNLocation*) | aLocation |
isAnimate: | (BOOL) | aIsAnimate |
// 경로 이벤트 델리게이션. 경로 안내 정보 변경 시 또는 상세 항목 중 1개 이상 변경 발생 시에 전달.
- (void)guidance:(KNGuidance *)aGuidance didUpdateLocation:(KNGuide_Location *)aLocationGuide {
// 현재 위치 기준으로 지나간 경로 자르기
[self->mapView cullPassedRouteWithLocation:aLocationGuide.location isAnimate:false];
}
// 경로 이벤트 델리게이션. 경로 안내 정보 변경 시 또는 상세 항목 중 1개 이상 변경 발생 시에 전달.
- (void)guidance:(KNGuidance *)aGuidance didUpdateLocation:(KNGuide_Location *)aLocationGuide {
// 현재 위치 기준으로 지나간 경로 자르기
[self->mapView cullPassedRouteWithLocation:aLocationGuide.location isAnimate:false];
}
- aLocation
- 위치 정보
- aIsAnimate
- 경로를 자르는 애니메이션 사용 여부
지도에 마커를 추가합니다.
- (void) | addMarker: | (KNMapMarker*) | aMarker |
// 현재 지도 위치
FloatPoint pos = FloatPointMake(self->mapView.coordinate.x, self->mapView.coordinate.y);
// 기본 핀 마커로 생성 및 지도에 추가
KNMapMarker* marker = [KNMapMarker markerWithCoordinate:pos];
marker.priority = PRIORITY;
marker.tag = MARKER_01;
marker.info = nil;
// 지도 줌 레벨에 따른 마커의 가시성(visibility) 설정
[marker setVisibleRangeWithMinZoom:0.1 maxZoom:30.0];
[self->mapView addMarker:marker];
// 현재 지도 위치
FloatPoint pos = FloatPointMake(self->mapView.coordinate.x, self->mapView.coordinate.y);
// 기본 핀 마커로 생성 및 지도에 추가
KNMapMarker* marker = [KNMapMarker markerWithCoordinate:pos];
marker.priority = PRIORITY;
marker.tag = MARKER_01;
marker.info = nil;
// 지도 줌 레벨에 따른 마커의 가시성(visibility) 설정
[marker setVisibleRangeWithMinZoom:0.1 maxZoom:30.0];
[self->mapView addMarker:marker];
- aMarker
- 마커
지도에 마커 리스트를 추가합니다.
- (void) | addMarkers: | (NSArray<KNMapMarker*>*) | aMarkers |
- (void)addMarkers:(NSArray<KNMapMarker*>*)aMarkers
- (void)addMarkers:(NSArray<KNMapMarker*>*)aMarkers
- aMarkers
- 마커 리스트
지도에서 마커를 제거합니다.
- (void) | removeMarker: | (KNMapMarker*) | aMarker |
[self->mapView removeMarker:aMarker];
[self->mapView removeMarker:aMarker];
- aMarker
- 마커
지도에 추가된 모든 마커를 제거합니다.
- (void) | removeMarkersAll |
[self->mapView removeMarkersAll];
[self->mapView removeMarkersAll];
지도에 추가된 마커 리스트를 반환합니다. 추가된 마커가 없을 경우 빈 리스트를 반환합니다.
- (NSArray*) | getMarkers |
NSArray* markers = [self->mapView getMarkers];
NSArray* markers = [self->mapView getMarkers];
지도에 원을 추가합니다.
- (void) | addCircle: | (KNMapCircle*) | aCircle |
IntPoint mapPos = [[KNSDK sharedInstance] convertWGS84ToKATECWithLongitude:127.11019081347423 latitude:37.3941851228957];
KNMapCircle *circle = [KNMapCircle circleWithCenter:FloatPointMake(mapPos.x, mapPos.y) radius:100.0f];
circle.strokeColor = [UIColor redColor];
circle.fillColor = [UIColor blueColor];
circle.strokeWidth = STROKE_WIDTH;
circle.strokeDashType = KNLineDashType_Solid;
circle.isVisible = YES;
circle.priority = PRIORITY;
circle.tag = CIRCLE_01;
[self->mapView addCircle:circle];
IntPoint mapPos = [[KNSDK sharedInstance] convertWGS84ToKATECWithLongitude:127.11019081347423 latitude:37.3941851228957];
KNMapCircle *circle = [KNMapCircle circleWithCenter:FloatPointMake(mapPos.x, mapPos.y) radius:100.0f];
circle.strokeColor = [UIColor redColor];
circle.fillColor = [UIColor blueColor];
circle.strokeWidth = STROKE_WIDTH;
circle.strokeDashType = KNLineDashType_Solid;
circle.isVisible = YES;
circle.priority = PRIORITY;
circle.tag = CIRCLE_01;
[self->mapView addCircle:circle];
- aCircle
- 원
지도에서 원을 제거합니다.
- (void) | removeCircle: | (KNMapCircle*) | aCircle |
[self->mapView removeCircle:aCircle];
[self->mapView removeCircle:aCircle];
- aCircle
- 원
지도에 추가된 모든 원을 제거합니다.
- (void) | removeCirclesAll |
[self->mapView removeCircleAll];
[self->mapView removeCircleAll];
지도에 추가된 원 리스트를 반환합니다. 추가된 원이 없을 경우 빈 리스트를 반환합니다.
- (NSArray*) | getCircles |
NSArray* circles = [self->mapView getCircles];
NSArray* circles = [self->mapView getCircles];
지도에 폴리라인을 추가합니다.
aPolyline | addPolyline: | (KNMapPolyline*) | aPolyline |
ObjectLoader *objectLoader = [[ObjectLoader alloc] initWithFile:[[NSBundle mainBundle] pathForResource:@"testcase2.csv" ofType:nil]];
KNMapPolyline *mapPolyline = [KNMapPolyline polylineWithPoints:objectLoader.position countPoints:objectLoader.positionCnt];
mapPolyline.lineColor = [UIColor redColor];
mapPolyline.lineDashType = KNLineDashType_Solid;
mapPolyline.lineWidth = STROKE_WIDTH;
mapPolyline.isVisible = YES;
mapPolyline.priority = PRIORITY;
mapPolyline.tag = POLYLINE_01;
[self->mapView addPolyline:mapPolyline];
ObjectLoader *objectLoader = [[ObjectLoader alloc] initWithFile:[[NSBundle mainBundle] pathForResource:@"testcase2.csv" ofType:nil]];
KNMapPolyline *mapPolyline = [KNMapPolyline polylineWithPoints:objectLoader.position countPoints:objectLoader.positionCnt];
mapPolyline.lineColor = [UIColor redColor];
mapPolyline.lineDashType = KNLineDashType_Solid;
mapPolyline.lineWidth = STROKE_WIDTH;
mapPolyline.isVisible = YES;
mapPolyline.priority = PRIORITY;
mapPolyline.tag = POLYLINE_01;
[self->mapView addPolyline:mapPolyline];
- aPolyline
- 폴리라인
지도에서 폴리라인을 제거합니다.
- (void) | removePolyline: | (KNMapPolyline*) | aPolyline |
[self->mapView removePolyline:aPolyline];
[self->mapView removePolyline:aPolyline];
- aPolyline
- 폴리라인
지도에 추가된 모든 폴리라인을 제거합니다.
- (void) | removePolylinesAll |
[self->mapView removePolylineAll];
[self->mapView removePolylineAll];
지도에 추가된 폴리라인 리스트를 반환합니다. 추가된 폴리라인이 없을 경우 빈 리스트를 반환합니다.
- (NSArray*) | getPolylines |
NSArray* polylines = [self->mapView getPolylines];
NSArray* polylines = [self->mapView getPolylines];
지도에 폴리곤(다각형)을 추가합니다.
- (void) | addPolygon: | (KNMapPolygon*) | aPolygon |
ObjectLoader *objectLoader = [[ObjectLoader alloc] initWithFile:[[NSBundle mainBundle] pathForResource:@"testcase5.csv" ofType:nil]];
KNMapPolygon* polygon = [[KNMapPolygon alloc] polygonWithPoints:objectLoader.position countPoints:objectLoader.positionCnt];
polygon.fillColor = [UIColor redColor];
polygon.strokeColor = [UIColor greenColor];
polygon.strokeWidth = STROKE_WIDTH;
polygon.strokeDashType = KNLineDashType_Solid;
polygon.isVisible = YES;
polygon.priority = PRIORITY;
polygon.tag = POLYGON_01;
if(objectLoader.holeCnt > 0)
{
[polygon addHoleWithPoints:objectLoader.holePosition countPoints:objectLoader.holeCnt];
}
[self->mapView addPolygon:polygon];
ObjectLoader *objectLoader = [[ObjectLoader alloc] initWithFile:[[NSBundle mainBundle] pathForResource:@"testcase5.csv" ofType:nil]];
KNMapPolygon* polygon = [[KNMapPolygon alloc] polygonWithPoints:objectLoader.position countPoints:objectLoader.positionCnt];
polygon.fillColor = [UIColor redColor];
polygon.strokeColor = [UIColor greenColor];
polygon.strokeWidth = STROKE_WIDTH;
polygon.strokeDashType = KNLineDashType_Solid;
polygon.isVisible = YES;
polygon.priority = PRIORITY;
polygon.tag = POLYGON_01;
if(objectLoader.holeCnt > 0)
{
[polygon addHoleWithPoints:objectLoader.holePosition countPoints:objectLoader.holeCnt];
}
[self->mapView addPolygon:polygon];
- aPolygon
- 폴리곤
지도에서 폴리곤(다각형)을 제거합니다.
- (void) | removePolygon: | (KNMapPolygon*) | aPolygon |
[self->mapView removePolygon:aPolygon];
[self->mapView removePolygon:aPolygon];
- aPolygon
- 폴리곤
지도에 추가된 모든 폴리곤(다각형)을 제거합니다.
- (void) | removePolygonsAll |
[self->mapView removePolygonAll];
[self->mapView removePolygonAll];
지도에 추가된 폴리곤(다각형) 리스트를 반환합니다. 추가된 폴리곤이 없을 경우 빈 리스트를 반환합니다.
- (NSArray*) | getPolygons |
NSArray* polygons = [self->mapView getPolygons];
NSArray* polygons = [self->mapView getPolygons];
KNMapCoordinateRegion
을 감싸는 화면의 사각 영역(CGRect
)을 반환합니다.
- (CGRect) | getScreenRectWithRegion: | (KNMapCoordinateRegion*) | aRegion |
// 판교, 광화문의 최대, 최소 위치 구하기
FloatPoint min, max;
min.x = MIN(self->pangyoPos.x, self->gwanghwamoonPos.x);
min.y = MIN(self->pangyoPos.y, self->gwanghwamoonPos.y);
max.x = MAX(self->pangyoPos.x, self->gwanghwamoonPos.x);
max.y = MAX(self->pangyoPos.y, self->gwanghwamoonPos.y);
// 최소, 최대 영역으로 이동
KNMapCoordinateRegion* region = [KNMapCoordinateRegion regionWithMin:min max:max];
[self->mapView moveCamera:[KNMapCameraUpdate fitToRegion:region] withUserLocation:false];
// 영역의 CGRect구하기
CGRect rect = [self->mapView getScreenRectWithRegion:region];
NSLog(@"minMaxScreenRect orgin(x:%f, y:%f) size(width:%f height:%f)", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
// 판교, 광화문의 최대, 최소 위치 구하기
FloatPoint min, max;
min.x = MIN(self->pangyoPos.x, self->gwanghwamoonPos.x);
min.y = MIN(self->pangyoPos.y, self->gwanghwamoonPos.y);
max.x = MAX(self->pangyoPos.x, self->gwanghwamoonPos.x);
max.y = MAX(self->pangyoPos.y, self->gwanghwamoonPos.y);
// 최소, 최대 영역으로 이동
KNMapCoordinateRegion* region = [KNMapCoordinateRegion regionWithMin:min max:max];
[self->mapView moveCamera:[KNMapCameraUpdate fitToRegion:region] withUserLocation:false];
// 영역의 CGRect구하기
CGRect rect = [self->mapView getScreenRectWithRegion:region];
NSLog(@"minMaxScreenRect orgin(x:%f, y:%f) size(width:%f height:%f)", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
- aRegion
- 입력받은 좌표 영역
화면의 사각 영역(CGRect
)이 KNMapCoordinateRegion
과 겹치는지 여부를 반환합니다.
- (BOOL) | isOverlappedWithScreenRect: | (CGRect) | aScreenRect |
region: | (KNMapCoordinateRegion*) | aRegion |
// 마커 추가
KNMapMarker* marker = [KNMapMarker markerWithCoordinate:FloatPointMakeWithIntPoint(self->gwanghwamoonPos)];
[self->mapView addMarker:marker];
marker.pixelOffset = IntPointMake(0, 10);
CGRect markerRect1 = [self->mapView getScreenRectWithRegion:[KNMapCoordinateRegion regionWithMarkers:[NSArray arrayWithObjects:marker, nil]]];
// 겹침 확인 1
if([self->mapView isOverlappedWithScreenRect:markerRect1 region:region]){
NSLog(@"routeMarkerOverlap marker isOverlap1");
}
else{
NSLog(@"routeMarkerOverlap marker isNotOverlap1");
}
// 마커 추가
KNMapMarker* marker = [KNMapMarker markerWithCoordinate:FloatPointMakeWithIntPoint(self->gwanghwamoonPos)];
[self->mapView addMarker:marker];
marker.pixelOffset = IntPointMake(0, 10);
CGRect markerRect1 = [self->mapView getScreenRectWithRegion:[KNMapCoordinateRegion regionWithMarkers:[NSArray arrayWithObjects:marker, nil]]];
// 겹침 확인 1
if([self->mapView isOverlappedWithScreenRect:markerRect1 region:region]){
NSLog(@"routeMarkerOverlap marker isOverlap1");
}
else{
NSLog(@"routeMarkerOverlap marker isNotOverlap1");
}
- aScreenRect
- 화면의 사각 영역(CGRect)
- aRegion
- 입력받은 좌표 영역
화면의 좌표(CGPoint
)가 KNMapCoordinateRegion
과 겹치는지 여부를 반환합니다.
- (BOOL) | isOverlappedWithScreenPoint: | (CGPoint) | aScreenPoint |
region: | (KNMapCoordinateRegion*) | aRegion |
// 임의의 위치에 마커 유무 확인
NSArray<KNMapMarker*>* markers = [self->mapView getMarkers];
for(KNMapMarker* marker in markers){
if([self->mapView isOverlappedWithScreenPoint:point region:[KNMapCoordinateRegion regionWithMarkers:[NSArray arrayWithObject:marker]]]){
NSLog(@"overlaped markerTag %ld", (long)marker.tag);
}
}
// 임의의 위치에 마커 유무 확인
NSArray<KNMapMarker*>* markers = [self->mapView getMarkers];
for(KNMapMarker* marker in markers){
if([self->mapView isOverlappedWithScreenPoint:point region:[KNMapCoordinateRegion regionWithMarkers:[NSArray arrayWithObject:marker]]]){
NSLog(@"overlaped markerTag %ld", (long)marker.tag);
}
}
- aScreenPoint
- 화면의 좌표(CGPoint)
- region
- 입력받은 좌표 영역
KNMapCameraUpdate
의 설정값으로 지도의 카메라 위치를 업데이트합니다.
-(void) | moveCamera: | (KNMapCameraUpdate*) | aCameraUpdate |
withUserLocation: | (BOOL) | aWithUserLocation |
KNMapCameraUpdate* cameraUpdate = [[[[KNMapCameraUpdate targetTo:pos] zoomTo:zoom] tiltTo:tilt] bearingTo:bearing];
[self->mapView moveCamera:cameraUpdate withUserLocation:false];
KNMapCameraUpdate* cameraUpdate = [[[[KNMapCameraUpdate targetTo:pos] zoomTo:zoom] tiltTo:tilt] bearingTo:bearing];
[self->mapView moveCamera:cameraUpdate withUserLocation:false];
- aCameraUpdate
- KNMapCameraUpdate의 설정값
- aWithUserLocation
- 사용자 위치 동기화 여부
KNMapCameraUpdate
에서 설정된 정보로 현재 지도상 위치와 줌, 각도를 aDuration
에 입력된 시간동안 변경합니다. (단위: ms)
-(void) | animateCamera: | (KNMapCameraUpdate*) | aCameraUpdate |
duration: | (int) | aDuraiton | |
withUserLocation: | (BOOL) | aWithUserLocation |
KNMapCameraUpdate* cameraUpdate = [[[[KNMapCameraUpdate targetTo:pos] zoomTo:zoom] tiltTo:tilt] bearingTo:bearing];
[self->mapView animateCamera:cameraUpdate duration:1000 withUserLocation:false];
KNMapCameraUpdate* cameraUpdate = [[[[KNMapCameraUpdate targetTo:pos] zoomTo:zoom] tiltTo:tilt] bearingTo:bearing];
[self->mapView animateCamera:cameraUpdate duration:1000 withUserLocation:false];
- aCameraUpdate
- KNMapCameraUpdate의 설정값
- aDuraton
- 애니메이션 동작 시간(단위: ms)
- aWithUserLocation
- 사용자 위치 동기화 여부
현재 지도 기준 카텍(KATEC) 좌표를 화면 좌표로 변환합니다.
- (CGPoint) | katecToScreen: | (FloatPoint) | aKatec |
CGPoint screen = [self->mapView katecToScreen:marker.coordinate];
CGPoint screen = [self->mapView katecToScreen:marker.coordinate];
- aKatec
- 카텍 좌표
현재 지도 기준 화면 좌표를 카텍(KATEC)좌표로 변환합니다.
- (FloatPoint) | screenToKatec: | (CGPoint) | aScreen |
FloatPoint katecPos = [self->mapView screenToKatec:CGPointMake(x, y)];
FloatPoint katecPos = [self->mapView screenToKatec:CGPointMake(x, y)];
- aScreen
- 화면 좌표
지도에 색분할 라인을 추가합니다.
-(void) | addSegmentPolyline: | (KNMapSegmentPolyline*_Nonnull) | aSegmentPolyline; |
- aSegmentPolyline
- 색분할 라인
지도에서 색분할 라인을 제거합니다.
-(void) | removeSegmentPolyline: | (KNMapSegmentPolyline*_Nonnull) | aSegmentPolyline; |
- aSegmentPolyline
- 색분할 라인
지도에 추가된 모든 색분할 라인을 제거합니다.
-(void) | removeSegmentPolylinesAll; |
지도에 추가된 색분할 라인 리스트를 반환합니다. 추가된 색분할 라인이 없을 경우 빈 리스트를 반환합니다.
-(NSArray*_Nullable) | getSegmentPolylines; |