-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmapbox_maps_api.html
More file actions
90 lines (72 loc) · 2.15 KB
/
mapbox_maps_api.html
File metadata and controls
90 lines (72 loc) · 2.15 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!DOCTYPE html>
<html lang="en">
<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>
let placesToEat = [
{
"restaurants":"Pappadeaux",
"Coordinates": [" -95.35938287422074", "29.7602999471777"]
}
,
{
"restaurants":"Pappa",
"Coordinates": [ "-95.36748532877176" ,"29.75462690757553"]
}
]
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: [-95.358421, 29.749907] // [lng, lat]
});
placesToEat.forEach(place => {
console.log(place.Coordinates[0])
let marker= new mapboxgl.Marker()
.setLngLat([ place.Coordinates[0], place.Coordinates[1] ])
.addTo(map);
let popup= new mapboxgl.Popup()
.setLngLat([place.Coordinates[0], place.Coordinates[1]])
.setHTML("<p>"+place.restaurants +"</p>")
.addTo(map)
marker.setPopup(popup)
})
// adding a marker
// let marker = new mapboxgl.Marker()
// .setLngLat([ -95.2960, 29.7004 ])
// .addTo(map);
//pop-up
// let popup = new mapboxgl.Popup()
// .setLngLat([-95.2960, 29.7004])
// .setHTML("<p>Boudreaux's</p>")
// .addTo(map)
// marker.setPopup(popup)
// marker.addEventListener("click", popup())
// marker.setPopup(popup)
// let currentLocation = geocode('Allen',MAPBOX_TOKEN)
// currentLocation.then(function (){
//
// })
</script>
</body>
</html>