

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

# 맵에 실시간 트래픽을 표시하는 방법
<a name="how-to-set-real-time-traffic-map"></a>

 Amazon Location Service를 사용하여 맵에 트래픽 기능을 추가할 수 있습니다. 이를 통해 실시간 트래픽 데이터를 제공하여 현재 도로 정체, 건설 및 인시던트와 같은 현재 교통 상황을 표시할 수 있으므로 라우팅을 선택할 수 있습니다.

## 실시간 트래픽이 포함된 맵 만들기
<a name="how-to-set-real-time-traffic"></a>

이 예제에서는 실시간 트래픽 데이터가 포함된 맵을 생성하는 방법을 보여줍니다.

### 실시간 트래픽 예제
<a name="how-to-set-real-time-traffic-code"></a>

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

```
<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Traffic Map</title>
        <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' />
                <script src='https://unpkg.com/maplibre-gl@5.x/dist/maplibre-gl.js'></script>
    </head>
    <body style="margin: 0; padding: 0;">
        <div id="map" style="width: 100%; height: 100vh;"></div>
        <script>
            const apiKey = "Add Your Api Key";
            const mapStyle = "Standard";
            const awsRegion = "us-east-1";

            const map = new maplibregl.Map({
                container: 'map',
                style: `https://maps.geo.${awsRegion}.amazonaws.com/v2/styles/${mapStyle}/descriptor?traffic=All&key=${apiKey}`,
                center: [-74.0060 ,40.7128], // New York City coordinates for traffic visibility
                zoom: 12,
                validateStyle: false, // Disable style validation for faster map load
            });
        </script>
    </body>
</html>
```

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

```
body {
    margin: 0;
    padding: 0;
}

#map {
    width: 100%;
    height: 100vh;
}
```

------