-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmapbox.html
40 lines (36 loc) · 1.18 KB
/
mapbox.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Mapbox</title>
<script src="js/mapbox-geocode-utils.js"></script>
<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="https://api.mapbox.com/mapbox-gl-js/v2.10.0/mapbox-gl.js"></script>
<script>
const key = "pk.eyJ1IjoiYnJpdHRuZXliOTUiLCJhIjoiY2w5bjg2MmhuMDU3dDNvcnN2bjl1b2c2byJ9.dh_5Tnhphj7ePvd_z5lbYA";
mapboxgl.accessToken = key;
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v9',
zoom: 3,
center:[-80.88123,35.23718]
});
let marker = new mapboxgl.Marker().setLngLat([-80.84636, 35.23216,]).addTo(map);
let popup = new mapboxgl.Popup().setLngLat([-80.84636, 35.23216]).setHTML("<h1>My House</h1>").addTo(map);
geocode("206 oak circle drive", key).then(function(results){
console.log(results)
let marker2 = new mapboxgl.Marker().setLngLat(results).addTo(map)
let popup2 = new mapboxgl.Popup().setLngLat(results).setHTML("<h4>Parents Home</h4>").addTo(map)});
</script>
</body>
</html>