Body extends ChartItem
시리즈, annotation, axis grid 및 guide 등이 표시되는 맵차트 주 영역 모델.
설정 모델은 BodyOptions이다.
Properties
center: MapCoord readonly
현재 표시된 상태의 맵 중앙 좌표.
default :undefined
map: MapModel readonly
map
default :undefined
movable: boolean (opens in a new tab) readonly
movable
default :undefined
panX: number (opens in a new tab) readonly
pan x
default :undefined
panY: number (opens in a new tab) readonly
pan y
default :undefined
rotationX: number (opens in a new tab) readonly
rotation x of globe.
default :undefined
rotationY: number (opens in a new tab) readonly
rotation y of globe.
default :undefined
scale: number (opens in a new tab) readonly
map scale
default :undefined
scroll: number (opens in a new tab) readonly
scroll
default :undefined
visible: boolean (opens in a new tab) readonly
표시 여부.
options.visible 값을 그대로 return하는 것이 아니라,
undefined나 null 등으로 지정하는 경우 모델의 상태에 따라 true나 false로 해석될 수 있다.
설정의 경우 updateOptions({visible: value})로 지정하는 것과 동일하다.
default :undefined
zoom: number (opens in a new tab) readonly
zoom
default :undefined
Methods
bool(prop, def?, fallback?): boolean (opens in a new tab)
boolean (opens in a new tab) 타입의 옵션 값에 특화된 prop() 메서드. prop()과 달리 boolean (opens in a new tab)으로 변환해서 반환한다.
| Parameter | Type | Description |
|---|---|---|
| prop | K | 설정 항목 이름 |
| def | boolean (opens in a new tab) | 기본값. 설정하지 않으면 defaults의 값을 사용한다. |
| fallback | boolean (opens in a new tab) |
return boolean (opens in a new tab) 타입의 옵션 값.
boolAt(path, def?, fallback?): boolean (opens in a new tab)
점(dot) 표기법으로 경로를 지정해서 boolean (opens in a new tab) 타입의 옵션 값을 반환한다.
| Parameter | Type | Description |
|---|---|---|
| path | string (opens in a new tab) | 경로 문자열 |
| def | boolean (opens in a new tab) | |
| fallback | boolean (opens in a new tab) |
return 경로에 해당하는 boolean (opens in a new tab) 타입의 옵션 값 또는 false
clean(recursive?): Body
_op에 명시적으로 설정되어 있지만 값이 현재 defaults와 동일한 항목들을 제거해
_op를 minimal delta 상태로 정규화한다.
[주의] 대부분의 경우 호출할 필요가 없다.
- 효과 값(
prop/num/props)은 영향 없음. - 직렬화(
saveOptions)도 어차피 defaults와 같은 값을 필터링하므로 결과가 동일하다. 즉 외부 저장 결과는 clean 전후가 같다.
clean이 실제로 차이를 만드는 경우는 다음과 같다.
_op의 메모리 사용을 줄이고 싶을 때(loadOptions로 큰 source를 읽어들인 직후 등).getOption()/saveOption()처럼 _op의 own value를 그대로 반환하는 API의 결과를 "사용자가 명시했는가"의 의미로 사용해야 할 때(예: 디자이너 UI의 "기본값 사용 중" 표시). 이 경우 clean 후에는 defaults와 같은 값들이undefined로 보고된다.
| Parameter | Type | Description |
|---|---|---|
| recursive | boolean (opens in a new tab) | true로 지정하면 모든 자식 모델에 대해서도 재귀적으로 수행한다. 기본값: true |
return 모델 객체 자신
clearOptions(recursive?, render?): Body
명시적으로 설정된 모든 모델 설정 값들을 제거한다.
| Parameter | Type | Description |
|---|---|---|
| recursive | boolean (opens in a new tab) | true로 지정하면 모든 자식 모델에 대해서도 재귀적으로 제거한다. 기본값: false |
| render | boolean (opens in a new tab) | true로 지정하면 옵션 변경 시 컨트롤을 다시 그린다. 기본값: true |
return 모델 객체 자신
clearStyle(render?): Body
명시적으로 모델에 설정된 모든 style 값들을 제거한다.
| Parameter | Type | Description |
|---|---|---|
render=false | boolean (opens in a new tab) | true로 지정하면 옵션 변경 시 맵차트를 다시 그린다. 기본값 false |
dispose(): null
객체를 해제하고 null을 반환한다.
사용 예: this._obj = this._obj.dispose();
return null
focusTo(target, duration?): void (opens in a new tab)
지정한 지점이나 area의 center가 중앙이 되도록 이동한다.
| Parameter | Type | Description |
|---|---|---|
| target | MapCoord | 지점 좌표 또는 area id. |
duration=500 | number (opens in a new tab) |
getOption(option): any (opens in a new tab)
옵션 값을 읽는다.
prop()과 달리 효과 값이 아닌 명시적으로 설정된 값만 읽는다. 설정되지 않은 옵션은 undefined를 반환한다.
| Parameter | Type | Description |
|---|---|---|
| option | string (opens in a new tab) | 설정 항목 이름 |
return 명시적으로 설정된 값 또는 undefined
getOptionAt(path): any (opens in a new tab)
점(dot) 표기법으로 경로를 지정해서 옵션 값을 읽는다.
| Parameter | Type | Description |
|---|---|---|
| path | string (opens in a new tab) | 경로 문자열 |
return 경로에 해당하는 옵션 값 또는 undefined
init(): Body
특정 부모에 마운팅되지 않은 독립된 옵션 객체를 초기화한다.
initAndLoad(source): Body
특정 부모에 마운팅되지 않은 독립된 옵션 객체를 초기화하고, source 객체로부터 옵션 값을 읽어서 설정한다.
| Parameter | Type |
|---|---|
| source | any (opens in a new tab) |
loadOptions(source): Body
source 객체로부터 모델 설정 값을 읽어서 적용한다.
[정책] load는 source에 명시된 값을 "사용자 의도"로 그대로 보존한다. 즉 source의 값이
현재 defaults와 같더라도 _op에 그대로 기록된다. 이는 단순한 성능 최적화가 아니라
의미상 의도된 동작이다:
defaults는 라이브러리 버전업 시 변경될 수 있다.- load 시점에 "defaults와 같다"는 이유로 키를 버리면, 이후
defaults가 바뀌었을 때 저장본이 표현하던 값이 조용히 달라진다. - 그대로 보존하면 사용자가 명시적으로 지정한 값이 항상 우선한다.
직렬화(saveOptions)는 어차피 defaults와 같은 값을 필터링하므로, 외부에 저장되는
결과의 크기와 내용에는 영향이 없다. 추가 비용은 _op에 약간의 메모리뿐이다.
(메모리 정리나 getOption()의 "사용자 명시 여부" 의미가 필요한 특수 케이스에 한해서만
clean()을 명시적으로 호출한다.)
| Parameter | Type |
|---|---|
| source | any (opens in a new tab) |
num(prop, def?): number (opens in a new tab)
숫자 타입의 옵션 값에 특화된 prop() 메서드. prop()과 달리 숫자로 변환해서 반환한다.
| Parameter | Type | Description |
|---|---|---|
| prop | K | 설정 항목 이름 |
| def | number (opens in a new tab) | 기본값. 설정하지 않으면 defaults의 값을 사용한다. |
return 숫자 타입의 옵션 값.
numAt(path, def?): number (opens in a new tab)
점(dot) 표기법으로 경로를 지정해서 숫자 타입의 옵션 값을 반환한다.
| Parameter | Type | Description |
|---|---|---|
| path | string (opens in a new tab) | 경로 문자열 |
| def | number (opens in a new tab) |
return 경로에 해당하는 숫자 타입의 옵션 값 또는 NaN
prop(prop, def?): BodyOptions[K]
옵션의 효과 값(effective value)을 반환한다.
명시적으로 설정된 값이 있으면 그 값을, 없으면 클래스의 defaults에 정의된 기본값을 반환한다.
옵션 값을 읽을 때는 options.prop 직접 접근 대신 이 메서드를 사용한다.
| Parameter | Type | Description |
|---|---|---|
| prop | K | 설정 항목 이름 |
| def | any (opens in a new tab) | 기본값. 설정하지 않으면 defaults의 값을 사용한다. |
propAt(path, def?): any (opens in a new tab)
점(dot) 표기법으로 경로를 지정해서 옵션의 효과 값(effective value)을 반환한다.
| Parameter | Type | Description |
|---|---|---|
| path | string (opens in a new tab) | 경로 문자열 |
| def | any (opens in a new tab) |
return 경로에 해당하는 옵션 값 또는 undefined
propIs(prop, value): boolean (opens in a new tab)
옵션 값이 특정 값과 일치하는지 여부를 반환한다.
| Parameter | Type | Description |
|---|---|---|
| prop | keyof (opens in a new tab) BodyOptions | 설정 항목 이름 |
| value | any (opens in a new tab) | 비교할 값 |
return 일치 여부
propIsNot(prop, value): boolean (opens in a new tab)
옵션 값이 특정 값과 일치하지 않는지 여부를 반환한다.
| Parameter | Type | Description |
|---|---|---|
| prop | keyof (opens in a new tab) BodyOptions | 설정 항목 이름 |
| value | any (opens in a new tab) | 비교할 값 |
return 불일치 여부
props(props): Pick<BodyOptions, K>
지정한 옵션들의 효과 값(effective value)을 묶어서 반환한다.
여러 옵션을 destructuring으로 한꺼번에 읽을 때 사용한다.
const { color, radius } = this.props('color', 'radius');| Parameter | Type | Description |
|---|---|---|
| props | Array (opens in a new tab)<K> | 설정 항목 이름들 |
removeAt(path, render?): any (opens in a new tab)
명시적으로 설정된 하위 모델의 설정 값을 제거해서 모델의 기본 값이 적용되도록 한다.
path 매개변수는 하위 모델의 속성 이름을 점(.)으로 구분해서 지정한다.
예를 들어, "axis.x"는 axis 모델의 x 속성을 의미한다.
render와 force 매개변수는 toggleOption과 동일하다.
| Parameter | Type |
|---|---|
| path | string (opens in a new tab) |
| render | boolean (opens in a new tab) |
removeOption(prop, render?): Body
명시적으로 설정된 모델 설정 값을 제거해서 모델의 기본 값이 적용되도록 한다.
prop이 자식 모델 이름인 경우에는 해당 자식의 clearOptions(true)를 호출한다.
| Parameter | Type | Description |
|---|---|---|
| prop | keyof (opens in a new tab) BodyOptions | 설정 항목 이름 |
| render | boolean (opens in a new tab) | true로 지정하면 옵션 변경 시 컨트롤을 다시 그린다. 기본값 true |
return 모델 객체 자신
saveOption(prop): BodyOptions[K] | Record<string (opens in a new tab), any (opens in a new tab)>
옵션 값을 읽는다.
prop()과 달리 효과 값이 아닌 명시적으로 설정된 값만 읽는다. 설정되지 않은 옵션은 undefined를 반환한다.
| Parameter | Type | Description |
|---|---|---|
| prop | K | 설정 항목 이름 |
return 명시적으로 설정된 값 또는 undefined
saveOptions(props?, recursive?, includeDefs?): Partial<BodyOptions>
모델의 설정 값을 json 객체로 직렬화한다.
| Parameter | Type | Description |
|---|---|---|
| props | Record<string (opens in a new tab), any (opens in a new tab)> | Array (opens in a new tab)<keyof (opens in a new tab) BodyOptions> | 저장할 속성 필터. |
(keyof OP)[]배열: 해당 키들만 저장.- 객체 (
{ [K in keyof OP]?: any }): 객체에 정의된 키들만 저장. 자식 모델 키의 값으로 객체를 지정하면 해당 자식의saveOptions(childFilter, true, includeDefs)호출 시 필터로 전달된다. - 생략 또는 빈 배열: 모든 속성 저장. |
| recursive |
boolean(opens in a new tab) | 자식 모델까지 재귀 저장 여부. | | includeDefs |boolean(opens in a new tab) | 기본값과 동일한 값도 저장 여부. |
saveTo(target, props?, recursive?, includeDefs?): Partial<BodyOptions>
모델의 설정 값을 target 객체에 복사해서 저장한다.
| Parameter | Type |
|---|---|
| target | Partial<BodyOptions> |
| props | Array (opens in a new tab)<keyof (opens in a new tab) BodyOptions> | Record<string (opens in a new tab), any (opens in a new tab)> |
| recursive | boolean (opens in a new tab) |
| includeDefs | boolean (opens in a new tab) |
setStyle(prop, value, render?): Body
모델 css style 값을 변경한다.
value에 undefined나 null, ''을 지정하면 기존에 설정됐던 스타일 항목이 제거된다.
| Parameter | Type | Description |
|---|---|---|
| prop | string (opens in a new tab) | css 스타일 항목 이름. |
| value | any (opens in a new tab) | 적용할 스타일 값. |
render=true | boolean (opens in a new tab) | true로 지정하면 옵션 변경 시 맵차트를 다시 그린다. 기본값 true |
setStyles(props, clear?, render?): Body
여러 항목의 모델 css style 값들을 json 객체로 지정해서 동시에 변경한다.
value에 undefined나 null, ''을 지정하면 기존에 설정됐던 스타일 항목이 제거된다.
| Parameter | Type | Description |
|---|---|---|
| props | object (opens in a new tab) | 스타일 항목들과 값들이 설정된 json 객체 |
clear=false | boolean (opens in a new tab) | true로 지정하면 기존 스타일 값을 모두 제거한다. 기본값 false |
render=true | boolean (opens in a new tab) | true로 지정하면 옵션 변경 시 맵차트를 다시 그린다. 기본값 true |
toVisible(coord): MapCoord
coord는 projection 하지 않은 값.
| Parameter | Type |
|---|---|
| coord | MapCoord |
toggleAt(path, render?): any (opens in a new tab)
boolean (opens in a new tab) 타입의 모델 설정 값을 반대 값으로 변경한다.
path 매개변수는 하위 모델의 속성 이름을 점(.)으로 구분해서 지정한다.
예를 들어, "axis.x"는 axis 모델의 x 속성을 의미한다.
render와 force 매개변수는 toggleOption과 동일하다.
| Parameter | Type |
|---|---|
| path | string (opens in a new tab) |
| render | boolean (opens in a new tab) |
toggleOption(prop, render?): Body
boolean (opens in a new tab) 타입의 모델 설정 값을 반대 값으로 변경한다.
prop이 자식 모델 이름인 경우에는 아무것도 하지 않고 무시된다.
| Parameter | Type | Description |
|---|---|---|
| prop | keyof (opens in a new tab) BodyOptions | 설정 항목 이름 |
| render | boolean (opens in a new tab) | true로 지정하면 옵션 변경 시 컨트롤을 다시 그린다. 기본값 true |
return 모델 객체 자신
updateAt(path, value, render?, force?): any (opens in a new tab)
하위 모델의 설정 값을 변경한다.
path 매개변수는 하위 모델의 속성 이름을 점(.)으로 구분해서 지정한다.
예를 들어, "axis.x"는 axis 모델의 x 속성을 의미한다.
render와 force 매개변수는 updateOption과 동일하다.
| Parameter | Type |
|---|---|
| path | string (opens in a new tab) |
| value | any (opens in a new tab) |
| render | boolean (opens in a new tab) |
| force | boolean (opens in a new tab) |
zoomTo(zoom, target, duration?): void (opens in a new tab)
지정한 좌표로 zoom하고 area center로 이동한다.
| Parameter | Type | Description |
|---|---|---|
| zoom | number (opens in a new tab) | 줌 배율 |
| target | MapCoord | 지정한 좌표 |
duration=300 | number (opens in a new tab) | animation duration |
zoomToArea(areaId, ratio?, duration?, _option?): void (opens in a new tab)
지정한 area가 모두 표시되는 정도로 zoom하고 area center로 이동한다.
| Parameter | Type | Description |
|---|---|---|
| areaId | string (opens in a new tab) | |
ratio=0.8 | number (opens in a new tab) | 지정한 area를 ratio만큼 확대한다. ratio는 0보다 크고 1 이하. 기본값은 0.7 |
duration=300 | number (opens in a new tab) | animation duration |
| _option | ZoomToAreaOptions |
zoomToBounds(from, to, duration?, ratio?): void (opens in a new tab)
떨어진 두 위치로 정해지는 영역이 모두 표시되도록 zoom(in/out)하고 영역 중앙으로 이동한다.
| Parameter | Type |
|---|---|
| from | MapCoord |
| to | MapCoord |
duration=300 | number (opens in a new tab) |
ratio=0.7 | number (opens in a new tab) |