-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.html
151 lines (146 loc) · 8.12 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<!-- 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: 13,
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("vancouver-downtown", {
type: "geojson",
data: {
type: "Feature",
geometry: {
type: "Polygon",
coordinates: [
[
[
-123.11226,
49.29016,
],
[
-123.10424,
49.28816,
],
[
-123.09928,
49.28927,
],
[
-123.09999,
49.27275,
],
[
-123.10169,
49.27297,
],
[
-123.11107,
49.27292,
],
[
-123.11444,
49.27177,
],
[
-123.12116,
49.26953,
],
[
-123.12928,
49.26953,
],
[
-123.13768,
49.27531,
],
[
-123.13233,
49.27693,
],
[
-123.12109,
49.28436,
],
[
-123.13668,
49.29445,
],
[
-123.13468,
49.29581,
],
[
-123.12271,
49.2915,
],
[
-123.11226,
49.29016,
],
],
],
},
},
});
// Add a new layer to visualize the polygon.
map.addLayer({
id: "vancouver-downtown",
type: "fill",
source: "vancouver-downtown", // reference the data source
layout: {},
paint: {
"fill-color": "#0080ff", // blue color fill
"fill-opacity": 0.5,
},
});
// Add an outline around the polygon.
map.addLayer({
id: "outline",
type: "line",
source: "vancouver-downtown",
layout: {},
paint: {
"line-color": "#000",
"line-width": 3,
},
});
});
}
initializeMap();
</script>
</body>
</html>