

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 如何在地圖上顯示傳輸詳細資訊
<a name="how-to-show-transit-details-map"></a>

Amazon Location Service 可讓您將傳輸功能新增至映射。`Transit` `TravelMode` 會顯示公有傳輸的路由資訊，例如顏色編碼的訓練線。另請查看如何為其他選項設定[物流 TravelMode](https://docs.aws.amazon.com/location/latest/developerguide/how-to-create-logistic-map.html)。

## 建立具有傳輸詳細資訊的映射
<a name="how-to-show-transit-map"></a>

此範例說明如何使用 Transit TravelMode 建立具有傳輸詳細資訊的地圖以供大眾運輸。

### 傳輸範例
<a name="how-to-show-transit-map-code"></a>

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

```
<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Transit 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?travel-modes=Transit&key=${apiKey}`,
                center: [-74.0060 ,40.7128],
                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;
}
```

------