

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# 맵에 컨트롤을 추가하는 방법
<a name="how-to-add-control-on-map"></a>

Amazon Location Service를 사용하면 탐색, 지리적 위치, 전체 화면, 규모 조정 및 속성 컨트롤을 포함한 여러 컨트롤을 맵에 추가할 수 있습니다.
+ **탐색 컨트롤**: 확대/축소 버튼과 나침반이 포함되어 있습니다.
+ **지리적 위치 컨트롤**: 브라우저의 지리적 위치 API를 사용하여 맵에서 사용자를 찾는 버튼을 제공합니다.
+ **전체 화면 컨트롤**: 맵을 전체 화면 모드로 전환하거나 해제하는 버튼이 포함되어 있습니다.
+ **규모 조정 컨트롤**: 맵상의 거리와 지면상의 해당 거리의 비율을 표시합니다.
+ **속성 컨트롤**: 맵의 속성 정보를 제공합니다. 기본적으로 속성 컨트롤은 확장됩니다(맵 너비에 관계없음).

왼쪽 상단, 왼쪽 하단, 오른쪽 하단 또는 오른쪽 상단 등 맵의 모든 모서리에 컨트롤을 추가할 수 있습니다.

## 맵 컨트롤 추가
<a name="add-map-controls"></a>

다음 예제에서는 위에 나열된 맵 컨트롤을 추가합니다.

### 맵 컨트롤 코드 예제
<a name="web-code-example"></a>

------
#### [ index.html ]

```
<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Map Controls</title>
        <meta property="og:description" content="Initialize a map in an HTML element with MapLibre GL JS." />
        <meta charset='utf-8'>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel='stylesheet' href='https://unpkg.com/maplibre-gl@5.x/dist/maplibre-gl.css' />
        <link rel='stylesheet' href='style.css' />
        <script src='https://unpkg.com/maplibre-gl@5.x/dist/maplibre-gl.js'></script>
    </head>
    <body>
        <!-- Map container -->
        <div id="map"></div>
        <script>
            const apiKey = "<API_KEY>";
            const mapStyle = "Standard"; // e.g., Standard, Monochrome, Hybrid, Satellite
            const awsRegion = "eu-central-1"; // e.g., us-east-2, us-east-1, us-west-2, etc.
            const styleUrl = `https://maps.geo.${awsRegion}.amazonaws.com/v2/styles/${mapStyle}/descriptor?key=${apiKey}`;

            const map = new maplibregl.Map({
                container: 'map', // container id
                style: styleUrl, // style URL
                center: [-123.13203602550998, 49.28726257639254], // starting position [lng, lat]
                zoom: 10, // starting zoom
                attributionControl: false, // hide default attributionControl in bottom left
            });

            // Adding controls to the map
            map.addControl(new maplibregl.NavigationControl()); // Zoom and rotation controls
            map.addControl(new maplibregl.FullscreenControl()); // Fullscreen control
            map.addControl(new maplibregl.GeolocateControl()); // Geolocation control
            map.addControl(new maplibregl.AttributionControl(), 'bottom-left'); // Attribution in bottom-left
            map.addControl(new maplibregl.ScaleControl(), 'bottom-right'); // Scale control in bottom-right
        </script>
    </body>
</html>
```

------
#### [ style.css ]

```
body { margin: 0; padding: 0; }
html, body, #map { height: 100%; }
```

------

## 개발자 팁
<a name="developer-tips"></a>

### 탐색 컨트롤 옵션
<a name="navigationcontrol-options"></a>

```
new maplibregl.NavigationControl({ 
    showCompass: true, // show or hide compass (default: true)
    showZoom: true // show or hide zoom controls (default: true)
});
```

### 지리적 위치 컨트롤 옵션
<a name="geolocatecontrol-options"></a>

```
new maplibregl.GeolocateControl({ 
    positionOptions: { enableHighAccuracy: true }, // default: false
    trackUserLocation: true // default: false
});
```

### 속성 컨트롤 옵션
<a name="attributioncontrol-options"></a>

```
new maplibregl.AttributionControl({
    compact: true, // compact (collapsed) mode (default: false)
});
```

### 규모 조정 컨트롤 옵션
<a name="scalecontrol-options"></a>

```
new maplibregl.ScaleControl({ 
    maxWidth: 100, // width of the scale (default: 50)
    unit: 'imperial' // imperial or metric (default: metric)
});
```

### 전체 화면 컨트롤 옵션
<a name="fullscreencontrol-options"></a>

```
map.addControl(new maplibregl.FullscreenControl({
    container: document.querySelector('body') // container for fullscreen mode
}));
```