-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
188 lines (156 loc) · 5.89 KB
/
index.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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>BEACON</title>
<script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<!--<link rel="stylesheet" href="style.css"> -->
<link rel="shortcut icon" href="./images/favicon.ico" type="image/x-icon">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<style>
body {
background-color: white;
font-family: 'Roboto', sans-serif;
padding: 5px 25px;
font-size: 18px;
margin: 0;
color: #444;
}
h1 {
font-size: 62px;
}
#map {
height: 400px;
width: 100%;
}
.infoWin {
font-size: 14px;
}
#contentBoxHeader {
font-size: 20px;
}
</style>
</head>
<body>
<!-- <h1>Beacon</h1> -->
<img src="images/try.png" alt="header image" width= 100% />
<img src="images/coverMap.png" alt="beacon image" width= 100% />
<p></p>
<div id="map"></div>
<p></p>
<br/>
<br/>
<script>
function initMap()
{
var user = {}
var apiContainsData = false;
var myHeaders = new Headers();
var myInit = { method: 'GET',
headers: myHeaders,
mode: 'cors',
cache: 'default' };
var myRequest = new Request('https://infinite-castle-39283.herokuapp.com/getUser', myInit);
fetch(myRequest).then(function (response) {
return response.json();
}).then(function (json) {
var data = json[0]
if(json[0]){
user = {
coordinates:{lat:data.latitude, lng:data.longitude},
img:'images/icons/foodUrgent.png',
name:data.name,
address:data.address,
phone:data.phone,
supply:data.supply,
urgent:(data.urgent ? "Urgent!" : "Not Urgent, but Necessary")}
apiContainsData = true
}
});
window.setTimeout( function(){
//acting like this is an Ajax call
if(apiContainsData){
addMarker(user.coordinates, user.img, user.name, user.address, user.phone, user.supply, user.urgent);
}
},2000);
// Map options
var options = {
zoom: 12,
center: {lat:40.6782, lng:-73.9442} //Brooklyn uluru
}
// New map
var map = new google.maps.Map(document.getElementById('map'), options);
/*-----------------------------------------------------*/
// =>
// place-holder: marker location
var lat = 40.700214;
var lng = -73.978007;
var _uluru = {lat:lat, lng:lng};
var _icon = 'images/icons/crossNonUrgent.png';
// =>
// place-holder: content to for infoWindow
var _name = 'John Doe';
var _address = 'Building 22, Mc Donough Ave, Brooklyn, NY, 11205';
var _phoneN = '(718) 405-6473';
var _emergency = 'Medicine';
var _urgency = 'Urgent! As soon as Possible';
// Add marker function
function addMarker(coordinates, icon, name, address, phoneN, emergency, urgency)
{
console.log("logged")
// Add marker
var marker = new google.maps.Marker({
position: coordinates,
map: map,
icon: icon
});
var infoWindow = new google.maps.InfoWindow({
content: '<h1 id = "contentBoxHeader">' + name + '</h1>' +
'<h2 class="infoWin">' + address + '</h2>' +
'<h2 class="infoWin">' + phoneN + '</h2>' +
'<h2 class="infoWin">' + 'Needs: ' + emergency + '</h2>' +
'<h2 class="infoWin">' + urgency + '</h2>'
});
marker.addListener('click', function(){
infoWindow.open(map, marker);
});
}
// => function call
addMarker(_uluru, _icon, _name, _address, _phoneN, _emergency, _urgency);
/* --------------------------------------------------- */
// DUMMY Markers! In Brooklyn, NY!
var _uluru2 = {lat:40.6676216, lng:-73.96319069999998}
var _icon2 = 'images/icons/clothingNonUrgent.png';
var _name2 = 'Sabrina Harris';
var _address2 = '990 Washington Ave, Brooklyn, NY 11225, USA';
var _phoneN2 = '(718) 259-8006';
var _emergency2 = 'Clothing';
var _urgency2 = 'Not Urgent. But, necessary!';
addMarker(_uluru2, _icon2, _name2, _address2, _phoneN2, _emergency2, _urgency2);
var _uluru3 = {lat:40.6744074, lng:-73.94391999999999};
var _icon3 = 'images/icons/waterUrgent.png';
var _name3 = 'Phyllis Smith';
var _address3 = '145 Brooklyn Ave, Brooklyn, NY 11213, USA';
var _phoneN3 = '(718) 267-6766';
var _emergency3 = 'Water';
var _urgency3 = 'Very Urgent! Need, as soon as possible!';
addMarker(_uluru3, _icon3, _name3, _address3, _phoneN3, _emergency3, _urgency3);
var _uluru4 = {lat:40.6892718, lng:-73.9511324};
var _icon4 = 'images/icons/foodNonUrgent.png';
var _name4 = 'Caroline Owens';
var _address4 = '279 Nostrand Ave, Brooklyn, NY 11216';
var _phoneN4 = '(718) 259-4161';
var _emergency4 = 'Food';
var _urgency4 = 'Not Urgent. But, necessary!';
addMarker(_uluru4, _icon4, _name4, _address4, _phoneN4, _emergency4, _urgency4);
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyA7jkGi2aUU3zDoiFI3OQfP1e3NFOXprsA&callback=initMap">
</script>
</body>
</html>