-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmapbox-2.html
33 lines (28 loc) · 1.04 KB
/
mapbox-2.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>mapbox-2</title>
<link href='https://api.mapbox.com/mapbox-gl-js/v2.4.1/mapbox-gl.css' rel='stylesheet' />
<script src="js/keys.js"></script>
</head>
<body>
<script src='https://api.mapbox.com/mapbox-gl-js/v2.4.1/mapbox-gl.js'></script>
<div id='map' style='width: 400px; height: 300px;'></div>
<script>
mapboxgl.accessToken = MAP_BOX_API_TOKEN;
const map = new mapboxgl.Map({
container: 'map', // container ID
style: 'mapbox://styles/mapbox/streets-v11', // style URL
center: [-77.050636, 38.889248], // starting position [lng, lat]
zoom: 12 // starting zoom
});
let memorinalPopup = new mapboxgl.Popup().setHTML("<h3>Lincoln Memorial</h3>")
let marker = new mapboxgl.Marker({draggable: true}).setLngLat([-77.050636, 38.889248]).setPopup(memorinalPopup).addTo(map);
marker.on('dragend', function() {
let newCoordinates = marker.getLngLat();
memorinalPopup.setHTML(newCoordinates.lng);
});
</script>
</body>
</html>