-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmapbox_maps_api.html
More file actions
60 lines (59 loc) · 2.06 KB
/
mapbox_maps_api.html
File metadata and controls
60 lines (59 loc) · 2.06 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
56
57
58
59
60
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Mapbox Lecture</title>
<script src="js/keys.js"></script>
<script src='https://api.mapbox.com/mapbox-gl-js/v2.13.0/mapbox-gl.js'></script>
<link href='https://api.mapbox.com/mapbox-gl-js/v2.13.0/mapbox-gl.css' rel='stylesheet' />
<link rel="stylesheet" href="css/resets.css">
<link rel="stylesheet" href="css/layout.css">
<link rel="stylesheet" href="css/mapbox-lecture.css">
</head>
<body>
<div class="page-wrapper">
<div class="container">
<div class="row">
<div class="column justify-center align-center text-center">
<h1>Matt's Virginia Karaoke Bars</h1>
<div id='map' style='width: 80%; height: 700px;'></div>
<div class="row">
<form class="column justify-center align-center text-center gap-10">
<label for="zoom">Set zoom:</label>
<input type="text" name="zoom" id="zoom">
<button id="zoomSubmit">Zoom</button>
</form>
<form class="column justify-center align-center text-center gap-10">
<label for="setMarker">Enter an address:</label>
<input type="text" name="setMarker" id="setMarker">
<button id="setMarkerButton">Set Marker</button>
</form>
</div>
</div>
</div>
</div>
</div>
<script src="js/mapbox-geocoder-utils.js"></script>
<script>
mapboxgl.accessToken = MAPBOX_API_TOKEN;
const map = new mapboxgl.Map({
container: 'map', // container ID
style: 'mapbox://styles/mapbox/outdoors-v12', // style URL
center: [ -77.89077475434503,38.502928434113876], // starting position [lng, lat]
zoom: 8, // starting zoom
});
let marker = new mapboxgl.Marker({
draggable: true
})
.setLngLat([-74.5, 40])
.addTo(map);
// Get the marker's coordinates when it is moved
marker.on('dragend', function () {
var lngLat = marker.getLngLat();
console.log('Longitude:', lngLat.lng);
console.log('Latitude:', lngLat.lat);
});
</script>
<script src="js/mapbox_maps_api.js"></script>
</body>
</html>