입력받은 층 이름에 해당하는 층으로 지도를 변경합니다. 현재 렌더링된 건물중에 현재 렌더링된 언어의 지도명을 가진 층이 있다면 그 층으로 층변경합니다 통합지도일 때는, 렌더링 되지 않은 건물일 경우 건물을 렌더링하고 층변경합니다. 비동기 처리를 해주셔야합니다.
변경할 층의 이름
await map.context.changeFloorByName('1F'); // 층 이름이 '1F'에 해당하는 층으로 모든 층을 변경한다.
현재 poi들의 언어 설정을 변경해줍니다.
"ko" | "zh" | "en" | "ja"
한국어, 중국어, 영어, 일본어 설정값은 ISO_639-1_codes 참조
map.context.changeLanguage('en');
지도의 오브젝트, POI, 마커를 png로 캡쳐합니다. floorAll (기본값: false) 옵션은 graphicLibrary: 2d 에서만 사용할 수 있습니다. useShowMapOption (기본값: false) 옵션을 통해 showMap 으로 그린 지도 그대로 저장할 수 있습니다. graphicLibrary: '2d'로 showMap() 하였을 때 더 좋은 해상도로 다운됩니다. 캡처시 poiFontFixedSize 속성은 적용되지 않습니다.
지도 이미지 캡처 속성
원본 지도 이미지 크기 대비 캡처 이미지 크기 비율
option = {
filename?: string; (.png format으로 다운로드됨. 지정안하는 경우 지도명(빌딩명)_층명.png 로 저장됨 예: [배포]현대백화점-더현대서울점(파크원)_1F.png)
floorAll?: boolean (graphicLibrary: '2d' 에서만 사용 가능, true 일 경우 모든 층이 저장됨)
useShowMapOption?: boolean (true 일 경우 showMap 으로 그린 모습으로 저장됨)
}
map.context.convertToImg(option);
map 좌표를 layer 좌표로 변환합니다. poi-click 등에서 받은 map 좌표를 moveTo 등 layer 좌표가 필요한 API에 전달할 때 사용합니다.
map 좌표 {x, y}
해당 층의 ID
layer 좌표 {x, y}
const poi = e.detail[0];
const layerCoord = map.context.convertToLayerCoords(poi.position, poi.floorId);
map.control.moveTo({ position: layerCoord });
on-mouse-click 이벤트에서 받은 layer 좌표를 해당 층의 map 좌표로 변환합니다. on-mouse-click 이벤트는 coordType: 'layer' 좌표를 반환하므로, markers.set() 등에 전달하기 전에 이 함수로 변환해야 합니다.
on-mouse-click 이벤트에서 받은 좌표 {x, y}
마커를 배치할 층의 ID
해당 층의 map 좌표 {x, y}
container.addEventListener('on-mouse-click', async (e) => {
const pos = e.detail; // { x, y, coordType: 'layer' }
const floorId = map.context.getCurrentFloor().id;
const mapCoord = pos.coordType && pos.coordType === 'layer' ? map.context.convertToMapCoords(pos, floorId) : pos;
await map.markers.set({
marker: [{ x: mapCoord.x, y: mapCoord.y, floorId }]
});
});
지도를 pdf로 캡쳐합니다. filesize가 크게 나옵니다. 약 300MB, png는 약 10~30 MB일때 ratio : number; // 원본 지도 해상도에 대한 캡처 화면 비율 0 ~ 5 사이의 실수. 단, 사용가능한 최대 ratio를 넘으면 최대 ratio로 적용됨
지도 이미지 캡처 속성
number | undefined 성공시: 적용된 ratio 비율 반환 재시도 필요시 : -1 반환 실패시 : undefined 반환
const { jsPDF } = window.jspdf;
const size = mapContainer.getBoundingClientRect();
// 'l', // p: 세로(기본), l: 가로, 큰 숫자가 가로가 됨
// 'px', // 단위: "pt", "mm", "cm", "in", "px" 등
// [size.width, size.height], //
let ratio = 5;
let result;
while (true) {
const pdf = new jsPDF(
'l',
'px',
[size.width, size.height], // 포맷 (페이지 크기).
);
result = await map.context.convertToPdf({ ratio, filename: 'capturePdf', pdf: pdf });
if (result > 0) break; // 정상으로 출력되었으므로 종료
if (result === undefined) break; // 이상동작이므로 종료
if (ratio < 1) break; // while문이 계속 도는 것을 막기 위하여 종료
ratio = ratio * 0.9;
}
console.log('result', result);
Returns the center coordinates of the currently rendered building. The coordinates use the same coordinate system as cameraMoveTo(), markers.set(), etc.
The ID of the building to get the center coordinates for
The building center coordinates {x, y}, or undefined if the building is not rendered
const center = map.context.getBuildingCenterPosition('building-id-123');
if (center) {
map.control.moveTo({ position: { x: center.x, y: center.y }, transition: true });
}
현재 화면안에 있는 Buliding의 정보를 가져옵니다 옵션에 따라 현재 보이는 화면에서 렌더링 되고 있는 Building을 가져옵니다. 실외지도는 항상 마지막에 정렬됩니다
Optional filterOptions: ICurrentBuildingsconst filterOptions = {
sortOption:{
center: {x:1500,y:1000,z:0}, // 주어진 center중심으로 부터 거리를 계산하여 sort합니다. center가 없으면(default는) 카메라의 position을 중심으로 거리를 계산합니다.
byAsc: true // true라면 오름차순(ASC): 작은 값부터 큰 값 쪽으로의 순서, false라면 내림차순(DESC): 큰 값부터 작은 값 쪽으로의 순서로 sort합니다. (default=true)
}
}
map.context.getCurrentBuildings(filterOptions);
@returns filtering된 Building array
현재 층 정보를 가져옵니다.
현재 층 정보
사용자가 설정한 mapOption 을 반환합니다.
사용자가 설정한 mapOption
Map 관련 API를 호출 할 수 있는 Class