forked from eneerhut/mapillary_leaderboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lesotho.html
226 lines (205 loc) · 6.42 KB
/
lesotho.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
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>Mapillary Leaderboard Builder</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src='https://unpkg.com/[email protected]/dist/mapillary-js.min.js'></script>
<link href='https://unpkg.com/[email protected]/dist/mapillary-js.min.css' rel='stylesheet' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.24.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.24.0/mapbox-gl.css' rel='stylesheet' />
<script>
$( function() {
$( ".datepicker" ).datepicker();
} );
</script>
<script language="JavaScript" type="Text/JavaScript">
processButton = function() {
map.flyTo({
center: [28.2336, -29.6100],
zoom: 7
});
map.removeLayer("mapillary");
map.removeSource("mapillary");
var user = document.getElementById("user").value;
var start = document.getElementById("start").value;
var finish = document.getElementById("finish").value;
var st = new Date(start).getTime();
var et = new Date(finish).getTime();
console.log(start, st, finish, et);
var added = false;
var that = this;
var uuidfind = "https://a.mapillary.com/v2/u/" + user + "?client_id=UTZhSnNFdGpxSEFFREUwb01GYzlXZzpkMWM2YzdjYjQxN2FhM2Vh"
var url = "https://a.mapillary.com/v2/search/im?client_id=UTZhSnNFdGpxSEFFREUwb01GYzlXZzpkMWM2YzdjYjQxN2FhM2Vh&max_lat=-28.57004987964739&max_lon=29.443359375&min_lat=-30.699335004371967&min_lon=27.0648193359375&limit=10000000&user=" + user + "&start_time=" + st + "&end_time=" + et
//var uuid;
console.log(uuidfind)
$.ajax({
type: "get",
dataType: "json",
url: uuidfind,
timeout : 10000,
success: function(data) {
console.log(data.user_uuid);
var uuid = data.user_uuid;
map.addSource('mapillary', mapillarySource)
map.addLayer({
'id': 'mapillary',
'type': 'line',
'source': 'mapillary',
'source-layer': 'mapillary-sequences',
"filter": ['all',
['==', 'userkey', uuid],
['>=', 'captured_at', st],
['<=', 'captured_at', et]
],
'layout': {
'line-cap': 'round',
'line-join': 'round'
},
'paint': {
'line-opacity': 0.6,
'line-color': 'rgb(53, 175, 109)',
'line-width': 2
}
});
}
});
console.log(url);
$.ajax({
type: "get",
dataType: "json",
url: url,
timeout : 10000,
success: function(data) {
console.log("success");
var len = data.ims.length;
document.getElementById('output').innerHTML = "User " + user + " has uploaded " + len + " photos between " + start + " and " + finish +".";
var mapillarySource = {
type: 'vector',
tiles: ['http://d25uarhxywzl1j.cloudfront.net/v0.1/{z}/{x}/{y}.mvt'],
minzoom: 0,
maxzoom: 14
};
},
error: function( req, status, err ) {
console.log( 'something went wrong', status, err );
alert('something went wrong'+ status + err);
}
});
};
</script>
<style>
body {
background-color: #000;
}
.mapillary-js {
position: relative;
height: 100%;
width: 50%;
}
#input, #output {
color: #fff;
z-index: 1;
}
#mly {
z-index: 0;
text-align: center;
align-items: center;
}
#output {
text-align: center;
}
#map {
position: absolute;
width: 55%;
height: auto;
top: 0;
right: 0;
bottom: 0;
z-index: 1;
}
</style>
</head>
<body>
<div id="left" width=40%>
<div id="input" width=40%>
<form>
Enter username: <input id="user" type="text"><br>
Enter start date:  <input class="datepicker" type="text" id="start" /><br>
Enter end date:   <input class="datepicker" type="text" id="finish"/></br>
</form>
<input type="submit" onclick="processButton();" /><br>
</div><br>
<div id="output" style='width: 45%; height: 50px;'> </div>
<div id="mly" style='width: 45%; height: 400px;'>
<script>
</script>
</div>
</div>
<div id="map" width=55%></div>
<script>
mapboxgl.accessToken = 'pk.eyJ1IjoiY2JlZGRvdyIsImEiOiI5Q09YRG1RIn0.Izu6OPJ4CEEaSSpGuys3Xg';
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v9',
center: [28.2336, -29.6100],
zoom: 7
});
var mapillarySource = {
type: 'vector',
tiles: ['http://d25uarhxywzl1j.cloudfront.net/v0.1/{z}/{x}/{y}.mvt'],
minzoom: 0,
maxzoom: 14
};
map.on('load', function () {
map.addSource('mapillary', mapillarySource);
map.addLayer({
'id': 'mapillary',
'type': 'line',
'source': 'mapillary',
'source-layer': 'mapillary-sequences',
'layout': {
'line-cap': 'round',
'line-join': 'round'
},
'paint': {
'line-opacity': 0.6,
'line-color': 'rgb(53, 175, 109)',
'line-width': 2
}
});
var nav = new mapboxgl.Navigation({position: 'top-left'}); // position is optional
map.addControl(nav);
});
map.on('click', function (e) {
var mly;
coords = JSON.stringify(e.lngLat);
console.log(coords);
url3 = "https://a.mapillary.com/v2/search/im/close?client_id=UTZhSnNFdGpxSEFFREUwb01GYzlXZzpkMWM2YzdjYjQxN2FhM2Vh&distance=100&limit=1&lat=" + e.lngLat.lat + "&lon=" + e.lngLat.lng
console.log(url3);
$.ajax({
type: "get",
dataType: "json",
url: url3,
success: function(data) {
console.log(JSON.stringify(data));
var mlypos = data.ims[0]["key"]
console.log(mlypos);
var mlon = data.ims[0].lon;
var mlat = data.ims[0].lat;
map.flyTo({
center: [mlon, mlat],
zoom: 15,
});
mly = new Mapillary.Viewer('mly',
'UTZhSnNFdGpxSEFFREUwb01GYzlXZzpkMWM2YzdjYjQxN2FhM2Vh', // ClientID for user chrisbeddow
mlypos, {cover: true, cache: false, direction: true});
}
});
});
</script>
</body>
</html>