-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmapbox-lec.html
More file actions
58 lines (53 loc) · 1.91 KB
/
mapbox-lec.html
File metadata and controls
58 lines (53 loc) · 1.91 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
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
<meta charset="UTF-8">
<title>First Mapbox Map</title>
<!-- Mapbox JS -->
<script src='https://api.mapbox.com/mapbox-gl-js/v2.10.0/mapbox-gl.js'></script>
<!-- Mapbox CSS -->
<link href='https://api.mapbox.com/mapbox-gl-js/v2.10.0/mapbox-gl.css' rel='stylesheet'>
<style>
#map {
/* the width and height may be set to any size */
width: 100%;
height: 700px;
}
</style>
</head>
<body>
<h1>My First Mapbox Map!</h1>
<!-- The HTML element that serves as the Mapbox container -->
<div id='map'></div>
<script src="js/keys.js"></script>
<script src="js/mapbox-geocoder.js"></script>
<!-- Custom JS -->
<script>
//----------------------------------------mapbox gl map-------------------------------------------------------------
mapboxgl.accessToken = MAPBOX_TOKEN;
let map = new mapboxgl.Map({
container: 'map', // container ID
style: 'mapbox://styles/mapbox/streets-v11', // style URL
zoom: 10, // starting zoom
center: [-98.4916, 29.4252] // [lng, lat]
});
//----------------------------------------mapbox gl marker--------------------------------------------------------------
//setting a marker object
let marker = new mapboxgl.Marker()
//setting marker object location
.setLngLat([-98.4916, 29.4252])
//adding marker to map
.addTo(map)
//----------------------------------------mapbox gl popup-----------------------------------------------------------
let popup = new mapboxgl.Popup()
.setLngLat([-98.4916, 29.4252])
.setHTML("<h1>San Antonio</p>")
marker.setPopup(popup)
// ------------------------------------------mapbox gl geocoder-------------------------------------------------------
let currentLocation = geocode("Allen", MAPBOX_TOKEN);
currentLocation.then(function (results){
console.log(results)
})
</script>
</body>
</html>