本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
如何在地圖上顯示 3D 功能
Amazon Location Service 可讓您新增要映射的三維功能,例如Terrain3D將海拔資料顯示為三維表面,或Buildings3D顯示具有高度和體積的都會結構。
建立具有三維地形詳細資訊的映射
此範例說明如何使用 Terrain3D 參數建立映射。
- index.html
-
<!DOCTYPE html> <html lang="en"> <head> <title>3D Terrain</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?terrain=Terrain3D&key=${apiKey}`, center: [7.6583, 45.9763], zoom: 12, pitch: 60, // Tilt angle (0-85 degrees) validateStyle: false, // Disable style validation for faster map load }); </script> </body> </html> - style.css
-
body { margin: 0; padding: 0; } #map { width: 100%; height: 100vh; }
建立具有三維建築物詳細資訊的地圖
此範例說明如何使用 Buildings3D 參數建立映射。
- index.html
-
<!DOCTYPE html> <html lang="en"> <head> <title>3D Buildings</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?buildings=Buildings3D&key=${apiKey}`, center: [7.6583, 45.9763], zoom: 12, pitch: 60, // Tilt angle (0-85 degrees) validateStyle: false, // Disable style validation for faster map load }); </script> </body> </html> - style.css
-
body { margin: 0; padding: 0; } #map { width: 100%; height: 100vh; }
在地圖上顯示傳輸詳細資訊
靜態映射