As traduções são geradas por tradução automática. Em caso de conflito entre o conteúdo da tradução e da versão original em inglês, a versão em inglês prevalecerá.
Como criar um mapa 3D
O Amazon Location Service permite adicionar recursos tridimensionais aos mapas, como Terrain3D exibir dados de elevação como uma superfície tridimensional ou Buildings3D exibir estruturas urbanas com altura e volume.
Crie um mapa com detalhes tridimensionais do terreno
Este exemplo mostra como criar um mapa com Terrain3D parâmetros.
- 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;
}
Crie um mapa com detalhes tridimensionais de edifícios
Este exemplo mostra como criar um mapa com Buildings3D parâmetros.
- 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;
}
Ativar/desativar a visualização do globo
Este exemplo mostra como ativar ou desativar a projeção da vista do globo. Por padrão, a visualização do globo está ativada.
- index.html
-
<!DOCTYPE html>
<html lang="en">
<head>
<title>Globe View</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?key=${apiKey}`,
center: [-74.5, 40],
zoom: 2,
validateStyle: false, // Disable style validation for faster map load
});
map.on('style.load', () => {
// Globe view is enabled by default
// To disable globe view, uncomment the next line:
// map.setProjection({});
});
</script>
</body>
</html>
- style.css
-
body {
margin: 0;
padding: 0;
}
#map {
width: 100%;
height: 100vh;
}