-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmapbox-lecture.html
More file actions
55 lines (47 loc) · 1.77 KB
/
mapbox-lecture.html
File metadata and controls
55 lines (47 loc) · 1.77 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Mapbox</title>
<script src='https://api.mapbox.com/mapbox-gl-js/v2.14.1/mapbox-gl.js'></script>
<link href='https://api.mapbox.com/mapbox-gl-js/v2.14.1/mapbox-gl.css' rel='stylesheet' />
<link rel='stylesheet' href='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v4.7.0/mapbox-gl-geocoder.css' type='text/css' />
<style>
#map {
width: 100%;
height: 700px;
}
</style>
</head>
<body>
<div id='map'></div>
<script src='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v4.7.0/mapbox-gl-geocoder.min.js'></script>
<script src="js/keys.js"></script>
<script>
mapboxgl.accessToken = MAPBOX_KEY;
const map = new mapboxgl.Map({
container: 'map', // container ID
style: 'mapbox://styles/mapbox/streets-v12', // style URL
center: [-98.4916, 29.4260], // starting position [lng, lat]
zoom: 10, // starting zoom
});
let marker = new mapboxgl.Marker().setLngLat([-98.6089, 29.5994]).addTo(map);
let popup = new mapboxgl.Popup().setHTML("<p>Six Flags!</p>");
marker.setPopup(popup);
let marker2 = new mapboxgl.Marker().setLngLat([-98.643, 29.555]).addTo(map);
let popup2 = new mapboxgl.Popup().setHTML("<p>HEB!</p>");
marker2.setPopup(popup2);
const geocoder = new MapboxGeocoder({
// Initialize the geocoder
accessToken: mapboxgl.accessToken, // Set the access token
mapboxgl: mapboxgl, // Set the mapbox-gl instance
marker: false // Do not use the default marker style
});
// Add the geocoder to the map
map.addControl(geocoder);
geocoder.on('result', (event) => {
console.log(event);
});
</script>
</body>
</html>