forked from aws-geospatial/amazon-location-samples-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
61 lines (56 loc) · 2.35 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!-- Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -->
<!-- SPDX-License-Identifier: MIT-0 -->
<html>
<head>
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/maplibre-gl.min.css"
rel="stylesheet"
/>
<style>
body {
margin: 0;
}
#map {
height: 100vh;
}
</style>
</head>
<body>
<div id="map" />
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/maplibre-gl.min.js"></script>
<script>
async function initializeMap() {
const apiKey = "<YOUR_AWS_API_KEY>";
const region = "<YOUR_AWS_REGION>";
// Initialize the map
const map = new maplibregl.Map({
container: "map",
// Initial map centerpoint
center: [-123.1187, 49.2819],
// Initial zoom level
zoom: 15,
style: `https://maps.geo.${region}.amazonaws.com/v2/styles/Standard/descriptor?key=${apiKey}`,
validateStyle: false, // Disable style validation for faster map load
});
// Add navigation controls
map.addControl(
new maplibregl.NavigationControl(),
"top-left"
);
// Configure a new popup
const popup = new maplibregl.Popup({
offset: 35,
}).setHTML(
`<h3>Amazon YVR11</h3>
<p>510 W Georgia St #14, Vancouver, BC V6B 0M3</p>`
);
// Add a new marker and popup
const marker = new maplibregl.Marker()
.setLngLat([-123.11685, 49.2811])
.setPopup(popup)
.addTo(map);
}
initializeMap();
</script>
</body>
</html>