-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmapbox_maps_api.html
More file actions
130 lines (110 loc) · 3.62 KB
/
mapbox_maps_api.html
File metadata and controls
130 lines (110 loc) · 3.62 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>mapbox_maps_api.html</title>
<script src='https://api.mapbox.com/mapbox-gl-js/v2.8.2/mapbox-gl.js'></script>
<link href='https://api.mapbox.com/mapbox-gl-js/v2.8.2/mapbox-gl.css' rel='stylesheet' />
<script src="js/geocode_utils.js"></script>
</head>
<body>
<div id='map' style='width: 95vw; height: 75vh; margin: auto '></div>
<h1 id="place"></h1>
<script src="js/keys.js"></script>
<script>
mapboxgl.accessToken = MAPBOX_API_KEY;
const map = new mapboxgl.Map({
container: 'map', // container ID
style: 'mapbox://styles/mapbox/streets-v11', // style URL
center: [-98.4946, 29.42], // starting position [lng, lat]
zoom: 9,// starting zoom
});
const CITYMARKER = new mapboxgl.Marker()
.setLngLat([-98.4896, 29.4269])
.setDraggable(true)
.addTo(map);
// CITYMARKER.setLngLat([-98.9878, 29.6870]);
function CITYANDREST () {
geocode("San Antonio tx", MAPBOX_API_KEY).then(function (data) {
let popUp = new mapboxgl.Popup()
.setHTML("<p>This is the city where my favorite restaurant is </p>");
const MYFAVCITY = new mapboxgl.Marker()
.setLngLat(data)
.addTo(map.setZoom(11))
.setPopup(popUp);
// popUp.addTo(map);
});
}
console.log(CITYANDREST());
function FAVREST () {
geocode("6155 Northwest Loop 410", MAPBOX_API_KEY).then(function (data) {
let popUp = new mapboxgl.Popup()
.setHTML("<p>This is Olive Garden </p>");
const MYFAVCITY = new mapboxgl.Marker()
.setLngLat(data)
.addTo(map.setZoom(10))
.setPopup(popUp);
// popUp.addTo(map);
console.log(data);
});
}
console.log(FAVREST());
function FAVREST2 () {
geocode("5403 Northwest Loop 410", MAPBOX_API_KEY).then(function (data) {
let popUp = new mapboxgl.Popup()
.setHTML("<p> This are Las Palapas </p>");
const MYFAVCITY = new mapboxgl.Marker()
.setLngLat(data)
.addTo(map.setZoom(10))
.setPopup(popUp);
// popUp.addTo(map);
console.log(data);
});
}
console.log(FAVREST2());
function FAVREST3 () {
geocode("5450 Northwest Loop 410", MAPBOX_API_KEY).then(function (data) {
let popUp = new mapboxgl.Popup()
.setHTML("<p> This is Red Lobster </p>"+ restaurants.name + restaurants.food);
const MYFAVCITY = new mapboxgl.Marker()
.setLngLat(data)
.addTo(map.setZoom(10))
.setPopup(popUp);
// popUp.addTo(map);
console.log(data);
});
}
console.log(FAVREST3());
let restaurants = [
{
name: "olive garden",
food: "italian",
coordinates: [
-98.615182,
29.471175
]
}, {
name: "las palapas",
food: "mexican",
coordinates: [
-98.592688,
29.48594
]
}, {
name: "Red lobster",
food: "sea food",
coordinates: [
-98.592498,
29.485633
]
}
];
restaurants.forEach(function(restaurant) {
let marker = new mapboxgl.Marker()
.setLngLat(restaurant.coordinates)
.addTo(map)
})
console.log(map);
</script>
</body>
</html>