-
Notifications
You must be signed in to change notification settings - Fork 0
/
mapbeforesleep.html
300 lines (245 loc) · 10.7 KB
/
mapbeforesleep.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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Map</title>
<!-- Bootstrap -->
<link href="statics/css/bootstrap.min.css" rel="stylesheet">
<link href="statics/css/custom.css" rel="stylesheet">
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="statics/js/bootstrap.min.js"></script>
<script src='https://api.mapbox.com/mapbox.js/v2.3.0/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v2.3.0/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<center>
<nav class="navbar navbar-default bottomhomenav">
<div class="container-fluid bottomhomenav">
<div class="navbar-header bottomhomenav">
<center>
<img class="img-responsive" src="statics/whole_logo.png" style="width:20%; top:0px;left:0px;">
</center>
<button type="button" class="navbar-toggle" style="position:absolute;left:0px; top:0px;" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse bottomhomenav" id="myNavbar">
<center>
<ul class="nav navbar-nav ">
<li class="active btn-xl" style="">
{{profilebutton}}
<ul class="dropdown-menu">
<li class="active btn-xl" style="">
<a style=""href="/registerUser" rel="external" data-iconpos="center" data-icon="search"><span class="glyphicon glyphicon-search"></span>As a user</a>
</li>
<li class="active btn-xl" style="">
<a style=""href="/registerPage1" rel="external" data-iconpos="center" data-icon="search"><span class="glyphicon glyphicon-search"></span>As a Hair Dresser</a>
</li>
</ul>
</li>
<li class="active btn-xl" style="">
<script>
function getLocation(){
var geo;
if(navigator && navigator.geolocation){
navigator.geolocation.getCurrentPosition(showPosition);
}
else{
console.log('Geolocation is not supported');
}
}
function showPosition(position){
geo =position.coords;
document.getElementById("location").value = "["+geo.latitude+ "," + geo.longitude + "]";
}
</script>
<form method="post" onSubmit="getLocation()" action="/map" style="color:white;">
<center>
<button class=" button-effect btn-block"type="submit" style="color:black; box-shadow:none; border:none;padding: 10px 15px;"><span class="glyphicon glyphicon-search"></span>Find A Hair Professional</button>
</center>
<label style="visibility:hidden" for="location" >Location:</label>
<input type="text" name="location" style="color:black; visibility:hidden" id="location" />
<script>
getLocation();
</script>
<label for="range" style="visibility:hidden">Range in Miles:</label>
<input id="range" name="range"type="text" data-slider-min="0.0" data-slider-max="50" data-slider-step="5" data-slider-value="25.0" style="display: none; visibility:hidden" data-value="14" value="50.0">
<label for="rating" style="visibility:hidden">Minimum Rating:</label>
<input name="rating" id="rating"type="text" data-slider-min="0" data-slider-max="5" data-slider-step="1" data-slider-value="3" style="display: none; visibility:hidden" data-value="14" value="3.0"/>
</form>
</li>
</ul>
</center>
</div>
</div>
</nav>
</center>
<div id="JSON" style="position:absolute;left:-8000px;">
{{ jsonobject }}
</div>
<div id="maintextbox" title="Basic Dialogue" style="position:absolute;left:-8000px;">
<table border="0" align="center" cellpadding="1" cellspacing="4">
<tr>
<td colspan="2"><h3 style="cursor: pointer;text-decoration:underline" onclick="gobarber('{username}')"><center>{Barber Name}</center></h3></td>
</tr>
<tr>
<td rowspan="2"><a href="viewBarber/{username}"> <img src="viewPhoto/{photo}" width="90%" alt="Barber"/></a></td>
<td width="50%">Stars: {rating}<span class="stars s-{starnum}" data-default='{starnum}'>0 stars</span></td>
</tr>
<tr>
<td width="50%">{Description}</td>
</tr>
</table>
</div>
<div id='map'></div>
<!-- jQuery is required for this example. -->
<script src='https://code.jquery.com/jquery-1.11.0.min.js'></script>
<script type="text/javascript" src="statics/infobox.js"></script>
<script>
L.mapbox.accessToken = 'pk.eyJ1IjoibWFtYWRvdXdhbm4iLCJhIjoiY2lsanN0cjN2NWExOXZhbWN0M2E0NHRlZyJ9.Jry4JWNICLD2GcujnV9oIw';
var map = L.mapbox.map('map', 'mapbox.streets')
map.locate({setView: true, maxZoom: 18});
var myLayer = L.mapbox.featureLayer().addTo(map);
function onLocationFound(e) {
var radius = e.accuracy / 2;
var m = L.marker(e.latlng).addTo(map)
.bindPopup("You are within " + radius + " meters from this point").openPopup();
L.circle(e.latlng, radius).addTo(map);
}
var geoJson = [
{
type: 'Feature',
"geometry": { "type": "Point", "coordinates": [-77.03, 38.90]},
"properties": {
"image": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ef/Cherry_Blossoms_and_Washington_Monument.jpg/320px-Cherry_Blossoms_and_Washington_Monument.jpg",
"url": "https://en.wikipedia.org/wiki/Washington,_D.C.",
"marker-symbol": "star",
"marker-color": "#ff8888",
"marker-size": "large",
"city": "Washington, D.C."
}
}, {
type: 'Feature',
"geometry": { "type": "Point", "coordinates": [-87.63, 41.88]},
"properties": {
"image": "https://upload.wikimedia.org/wikipedia/commons/thumb/8/82/Chicago_sunrise_1.jpg/640px-Chicago_sunrise_1.jpg",
"url": "https://en.wikipedia.org/wiki/Chicago",
"marker-color": "#ff8888",
"city": "The night"
}
}, {
type: 'Feature',
"geometry": { "type": "Point", "coordinates": [-74.00, 40.71]},
"properties": {
"image": "https://upload.wikimedia.org/wikipedia/commons/thumb/3/39/NYC_Top_of_the_Rock_Pano.jpg/640px-NYC_Top_of_the_Rock_Pano.jpg",
"url": "https://en.wikipedia.org/wiki/New_York_City",
"marker-color": "#ff8888",
"city": "Batman City"
}
}];
myLayer.on('layeradd', function(e) {
var marker = e.layer,
feature = marker.feature;
// Create custom popup content
var popupContent = '<a target="_blank" class="popup" href="' + feature.properties.url + '">' +
'<img src="' + feature.properties.image + '" />' +
feature.properties.city +
'</a>';
// http://leafletjs.com/reference.html#popup
marker.bindPopup(popupContent,{
closeButton: false,
minWidth: 320
});
});
query+="&arg0=["+geo.latitude+","+geo.longitude+"]";
var req = new XMLHttpRequest();
var async = false;
var query = "action=getMapData";
query+="&arg1="+0;
query+="&arg2="+50;
req.open('GET', '/database?' + query, async);
req.send();
str = req.responseText;
jsondata = jQuery.parseJSON(str);
jsongmap(jsondata);
// Add features to the map
var str;
str =$("#JSON").html();
var n = jQuery.parseJSON(str);
alert(str);
myLayer.setGeoJSON(n);
map.on('locationfound', onLocationFound);
// The HTML we put in bindPopup doesn't exist yet, so we can't just say
// $('#mybutton'). Instead, we listen for click events on the map element which
// will bubble up from the tooltip, once it's created and someone clicks on it.
//$('#map_canvas').gmap().set('draggable', false);
</script>
<form method="post" class="navbar navbar-default bottomhomenav" action="/map" style="color:white;">
<div data-role="fieldcontain" data-type="horizontal">
<label for="location">Change location:</label>
<input type="text" name="location" style="color:black;" id="location"/>
</div>
<div data-role="fieldcontain" data-type="horizontal">
<label style="visibility:hidden" for="range">Range in Miles:</label>
<input id="range" name="range"type="text" data-slider-min="0.0" data-slider-max="50" data-slider-step="5" data-slider-value="25.0" style="display: none;" data-value="14" value="25.0">
</div>
<div data-role="fieldcontain" style="background:transparent !important">
<label style="visibility:hidden" for="rating">Minimum Rating:</label>
<input name="rating" id="rating"type="text" data-slider-min="0" data-slider-max="5" data-slider-step="1" data-slider-value="3" style="display: none;" data-value="14" value="3.0"/>
</div>
<input type="submit" class="form-control registerbutton" value="Refresh Map" data-role="button" data-icon="info" data-iconpos="left" />
<script>
getLocation();
</script>
<br/>
<br/>
</form>
<br/>
<br/>
<script type="text/javascript">
function gobarber(str){
window.location = "viewBarber/"+str
}
var text,clone,jsondata,disabled,geo;
text = "This is to show it works"
clone = $("#maintextbox").clone();
disabled = 0
geo = -1
var mapOptions = {
disableDoubleClickZoom: true,
draggable:false,
panControl:false
};
function getLocation()
{
if (navigator.geolocation && geo == -1)
{
navigator.geolocation.getCurrentPosition(showPosition);
}
}
function showPosition(position)
{
geo = position.coords
}
</script>
<!--Google Maps API-->
</body>
</html>