-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.html
84 lines (79 loc) · 3.7 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<!-- 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.12128, 49.281],
// Initial zoom level
zoom: 14,
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"
);
map.on("load", () => {
// Add a data source containing GeoJSON data.
map.addSource("route", {
type: "geojson",
data: {
type: "Feature",
geometry: {
type: "LineString",
coordinates: [
[-123.12882, 49.27676],
[-123.11914, 49.28314],
[-123.1231, 49.2857],
[-123.12598, 49.28388],
[-123.12965, 49.28635],
[-123.13597, 49.28208],
[-123.14136, 49.28552],
],
},
},
});
// Add a new layer to visualize the line.
map.addLayer({
id: "route",
type: "line",
source: "route",
layout: {
"line-join": "round",
"line-cap": "round",
},
paint: {
"line-color": "#00b0ff",
"line-width": 8,
},
});
});
}
initializeMap();
</script>
</body>
</html>