Skip to content

Commit d991667

Browse files
committed
First adatptions for Wikidata items
1 parent 7d7982d commit d991667

4 files changed

Lines changed: 46 additions & 57 deletions

File tree

‎css/style.css‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
Global Declarations and defaults
77
**********************************************************************/
8-
html,body { width: 100%; height: 100%;}
8+
html,body { width: 100%; height: 100%; background: black;}
99
#content { width: 100%; height: 100%; }
1010

1111
#miniMap { width: 300px; height: 300px; position: absolute; top: 20px; right: 20px; z-index: 1000; box-shadow: 0px 0px 20px rgba(255,255,255, 0.9); }
@@ -15,7 +15,7 @@ html,body { width: 100%; height: 100%;}
1515
#guessButton { font-size: 24px; font-weight: bold; color: white; width: 260px; cursor: pointer; text-align: center; position: absolute; top: 340px; right: 20px; z-index: 1000; }
1616
#guessButton:hover { background: #FF6666; }
1717

18-
#pano { width: 100%; height: 100%; z-index: 999; }
18+
#image { max-width: 100%; max-height: 100%; z-index: 999; }
1919

2020
#scoreBoard { position: absolute; bottom: 45px; left: 20px; width: 200px; height: 80px; padding: 10px; background: white;box-shadow: 0px 0px 20px rgba(0,0,0, 0.9); z-index: 1000; }
2121
#scoreBoard .round { }
@@ -31,4 +31,4 @@ html,body { width: 100%; height: 100%;}
3131

3232
#roundMap { width: 300px; height: 300px; position: relative; }
3333

34-
#endGame { position: absolute; top: 50%; left: 50%; width: 400px; margin: -190px 0 0 -240px; padding: 20px; background: #EFEFEF; text-align: center; display: none; z-index: 1000; }
34+
#endGame { position: absolute; top: 50%; left: 50%; width: 400px; margin: -190px 0 0 -240px; padding: 20px; background: #EFEFEF; text-align: center; display: none; z-index: 1000; }

‎index.html‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@
2626
<span class='totalScore'>Total Score: <b>0</b></span>
2727
</div>
2828
<div id='miniMap'></div>
29-
<div id='timer'></div>
3029
<div id='guessButton' class="btn btn-large btn-danger">Make Your Guess</div>
31-
<div id='pano'></div>
30+
<img id='image' src='' />
3231
</div>
3332
</body>
34-
</html>
33+
</html>

‎js/app.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969

7070
// Reset Timer
7171
function resetTimer(){
72-
count = 15;
72+
count = 999999;
7373
counter = setInterval(timer, 1000);
7474
}
7575

@@ -192,7 +192,7 @@
192192
points = 0;
193193

194194
} else {
195-
$('#roundEnd').html('<p>Your guess was<br/><strong><h1>'+distance+'</strong>km</h1> away from the actual location.<br/><div id="roundMap"></div><br/> You have scored<br/><h1>'+roundScore+' points</h1> this round!<br/><br/><button class="btn btn-primary closeBtn" type="button">Continue</button></p></p>');
195+
$('#roundEnd').html('<p>Your guess was<br/><strong><h1>'+distance+'</strong>km</h1> away from the actual location.<br/>'+window.locName+'<br/><div id="roundMap"></div><br/> You have scored<br/><h1>'+roundScore+' points</h1> this round!<br/><br/><button class="btn btn-primary closeBtn" type="button">Continue</button></p></p>');
196196
$('#roundEnd').fadeIn();
197197
};
198198

@@ -218,4 +218,4 @@
218218
}
219219

220220

221-
});
221+
});

‎js/streetviewmap.js‎

