-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmapbox.html
More file actions
49 lines (39 loc) · 1.32 KB
/
mapbox.html
File metadata and controls
49 lines (39 loc) · 1.32 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>mapbox</title>
<link href='https://api.mapbox.com/mapbox-gl-js/v2.2.0/mapbox-gl.css' rel='stylesheet' />
</head>
<body>
<h1></h1>
<div id='map' style= 'width: 600px; height: 500px;'></div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script src="js/keys.js"></script>
<script src='https://api.mapbox.com/mapbox-gl-js/v2.2.0/mapbox-gl.js'></script>
<script>
mapboxgl.accessToken = MAPBOX_ACCESS_TOKEN;
var map = new mapboxgl.Map({
container: 'map', // container ID
style: 'mapbox://styles/mapbox/streets-v11', // style URL
center: [-74.2179, 43.2994], // starting position [lng, lat]
zoom: 5 // starting zoom
});
var marker = new mapboxgl.Marker({
color: "red",
draggable: true
}).setLngLat([-74.0445, 40.6892])
.addTo(map);
var popup = new mapboxgl.Popup()
.setLngLat(marker.getLngLat())
.setHTML("<h3>Statue of Liberty</h3>")
.setMaxWidth("100px")
.addTo(map)
marker.setPopup(popup);
marker.on('dragend' ,function(){
$("h1").html(marker.getLngLat().toString())
marker.setPopup()
})
</script>
</body>
</html>