-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmapbox_maps_api.html
More file actions
104 lines (82 loc) · 3.09 KB
/
mapbox_maps_api.html
File metadata and controls
104 lines (82 loc) · 3.09 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<!DOCTYPE html>
<html lang="en">
<head>
<h1 text align="center">MY FIRST MAP</h1>
<!-- added this button to hide shit, still figuring out how to get it to work-->
<!-- <button id="button" class="button">Lost in the Sauce</button>-->
<meta charset="UTF-8">
<title>Mapbox</title>
<link href="https://api.mapbox.com/mapbox-gl-js/v2.10.0/mapbox-gl.css" rel="stylesheet">
<style>
#map{
width: 100%;
height: 500px;
}
</style>
</head>
<body>
<div id="map"></div>
<script src="js/mapbox-geocoder-utils.js"></script>
<script src="https://api.mapbox.com/mapbox-gl-js/v2.10.0/mapbox-gl.js"></script>
<script>
const key = "pk.eyJ1Ijoia2hlY3RvciIsImEiOiJjbDluOGdldmwwMDR2M3lxdXRxcjJpbTl6In0.BLF1x_19wpttTX_PatJoeg";
mapboxgl.accessToken = key;
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v9',
//TODO: Set your own zoom and center
zoom: 5,
center: [-85.313828, 35.081980]
});
//TODO: Set zoom on your own with a map.setZoom call in your console
//map.jumpTo, map.flyTo look them up zoom: 14
// let marker = new mapboxgl.Marker()
// .setLngLat([-98.646666, 29.51036])
// .addTo(map)
//TODO: Add your own marker to where we've aligned your map so far
//I do: set a pop up on my house
// let popup = new mapboxgl.Popup()
// .setLngLat([-98.646666, 29.51036])
// .setHTML("<p>Kens</p>")
// .addTo(map)
//TODO: Use the geocode method to add a 2nd marker and popup to your map, then center your map over it
geocode("111 Tower rock lane", key).then(function (result){
console.log(result)
let marker2 = new mapboxgl.Marker()
.setLngLat(result)
// .setPopup(
// new mapboxgl.Popup({ offset: 25 }) // add popups
// .setHTML("<h3>Pat's BBq Best BBQ</h3>" +
// "<p>Best Bbq</p>")
.addTo(map)
let popup2 = new mapboxgl.Popup()
.setLngLat(result)
.setHTML("<h3>Pat's BBq Best BBQ</h3>" +
"<p>Best Bbq</p>")
.addTo(map)
})
geocode("301 Cherokee Blvd., Chattanooga, TN 37405", key).then(function (result){
console.log(result)
let marker3 = new mapboxgl.Marker()
.setLngLat(result)
.addTo(map)
let popup3 = new mapboxgl.Popup()
.setLngLat(result)
.setHTML("<h3>El Embargo</h3>" +
"<p> Best Cubano</p>")
.addTo(map)
})
geocode("200 S Front St, Cobden, IL 62920", key).then(function (result) {
console.log(result)
let marker4 = new mapboxgl.Marker()
.setLngLat(result)
.addTo(map)
let popup4 = new mapboxgl.Popup()
.setLngLat(result)
.setHTML("<p>Iron Whsik Best Brunch</p>")
.addTo(map)
})
//TODO: Try a reverse geocode yourself and see what address you get back for your coordinates - remember to send up a {lng: <lng>, lat: <lat>} object
</script>
</body>
</html>