Lines changed: 38 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,40 @@
1-
//
2-
// Streetview Map
3-
//
4-
5-
function svinitialize() {
6-
7-
console.log('No peaking!');
8-
9-
//
10-
// Get Coords
11-
//
12-
// Yeah this is a bit gross, right? Why not do it randomly? Because in geoguessr while it was great having random coords, some of the randomized points it picked sucked. I didn't
13-
// want that at all, thus the manual lat/longs. It's fairly easy to build the random lat long coords based if the selected coords have a street view available
14-
// however detection for that is a bit CPU intensive. In the mean time, just throw more coords into this array - it ain't that bad!
15-
//
16-
var coordArray = ['41.386151,-72.594942','41.143598,-79.850821','39.953833,-82.459817','31.710572,-81.731586','54.730097,-113.322859','18.204668,98.688083','41.716861,-73.444118','49.773504,18.443298','49.760865,18.540459','45.441826,-76.482697','45.048785,-81.364746','46.487874,-87.341824','40.48642,-8.67229','-30.060433,-51.235402','48.462939,-122.57806','41.089282,-112.153015','39.607942,-104.037314','43.01766,-70.832514','44.636013,-63.56979','46.12368,-60.178324','58.154715,-6.503611','56.527054,-2.715433','52.381691,4.842191','52.323185,5.077737','48.627318,2.414361','22.158751,113.568383','50.443452,30.368872','46.102489,0.489836','40.32928,-8.843704','47.506302,-52.878399','59.91132,10.704117','59.324429,18.027363','59.308133,18.017603','61.583522,24.121818','61.792067,26.09482','61.153023,28.626297','59.930482,30.326724','55.740989,37.643505','42.504454,26.778216','32.047836,34.764','27.85158,-15.431503','28.405772,-13.851339','28.136941,-14.265967','-22.121892,-41.579143','21.107432,-101.643071','33.907164,-118.291597','32.578544,-117.084322','32.499614,-116.949802','27.954928,-110.838017','-33.627253,-70.713926','-33.902864,19.156254','-33.418034,19.287207','-29.603402,31.162643','-29.353418,31.275769','44.396495,8.943227','52.455897,13.315633','52.399292,4.54257','51.504403,-0.096115','50.779741,-1.076586','53.006673,-9.388301','53.269908,-9.056027','-36.244136,150.138252','-35.910253,150.080754','-35.304017,149.125024','-33.852164,151.210808','-33.60936,151.330671','-27.276922,152.981374','-16.914506,145.772079','-18.414849,133.850509','-12.714131,131.087205','-32.375691,124.624594','-33.205705,136.127483','-37.809287,144.860957','-38.518886,145.364938','-37.881112,147.986631','-45.890042,170.509817','-45.732399,170.570131','-44.395179,171.248557','-43.352667,172.662721','14.42514,-60.88696','-41.528316,174.006963','-41.278536,173.79653','-41.296114,174.805083','-39.831018,174.884594','-37.097002,174.944404','-36.586234,174.696246','23.392954,120.167403','23.434591,120.475001','24.164274,120.466706','25.127677,121.345888','22.14233,120.895906','22.068026,120.713913','24.180617,121.310135','22.713633,120.647938','37.520159,126.965217','37.605225,126.819185','33.03172,133.092495','33.363595,133.257364','33.245564,134.175172','33.9355,134.675445','34.090315,134.568655','34.370156,134.897461','34.573761,135.483717','35.036556,136.624798','35.053323,136.860677','37.919095,140.90102','38.172184,140.890116','38.302981,141.016754','39.004622,141.620705','40.834644,140.724153','13.671031,100.453813','13.794303,100.475734','13.820743,100.520225','15.688301,100.123802','20.701626,-156.444524','20.935914,-156.340622','20.754721,-156.307426','20.932671,-156.512269','20.930665,-156.690124','20.817193,-156.627544','21.059255,-156.833847','21.170511,-156.998919','21.099857,-157.043906','21.314349,-157.88783','21.390764,-157.963323','21.460369,-157.994817','21.500828,-158.029445','21.579848,-158.179746','21.546209,-158.240185','22.215538,-159.533002','22.210937,-159.475825','22.14238,-159.313348','21.975743,-159.370528','61.037293,-149.780767','61.087325,-149.834305','61.481578,-149.252417','60.986285,-149.509693','60.81731,-148.986377','64.788119,-148.215078','66.426153,19.682644','66.897023,17.836021','68.419404,17.38831','42.041688,11.828012','36.747676,-3.062242','27.752501,-15.647589','-42.808793,147.521977','-41.188572,146.370518','-41.239591,147.007891','-41.564388,148.297033','-42.193771,148.058178','-22.539818,27.150758','-22.564326,27.084064','-19.988805,23.420358','-19.987536,23.400586','-19.97829,23.436552','-2.547081,-44.303493','-2.521623,-44.303452','-2.496611,-44.307604','-2.483738,-44.251567','-4.8685,-43.359994','-4.862966,-43.366505','-4.856253,-43.350032','61.256752,73.445459','61.260159,73.255434','61.223046,73.159369','61.260149,73.522541','61.018278,69.03807','61.060151,72.611124','60.161247,24.924737','60.166274,24.894095','60.180358,24.839546','60.156709,24.61002','60.443872,22.269734','59.43249,24.786236','59.438622,24.77217','59.440308,24.739404','59.428183,24.725075','56.965314,23.87461','56.930528,23.611445','38.796784,-9.217481','38.762923,-9.140635','41.173086,-71.558383','41.1882,-71.568413','41.224204,-71.565897','41.503585,-71.342547','41.27875,-70.09466','41.285498,-70.097395','41.290028,-70.091802','41.28397,-70.169894','42.05567,-70.130615','42.0437,-70.214552','42.061555,-70.161672','41.460846,-71.321621','38.663682,1.583126','39.067397,1.588115','39.545419,2.620647','39.56504,2.643499','36.744034,11.989399','40.846046,14.266241','41.903467,12.52023','41.900241,12.45591','41.917006,8.736544','41.931862,8.740537','41.863582,-87.619196','41.702427,-87.524245','39.961456,-83.000494','39.953099,-82.998817','40.438824,-80.011528','40.449676,-79.993329','41.49853,-81.705368','41.478657,-81.673517','42.32768,-83.04662','42.347674,-83.000241','43.632123,-79.412226','43.649058,-79.354391','43.700565,-79.254752','41.390699,-73.477126','41.425949,-73.340598','41.468883,-73.405674','41.455067,-73.238091','41.465248,-73.246627','41.465829,-73.229696','41.477619,-73.216943','41.507517,-73.140724','41.117671,-73.38268','41.107462,-73.411','41.093624,-73.419081','41.09153,-73.415912','41.098894,-73.416056','41.576465,-73.411813','41.605417,-73.404012','41.592727,-73.450599','41.556962,-73.387772','41.550288,-73.329864','41.535304,-73.279492','41.550911,-73.205327','41.551363,-73.055456','41.518617,-72.771206'];
17-
var randCoord = coordArray[Math.floor(Math.random() * coordArray.length)];
18-
coordArrayLatLongs = randCoord.replace(/[\])}[{(]/g,'').split(',');
19-
20-
window.locLL = coordArrayLatLongs[0]+","+coordArrayLatLongs[1];
21-
22-
// Do streetview
23-
var whoamiLocation = new google.maps.LatLng(coordArrayLatLongs[0],coordArrayLatLongs[1]);
24-
var streetViewService = new google.maps.StreetViewService();
25-
var STREETVIEW_MAX_DISTANCE = 100;
26-
27-
streetViewService.getPanoramaByLocation(whoamiLocation, STREETVIEW_MAX_DISTANCE, function (streetViewPanoramaData, status) {
28-
if (status === google.maps.StreetViewStatus.OK) {
29-
30-
// We have a streetview pano for this location, so let's roll
31-
var panoramaOptions = {
32-
position: whoamiLocation,
33-
addressControl: false,
34-
linksControl: false,
35-
pov: {
36-
heading: 270,
37-
zoom: 1,
38-
pitch: -10
39-
},
40-
visible: true
41-
};
42-
var panorama = new google.maps.StreetViewPanorama(document.getElementById('pano'), panoramaOptions);
43-
44-
} else {
45-
// no street view available in this range, or some error occurred
46-
alert('Streetview is not available for this location :( Mind telling us that you saw this?');
1+
function svinitialize() {
2+
const query = `
3+
SELECT ?item ?itemLabel ?lat ?lon ?photo WHERE {
4+
{
5+
SELECT ?item ?photo ?lat ?lon
6+
WHERE {
7+
?item wdt:P18 ?photo .
8+
?item p:P625 ?statement .
9+
?statement psv:P625 ?coords .
10+
?coords wikibase:geoLatitude ?lat .
11+
?coords wikibase:geoLongitude ?lon .
12+
} LIMIT 1000
13+
}
14+
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
15+
}
16+
`;
17+
const url = `https://query.wikidata.org/bigdata/namespace/wdq/sparql?format=json&query=${query}`;
18+
window.fetch(url)
19+
.then(
20+
function (response) {
21+
if (response.status !== 200) {
22+
console.warn(`Looks like there was a problem. Status Code: ${response.status}`);
23+
return;
24+
}
25+
response.json().then(function (data) {
26+
var i = Math.floor(Math.random()*1000)
27+
var place = data.results.bindings[i];
28+
console.log(place);
29+
30+
var img = document.getElementById('image');
31+
img.src = place.photo.value;
32+
window.locLL = place.lat.value + "," + place.lon.value;
33+
window.locName = place.itemLabel.value;
34+
});
4735
}
36+
)
37+
.catch(function (err) {
38+
console.warn('Fetch Error :-S', err);
4839
});
49-
50-
};
40+
};

0 commit comments

Comments
 (0)