0.4.0 • Published 6 months ago
@42dot/maps-platform-js v0.4.0
Maps Platform JS
Maps Platform JS는 42dot이 제공하는 Map, Direction, Place API등의 사용을 위한 JS 라이브러리입니다.
Maps Platform 지도, 경로안내, 주소검색, 공간검색, 실시간 교통정보 검색 등 다양한 기능을 제공합니다.
Installation
HTML에 script 태그로 설치하는 방법과 npm을 이용하는 방법 두가지를 제공하고 있습니다.
- <script>를 이용한 방법
<script src="https://static.maps.umos.ai/sdk/v1/maps.js"></script>- npm을 이용한 방법
$ npm install @42dot/maps-platform-jssetClientCredentials
setClientCredentials에서clientId,clientSecret과 함께 사용할 맵 라이브러리를 추가로 지정해야 합니다.mapbox-gl,maplibre-gl두 가지 맵 라이브러리를 선택하여 사용할 수 있습니다.- 정상적인 SDK 사용을 위해서는 선택한 맵 라이브러리의 dependencies를 설치해야 합니다.
mapbox-gl를 사용할 경우, 맵 초기화 시accessToken을 파라미터로 전달해야 합니다.
1. MapLibre 사용 방법
1.1. 설치
npm install maplibre-gl1.2. 설정
import maplibre from "maplibre-gl";
setClientCredentials(
"{{clientId}}",
"{{clientSecret}}",
import("maplibre-gl"), // 사용할 라이브러리 지정
{
env: "{{int|real|stage}}",
},
);1.3. 맵 초기화
const map = new Map(mapRef.current, {});2. Mapbox 사용 방법
2.1. 설치
npm install mapbox-gl2.2. 설정
import mapboxgl from "mapbox-gl";
setClientCredentials(
"{{clientId}}",
"{{clientSecret}}",
import("mapboxgl-gl"), // 사용할 라이브러리 지정
{
env: "{{int|real|stage}}",
},
);2.3. 맵 초기화 (Access Token 필요)
const map = new Map(mapRef.current, {
accessToken: process.env.MAPBOX_ACCESS_TOKEN,
});Common Interface
Coordinates
지도의 경위도 좌표를 나타내는 클래스입니다.
| Field | Type | Description |
|---|---|---|
| lat | number | 위도 |
| lon | number | 경도 |
CoordinatesLike
지도 상의 좌표를 표현하는 다양한 형식을 정의합니다.
- CoordinatesArray 형식의 배열
- 객체 형식
{ lon: number; lat: number } - Coordinates 클래스 Instance
CoordinatesLong
latitude,longitude 에 대응하기 위한 interface coordinate 형식입니다.
| Field | Type | Description |
|---|---|---|
| latitude | number | 위도 |
| longitude | number | 경도 |
CoordinatesArray
경위도를 경도, 위도 형식으로 표현하는 배열입니다.
| 인덱스 | Description | Type |
|---|---|---|
| 0 | 경도 (longitude) | number |
| 1 | 위도 (latitude) | number |
예시: [126.9780, 37.5665]는 경도 126.9780, 위도 37.5665를 나타냅니다.
CoordinatesBounds
지도의 경계 영역을 나타내는 클래스입니다.
| Field | Type | Description |
|---|---|---|
| sw | Coordinates | 남서쪽 모서리 좌표 |
| ne | Coordinates | 북동쪽 모서리 좌표 |
CoordinatesBoundsLike
CoordinatesBoundsLike는 지도 경계 영역을 표현하는 두 가지 형식을 지원합니다.
| 형식 | Description |
|---|---|
| CoordinatesBounds | sw와 ne Field를 사용하여 남서쪽과 북동쪽 모서리 좌표를 나타내는 클래스 |
[number, number, number, number] 배열 | [남서쪽 경도, 남서쪽 위도, 북동쪽 경도, 북동쪽 위도] 형식의 number 배열 |
예시
- CoordinatesBounds 객체:
{ sw: { lon: 126.0, lat: 37.0 }, ne: { lon: 127.0, lat: 38.0 } } - 배열:
[126.0, 37.0, 127.0, 38.0](남서쪽 경도 126.0, 위도 37.0과 북동쪽 경도 127.0, 위도 38.0)
0.2.21
11 months ago
0.2.20
12 months ago
0.3.0
10 months ago
0.3.2
8 months ago
0.4.0
6 months ago
0.3.1
9 months ago
0.3.4
7 months ago
0.3.3
8 months ago
0.2.16
1 year ago
0.2.19
1 year ago
0.2.18
1 year ago
0.2.17
1 year ago
0.2.15
1 year ago
0.2.14
1 year ago
0.2.13
1 year ago
0.2.12
1 year ago
0.2.11
1 year ago
0.2.10
1 year ago
0.2.7
1 year ago
0.2.6
1 year ago
0.2.9
1 year ago
0.2.8
1 year ago
0.2.5
2 years ago
0.2.4
2 years ago
0.2.3
2 years ago
0.2.2
2 years ago
0.2.1
2 years ago
0.2.0
2 years ago