-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo2.html
319 lines (283 loc) · 10.5 KB
/
demo2.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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>Kelleys Island Parcels Demo</title>
<meta content='initial-scale=1,maximum-scale=1,user-scalable=no' name=
'viewport'>
<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 src="jquery-3.1.1.min.js"></script>
<link href="normalize.css" rel="stylesheet" />
<link href="skeleton.css" rel="stylesheet" />
<link href=
"https://npmcdn.com/[email protected]/dist/mapillary-js.min.css" rel=
"stylesheet">
<style>
html, body {
position:fixed;
top:0;
bottom:0;
left:0;
right:0;
background-color: black;
}
a:link{
color: ##e60000;
text-decoration: none
}
a:visited{
color: ##e60000;
text-decoration: none
}
a:hover{
color: ##e60000;
text-decoration: none
}
a:active{
color: orange;
text-decoration: none
}
.title {
color: white;
font-family: "Century Gothic";
font-size: 24px;
text-align: center;
font-weight: bolder;
}
.intro {
color: white;
font-family: "Century Gothic";
font-size: 14px;
text-align: center;
}
.mly-wrapper {
position: relative;
background-color: grey;
width: 100%;
height: 100%;
}
.mapillary-js {
position: relative;
height: 100%;
width: 50%;
}
#map {
position: absolute;
width: 50%;
top: 0;
right: 0;
bottom: 0;
z-index: 100;
}
.mapboxgl-popup {
max-width: 400px;
font: 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif;
}
.left {
background-color: #000;
}
</style>
</head>
<body>
<div class="title">
Kelleys Island Parcels
</div>
<div class="intro">
<br>
Placeholder info
</div><br>
<div class="mly-wrapper" class="container">
<div class="row">
<div class="six columns">
<div id='mly' class='container' id="left">
<div class="row">
<div id="id_0" class="four columns"></div>
<div id="id_1" class="four columns"></div>
<div id="id_2" class="four columns"></div>
</div>
<div class="row">
<div id="id_3" class="four columns"></div>
<div id="id_4" class="four columns"></div>
<div id="id_5" class="four columns"></div>
</div>
<div class="row">
<div id="id_6" class="four columns"></div>
<div id="id_7" class="four columns"></div>
<div id="id_8" class="four columns"></div>
</div>
<div class="row">
<div id="id_9" class="four columns"></div>
<div id="id_10" class="four columns"></div>
<div id="id_11" class="four columns"></div>
</div>
<div class="row">
<div id="id_12" class="four columns"></div>
<div id="id_13" class="four columns"></div>
<div id="id_14" class="four columns"></div>
</div>
</div>
</div>
<div class="six columns">
<div id='map'></div>
</div>
</div>
<script src=
"https://npmcdn.com/[email protected]/dist/mapillary-js.min.js">
</script>
<script>
var img_start = '0000000000000';
mapboxgl.accessToken = 'pk.eyJ1IjoiY2JlZGRvdyIsImEiOiI5Q09YRG1RIn0.Izu6OPJ4CEEaSSpGuys3Xg';
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v9',
center: [-82.69965,41.60116],
zoom: 12
});
function getJSON(url) {
var resp ;
var xmlHttp ;
resp = '' ;
xmlHttp = new XMLHttpRequest();
if(xmlHttp != null)
{
xmlHttp.open( "GET", url, false );
xmlHttp.send( null );
resp = xmlHttp.responseText;
}
return resp ;
}
var mapillary_client_id = 'UTZhSnNFdGpxSEFFREUwb01GYzlXZzpkMWM2YzdjYjQxN2FhM2Vh' //clientID for chrisbeddow
var nav = new mapboxgl.Navigation({position: 'top-left'}); // position is optional
map.addControl(nav);
map.on('load', function () {
map.addSource('parcels', {
'type': 'geojson',
'data': 'https://gist.githubusercontent.com/cbeddow/0bb1a957326cab0aec649e0dea3b978d/raw/069f1695034d9aac75c412c12d572122e500109b/kelleys_island.geojson'
});
map.addControl(new mapboxgl.Navigation());
// Add a layer showing the parcel polygons.
map.addLayer({
'id': 'parcels-layer',
'type': 'fill',
'source': 'parcels',
'source-layer': 'parcels-layer',
'paint': {
'fill-color': 'rgba(200, 100, 240, 0.4)',
'fill-outline-color': 'rgba(200, 100, 240, 1)'
}
});
});
// When a click event occurs on a polygon, open a popup at the location of
// the feature, with description HTML from its properties.
map.on('click', function (e) {
//change img_start variable, right now just a test to see if the new value will load
//(and next is to modify this to load value from query of Mapillary API)
var features = map.queryRenderedFeatures(e.point, { layers: ['parcels-layer'] });
if (!features.length) {
return;
};
var images = new Object(); //array to store the queried images fro Mapillary
var feature = features[0]; //defines feature as the parcel that has been clicked
var radius = ((feature.properties.road_dist + 15) * 5); //defines search radius for query in meters + 15 meters for good measure
var lng = feature.properties.longitude
var lat = feature.properties.latitude;
console.log(lng + ", " + lat)
console.log(feature.properties.road_dist);
console.log("radius: ", radius);
clear = function (){
$("#").empty();
console.log("Viewer cleared.");
};
// clear();
map.flyTo({
center: [lng, lat],
zoom: 15,
});
//var url = "http://mapillary-magic.mapillary.io/v3/images?look_at[lon]=-82.6885&look_at[lat]=41.6021&look_at[radius]=88.1336331806"
var url2 ="http://mapillary-magic.mapillary.io/v3/images?look_at[lon]=" + lng + "&look_at[lat]=" + lat + "&look_at[radius]=" + radius
console.log(url2);
var added = false;
var that = this;
$.ajax({
dataType: "json",
url: url2,
success: function (data) {
if (that.added) {
console.log("Removing...")
map.removeLayer("points");
map.removeSource("points");
};
that.added = true;
var mygeojson = {
features: [],
type: "FeatureCollection",
};
var items = data.images.i;
for (var i = 0; i < data.images.length; i++) {
var y = data.images[i];
var id = i;
var yurl = "img src=https://d1cuyjsrcm0gby.cloudfront.net/"+i["key"]+ "/thumb-320.jpg";
mygeojson.features.push({
"geometry":{
"type": "Point",
"coordinates": [y.lon, y.lat]
},
"properties":{
"url": yurl,
"image": y.key,
"id" : id
},
type: "Feature"
});
};
console.log(JSON.stringify(mygeojson));
map.addSource('points', { type: 'geojson', data: mygeojson });
var imglayer = {
"id": "points",
"type": "circle",
"source": "points",
"paint": {
"circle-color": "#32c987",
"circle-opacity": 0.3
}
};
map.addLayer(imglayer);
var images = data.images;
images.forEach( function(image, i){
// console.log(image["key"] +" " +i);
$("#id_"+i).html("<a target=_blank href=https://www.mapillary.com/map/im/"+image["key"] +">"+"<img src=https://d1cuyjsrcm0gby.cloudfront.net/"+image["key"]+"/thumb-320.jpg style=\"max-width:100%;max-height:100%\"></a>")
});
/* var x = document.createElement('div');
x.className = 'marker';
x.style.backgroundImage = 'url("https://d1cuyjsrcm0gby.cloudfront.net/"+i[key]+"/thumb-320.jpg")';
var xlon = i["lon"];
var xlat = i["lat"];
new mapboxgl.Marker(x)
.setLngLat([xlon, xlat])
.addTo(map);
});*/
}
});
//var lng1 = json1.images[0].lon;
//var lat1 = json1.images[0].lat;
//console.log(url2);
// console.log(lng1, lat1);
var popup = new mapboxgl.Popup()
.setLngLat(map.unproject(e.point))
//displays the TaxIDNum of the parcel
.setHTML("TaxID: " + feature.properties.TaxIDNum + "<br>" + "Coords: " + feature.properties.longitude +","+ feature.properties.latitude)
.addTo(map);
});
// Indicate that the parcels are clickable by changing the cursor style
map.on('mousemove', function (e) {
var features = map.queryRenderedFeatures(e.point, { layers: ['parcels-layer'] });
map.getCanvas().style.cursor = (features.length) ? 'pointer' : '';
});
/* var mly = new Mapillary.Viewer('mly',
mapillary_client_id, // ClientID for user chrisbeddow
img_start, {cover: true, cache: false, direction: false}); */
//begin test for retrieving image with best camera angle below, see test.txt file
</script>
</body>
</html>