2020-05-21 23:43:17 +02:00
|
|
|
'use strict';
|
|
|
|
|
2020-05-20 03:19:53 +02:00
|
|
|
(function () {
|
|
|
|
var Core = {
|
2020-05-21 23:43:17 +02:00
|
|
|
NUMBER_OF_ROUNDS: 5,
|
2020-05-20 03:19:53 +02:00
|
|
|
MAX_SCORE: 1000,
|
|
|
|
|
2020-05-21 23:43:17 +02:00
|
|
|
rounds: [],
|
|
|
|
scoreSum: 0,
|
2020-05-20 03:19:53 +02:00
|
|
|
realPosition: null,
|
|
|
|
panorama: null,
|
2020-05-22 23:23:54 +02:00
|
|
|
map: null,
|
2020-05-20 03:19:53 +02:00
|
|
|
guessMarker: null,
|
2020-05-21 23:43:17 +02:00
|
|
|
adaptGuess: false,
|
2020-05-20 03:19:53 +02:00
|
|
|
googleLink: null,
|
|
|
|
|
2020-05-22 01:31:32 +02:00
|
|
|
initialize: function () {
|
|
|
|
if (sessionStorage.rounds) {
|
|
|
|
var roundsLoaded = JSON.parse(sessionStorage.rounds);
|
|
|
|
for (var i = 0; i < roundsLoaded.length; ++i) {
|
|
|
|
var round = roundsLoaded[i];
|
|
|
|
Core.rounds.push({ realPosition: round.realPosition, guessPosition: round.guessPosition, realMarker: null, guessMarker: null, line: null });
|
|
|
|
if (round.guessPosition) {
|
2020-05-22 23:22:11 +02:00
|
|
|
Core.addRealGuessPair(round.realPosition, round.guessPosition, true);
|
2020-05-22 01:31:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sessionStorage.scoreSum) {
|
|
|
|
Core.scoreSum = parseInt(sessionStorage.scoreSum);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Core.rounds.length > 0 && !Core.rounds[Core.rounds.length - 1].guessPosition) {
|
|
|
|
Core.realPosition = Core.rounds[Core.rounds.length - 1].realPosition;
|
|
|
|
Core.loadPositionInfo(Core.realPosition);
|
2020-05-23 01:25:43 +02:00
|
|
|
|
|
|
|
document.getElementById('currentRound').innerHTML = String(Core.rounds.length) + '/' + String(Core.NUMBER_OF_ROUNDS);
|
2020-05-24 14:47:15 +02:00
|
|
|
document.getElementById('currentScoreSum').innerHTML = String(Core.scoreSum) + '/' + String((Core.rounds.length - 1) * Core.MAX_SCORE);
|
2020-05-22 01:31:32 +02:00
|
|
|
} else {
|
|
|
|
Core.startNewRound();
|
2020-05-23 01:25:43 +02:00
|
|
|
|
|
|
|
document.getElementById('currentScoreSum').innerHTML = String(0);
|
2020-05-22 01:31:32 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-05-21 23:43:17 +02:00
|
|
|
startNewGame: function () {
|
|
|
|
for (var i = 0; i < Core.rounds.length; ++i) {
|
|
|
|
var round = Core.rounds[i];
|
|
|
|
|
|
|
|
round.realMarker.setMap(null);
|
|
|
|
round.guessMarker.setMap(null);
|
|
|
|
round.line.setMap(null);
|
|
|
|
}
|
|
|
|
|
|
|
|
Core.rounds = [];
|
|
|
|
Core.scoreSum = 0;
|
|
|
|
|
|
|
|
var distanceInfo = document.getElementById('distanceInfo');
|
|
|
|
distanceInfo.children[0].style.display = null;
|
|
|
|
distanceInfo.children[1].style.display = null;
|
|
|
|
var scoreInfo = document.getElementById('scoreInfo');
|
|
|
|
scoreInfo.children[0].style.display = null;
|
|
|
|
scoreInfo.children[1].style.display = null;
|
|
|
|
document.getElementById('continueButton').style.display = null;
|
|
|
|
document.getElementById('startNewGameButton').style.display = null;
|
|
|
|
|
|
|
|
Core.prepareNewRound();
|
2020-05-23 01:25:43 +02:00
|
|
|
|
|
|
|
document.getElementById('currentScoreSum').innerHTML = String(0);
|
2020-05-21 23:43:17 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
prepareNewRound: function () {
|
|
|
|
document.getElementById('scoreBar').style.width = null;
|
|
|
|
|
2020-05-22 23:22:11 +02:00
|
|
|
if (Core.rounds.length > 0) {
|
|
|
|
var lastRound = Core.rounds[Core.rounds.length - 1];
|
|
|
|
|
|
|
|
lastRound.realMarker.setVisible(false);
|
|
|
|
lastRound.guessMarker.setVisible(false);
|
|
|
|
lastRound.line.setVisible(false);
|
2020-05-21 23:43:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
document.getElementById('showGuessButton').style.visibility = null;
|
|
|
|
document.getElementById('guess').style.visibility = null;
|
2020-05-22 23:22:11 +02:00
|
|
|
document.getElementById('guess').classList.remove('result')
|
2020-05-21 23:43:17 +02:00
|
|
|
|
2020-05-22 23:23:54 +02:00
|
|
|
Core.map.setOptions({
|
2020-05-22 23:22:11 +02:00
|
|
|
draggableCursor: 'crosshair'
|
|
|
|
});
|
2020-05-22 23:23:54 +02:00
|
|
|
Core.map.fitBounds(guessMapBounds);
|
2020-05-21 23:43:17 +02:00
|
|
|
|
|
|
|
Core.startNewRound();
|
|
|
|
},
|
|
|
|
|
|
|
|
startNewRound: function () {
|
|
|
|
Core.rounds.push({ realPosition: null, guessPosition: null, realMarker: null, guessMarker: null, line: null });
|
2020-05-20 15:54:09 +02:00
|
|
|
|
2020-05-21 23:43:17 +02:00
|
|
|
Core.panorama.setVisible(false);
|
2020-05-20 15:54:09 +02:00
|
|
|
document.getElementById('loading').style.visibility = 'visible';
|
|
|
|
|
2020-05-23 01:25:43 +02:00
|
|
|
document.getElementById('currentRound').innerHTML = String(Core.rounds.length) + '/' + String(Core.NUMBER_OF_ROUNDS);
|
|
|
|
|
2020-05-21 23:43:17 +02:00
|
|
|
Core.getNewPosition();
|
|
|
|
},
|
|
|
|
|
|
|
|
getNewPosition: function () {
|
2020-05-20 03:19:53 +02:00
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
xhr.responseType = 'json';
|
|
|
|
xhr.onreadystatechange = function () {
|
|
|
|
if (this.readyState == 4 && this.status == 200) {
|
|
|
|
Core.realPosition = this.response.position;
|
2020-05-21 23:43:17 +02:00
|
|
|
Core.rounds[Core.rounds.length - 1].realPosition = this.response.position;
|
2020-05-22 01:31:32 +02:00
|
|
|
Core.loadPositionInfo(this.response.position);
|
2020-05-20 03:19:53 +02:00
|
|
|
|
2020-05-22 01:31:32 +02:00
|
|
|
Core.saveToSession();
|
2020-05-20 03:19:53 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
xhr.open('GET', 'getNewPosition.json', true);
|
|
|
|
xhr.send();
|
|
|
|
},
|
|
|
|
|
2020-05-22 01:31:32 +02:00
|
|
|
loadPositionInfo: function (position) {
|
|
|
|
var sv = new google.maps.StreetViewService();
|
|
|
|
sv.getPanorama({ location: position, preference: google.maps.StreetViewPreference.NEAREST }, Core.loadPano);
|
|
|
|
},
|
|
|
|
|
2020-05-20 03:19:53 +02:00
|
|
|
loadPano: function (data, status) {
|
|
|
|
if (status !== google.maps.StreetViewStatus.OK) {
|
|
|
|
Core.getNewPosition();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-05-20 15:54:09 +02:00
|
|
|
document.getElementById('loading').style.visibility = 'hidden';
|
|
|
|
|
2020-05-21 03:24:09 +02:00
|
|
|
if (Core.adaptGuess) {
|
|
|
|
document.getElementById('guess').classList.add('adapt');
|
|
|
|
}
|
|
|
|
|
2020-05-20 15:54:09 +02:00
|
|
|
Core.panorama.setVisible(true);
|
2020-05-21 12:17:18 +02:00
|
|
|
Core.panorama.setPov({ heading: 0, pitch: 0 });
|
|
|
|
Core.panorama.setZoom(0);
|
2020-05-20 03:19:53 +02:00
|
|
|
Core.panorama.setPano(data.location.pano);
|
|
|
|
},
|
2020-05-17 19:29:06 +02:00
|
|
|
|
2020-05-21 23:43:17 +02:00
|
|
|
evaluateGuess: function () {
|
|
|
|
var guessPosition = Core.guessMarker.getPosition().toJSON();
|
|
|
|
Core.rounds[Core.rounds.length - 1].guessPosition = guessPosition;
|
|
|
|
|
2020-05-22 01:31:32 +02:00
|
|
|
var distance = Util.calculateDistance(Core.realPosition, guessPosition);
|
|
|
|
var score = Core.calculateScore(distance);
|
|
|
|
Core.scoreSum += score;
|
|
|
|
|
2020-05-23 01:25:43 +02:00
|
|
|
document.getElementById('currentScoreSum').innerHTML = String(Core.scoreSum) + '/' + String(Core.rounds.length * Core.MAX_SCORE);
|
|
|
|
|
2020-05-22 01:31:32 +02:00
|
|
|
Core.saveToSession();
|
|
|
|
|
2020-05-21 23:43:17 +02:00
|
|
|
Core.guessMarker.setMap(null);
|
|
|
|
Core.guessMarker = null;
|
|
|
|
|
2020-05-22 23:22:11 +02:00
|
|
|
if (Core.adaptGuess) {
|
|
|
|
document.getElementById('guess').classList.remove('adapt');
|
|
|
|
}
|
|
|
|
document.getElementById('guess').classList.add('result');
|
2020-05-21 23:43:17 +02:00
|
|
|
|
2020-05-22 01:31:32 +02:00
|
|
|
Core.addRealGuessPair(Core.realPosition, guessPosition);
|
2020-05-21 23:43:17 +02:00
|
|
|
|
|
|
|
var resultBounds = new google.maps.LatLngBounds();
|
|
|
|
resultBounds.extend(Core.realPosition);
|
|
|
|
resultBounds.extend(guessPosition);
|
2020-05-22 23:22:11 +02:00
|
|
|
|
2020-05-22 23:23:54 +02:00
|
|
|
Core.map.setOptions({
|
2020-05-22 23:22:11 +02:00
|
|
|
draggableCursor: 'grab'
|
|
|
|
});
|
2020-05-22 23:23:54 +02:00
|
|
|
Core.map.fitBounds(resultBounds);
|
2020-05-21 23:43:17 +02:00
|
|
|
|
|
|
|
document.getElementById('distance').innerHTML = Util.printDistanceForHuman(distance);
|
|
|
|
document.getElementById('score').innerHTML = score;
|
|
|
|
|
|
|
|
var scoreBarProperties = Core.calculateScoreBarProperties(score, Core.MAX_SCORE);
|
|
|
|
var scoreBar = document.getElementById('scoreBar');
|
|
|
|
scoreBar.style.backgroundColor = scoreBarProperties.backgroundColor;
|
|
|
|
scoreBar.style.width = scoreBarProperties.width;
|
|
|
|
|
|
|
|
if (Core.rounds.length == Core.NUMBER_OF_ROUNDS) {
|
|
|
|
document.getElementById('continueButton').style.display = 'none';
|
|
|
|
document.getElementById('showSummaryButton').style.display = 'block';
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-05-23 02:33:44 +02:00
|
|
|
addRealGuessPair: function (realPosition, guessPosition, hidden) {
|
2020-05-21 23:43:17 +02:00
|
|
|
var round = Core.rounds[Core.rounds.length - 1];
|
|
|
|
|
|
|
|
round.realMarker = new google.maps.Marker({
|
2020-05-22 23:23:54 +02:00
|
|
|
map: Core.map,
|
2020-05-22 23:22:11 +02:00
|
|
|
visible: !hidden,
|
2020-05-21 23:43:17 +02:00
|
|
|
position: realPosition,
|
2020-05-22 23:55:09 +02:00
|
|
|
title: 'Open in Google Maps',
|
2020-05-24 15:00:58 +02:00
|
|
|
zIndex: Core.rounds.length * 2,
|
2020-05-21 23:43:17 +02:00
|
|
|
clickable: true,
|
|
|
|
draggable: false
|
|
|
|
});
|
|
|
|
|
|
|
|
round.realMarker.addListener('click', function () {
|
|
|
|
window.open('https://www.google.com/maps/search/?api=1&query=' + this.getPosition().toUrlValue(), '_blank');
|
|
|
|
});
|
|
|
|
|
|
|
|
round.guessMarker = new google.maps.Marker({
|
2020-05-22 23:23:54 +02:00
|
|
|
map: Core.map,
|
2020-05-22 23:22:11 +02:00
|
|
|
visible: !hidden,
|
2020-05-21 23:43:17 +02:00
|
|
|
position: guessPosition,
|
2020-05-24 15:00:58 +02:00
|
|
|
zIndex: Core.rounds.length,
|
2020-05-21 23:43:17 +02:00
|
|
|
clickable: false,
|
|
|
|
draggable: false,
|
|
|
|
label: {
|
|
|
|
color: '#ffffff',
|
|
|
|
fontFamily: 'Roboto',
|
|
|
|
fontSize: '18px',
|
|
|
|
fontWeight: '500',
|
|
|
|
text: '?'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
round.line = new google.maps.Polyline({
|
2020-05-22 23:23:54 +02:00
|
|
|
map: Core.map,
|
2020-05-22 23:22:11 +02:00
|
|
|
visible: !hidden,
|
2020-05-21 23:43:17 +02:00
|
|
|
path: [
|
|
|
|
realPosition,
|
|
|
|
guessPosition
|
|
|
|
],
|
|
|
|
geodesic: true,
|
|
|
|
strokeOpacity: 0,
|
|
|
|
icons: [{
|
|
|
|
icon: {
|
|
|
|
path: 'M 0,-1 0,1',
|
|
|
|
strokeOpacity: 1,
|
|
|
|
strokeWeight: 2,
|
|
|
|
scale: 2
|
|
|
|
},
|
|
|
|
offset: '0',
|
|
|
|
repeat: '10px'
|
|
|
|
}],
|
|
|
|
clickable: false,
|
|
|
|
draggable: false,
|
|
|
|
editable: false
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-05-20 03:19:53 +02:00
|
|
|
calculateScore: function (distance) {
|
|
|
|
var goodness = 1.0 - distance / Math.sqrt(mapArea);
|
2020-05-17 19:29:06 +02:00
|
|
|
|
2020-05-21 14:07:37 +02:00
|
|
|
return Math.round(Math.pow(Core.MAX_SCORE, goodness));
|
2020-05-20 03:19:53 +02:00
|
|
|
},
|
2020-05-20 01:08:01 +02:00
|
|
|
|
2020-05-21 23:43:17 +02:00
|
|
|
calculateScoreBarProperties: function (score, maxScore) {
|
|
|
|
var percent = Math.floor((score / maxScore) * 100);
|
2020-05-20 03:19:53 +02:00
|
|
|
|
|
|
|
var color;
|
|
|
|
if (percent >= 90) {
|
|
|
|
color = '#11ca00';
|
|
|
|
} else if (percent >= 10) {
|
|
|
|
color = '#ea9000';
|
|
|
|
} else {
|
|
|
|
color = '#ca1100';
|
|
|
|
}
|
2020-05-17 19:29:06 +02:00
|
|
|
|
2020-05-20 03:19:53 +02:00
|
|
|
return { width: percent + '%', backgroundColor: color };
|
|
|
|
},
|
|
|
|
|
2020-05-21 23:43:17 +02:00
|
|
|
showSummary: function () {
|
|
|
|
var distanceInfo = document.getElementById('distanceInfo');
|
|
|
|
distanceInfo.children[0].style.display = 'none';
|
|
|
|
distanceInfo.children[1].style.display = 'block';
|
|
|
|
var scoreInfo = document.getElementById('scoreInfo');
|
|
|
|
scoreInfo.children[0].style.display = 'none';
|
|
|
|
scoreInfo.children[1].style.display = 'block';
|
|
|
|
document.getElementById('showSummaryButton').style.display = null;
|
|
|
|
document.getElementById('startNewGameButton').style.display = 'block';
|
|
|
|
|
|
|
|
var resultBounds = new google.maps.LatLngBounds();
|
|
|
|
|
|
|
|
for (var i = 0; i < Core.rounds.length; ++i) {
|
|
|
|
var round = Core.rounds[i];
|
|
|
|
|
2020-05-22 21:08:36 +02:00
|
|
|
round.realMarker.setLabel({
|
|
|
|
color: '#812519',
|
|
|
|
fontFamily: 'Roboto',
|
|
|
|
fontSize: '16px',
|
|
|
|
fontWeight: '500',
|
2020-05-24 14:47:15 +02:00
|
|
|
text: String(i + 1)
|
2020-05-22 21:08:36 +02:00
|
|
|
});
|
2020-05-21 23:43:17 +02:00
|
|
|
round.realMarker.setVisible(true);
|
|
|
|
round.guessMarker.setVisible(true);
|
|
|
|
round.line.setVisible(true);
|
|
|
|
|
|
|
|
resultBounds.extend(round.realPosition);
|
|
|
|
resultBounds.extend(round.guessPosition);
|
|
|
|
}
|
|
|
|
|
2020-05-22 23:23:54 +02:00
|
|
|
Core.map.fitBounds(resultBounds);
|
2020-05-21 23:43:17 +02:00
|
|
|
|
2020-05-23 01:25:43 +02:00
|
|
|
document.getElementById('scoreSum').innerHTML = String(Core.scoreSum);
|
2020-05-21 23:43:17 +02:00
|
|
|
|
|
|
|
var scoreBarProperties = Core.calculateScoreBarProperties(Core.scoreSum, Core.NUMBER_OF_ROUNDS * Core.MAX_SCORE);
|
|
|
|
var scoreBar = document.getElementById('scoreBar');
|
|
|
|
scoreBar.style.backgroundColor = scoreBarProperties.backgroundColor;
|
|
|
|
scoreBar.style.width = scoreBarProperties.width;
|
|
|
|
},
|
|
|
|
|
2020-05-20 03:19:53 +02:00
|
|
|
rewriteGoogleLink: function () {
|
|
|
|
if (!Core.googleLink) {
|
|
|
|
var anchors = document.getElementById('panorama').getElementsByTagName('a');
|
|
|
|
for (var i = 0; i < anchors.length; i++) {
|
|
|
|
var a = anchors[i];
|
|
|
|
if (a.href.indexOf('maps.google.com/maps') !== -1) {
|
|
|
|
Core.googleLink = a;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-17 19:29:06 +02:00
|
|
|
|
2020-05-20 03:19:53 +02:00
|
|
|
setTimeout(function () {
|
2020-05-22 23:32:17 +02:00
|
|
|
if (Core.googleLink) {
|
|
|
|
Core.googleLink.title = 'Google Maps';
|
|
|
|
Core.googleLink.href = 'https://maps.google.com/maps';
|
|
|
|
}
|
2020-05-20 03:19:53 +02:00
|
|
|
}, 1);
|
2020-05-22 01:31:32 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
saveToSession: function () {
|
|
|
|
if (Core.rounds.length == Core.NUMBER_OF_ROUNDS && Core.rounds[Core.rounds.length - 1].guessPosition) {
|
|
|
|
sessionStorage.removeItem('rounds');
|
|
|
|
sessionStorage.removeItem('scoreSum');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var roundsToSave = [];
|
|
|
|
for (var i = 0; i < Core.rounds.length; ++i) {
|
|
|
|
var round = Core.rounds[i];
|
|
|
|
roundsToSave.push({ realPosition: round.realPosition, guessPosition: round.guessPosition });
|
|
|
|
}
|
|
|
|
|
|
|
|
sessionStorage.setItem('rounds', JSON.stringify(roundsToSave));
|
|
|
|
sessionStorage.setItem('scoreSum', String(Core.scoreSum));
|
2020-05-19 19:01:35 +02:00
|
|
|
}
|
2020-05-20 03:19:53 +02:00
|
|
|
};
|
2020-05-19 19:01:35 +02:00
|
|
|
|
2020-05-20 03:19:53 +02:00
|
|
|
var Util = {
|
|
|
|
EARTH_RADIUS_IN_METER: 6371000,
|
2020-05-17 19:29:06 +02:00
|
|
|
|
2020-05-20 03:19:53 +02:00
|
|
|
deg2rad: function (deg) {
|
|
|
|
return deg * (Math.PI / 180.0);
|
|
|
|
},
|
2020-05-19 16:18:12 +02:00
|
|
|
|
2020-05-20 03:19:53 +02:00
|
|
|
calculateDistance: function (position1, position2) {
|
|
|
|
var lat1 = Util.deg2rad(position1.lat);
|
|
|
|
var lng1 = Util.deg2rad(position1.lng);
|
|
|
|
var lat2 = Util.deg2rad(position2.lat);
|
|
|
|
var lng2 = Util.deg2rad(position2.lng);
|
2020-05-20 01:08:01 +02:00
|
|
|
|
2020-05-20 03:19:53 +02:00
|
|
|
var angleCos = Math.cos(lat1) * Math.cos(lat2) * Math.cos(lng2 - lng1) +
|
|
|
|
Math.sin(lat1) * Math.sin(lat2);
|
2020-05-20 01:08:01 +02:00
|
|
|
|
2020-05-20 03:19:53 +02:00
|
|
|
if (angleCos > 1.0) {
|
|
|
|
angleCos = 1.0;
|
|
|
|
}
|
2020-05-20 01:08:01 +02:00
|
|
|
|
2020-05-20 03:19:53 +02:00
|
|
|
var angle = Math.acos(angleCos);
|
2020-05-20 01:08:01 +02:00
|
|
|
|
2020-05-20 03:19:53 +02:00
|
|
|
return angle * Util.EARTH_RADIUS_IN_METER;
|
|
|
|
},
|
2020-05-20 01:08:01 +02:00
|
|
|
|
2020-05-20 03:19:53 +02:00
|
|
|
printDistanceForHuman: function (distance) {
|
|
|
|
if (distance < 1000) {
|
|
|
|
return Number.parseFloat(distance).toFixed(0) + ' m';
|
|
|
|
} else if (distance < 10000) {
|
|
|
|
return Number.parseFloat(distance / 1000).toFixed(2) + ' km';
|
|
|
|
} else if (distance < 100000) {
|
|
|
|
return Number.parseFloat(distance / 1000).toFixed(1) + ' km';
|
|
|
|
} else {
|
|
|
|
return Number.parseFloat(distance / 1000).toFixed(0) + ' km';
|
2020-05-17 19:29:06 +02:00
|
|
|
}
|
|
|
|
}
|
2020-05-20 03:19:53 +02:00
|
|
|
};
|
2020-05-17 19:29:06 +02:00
|
|
|
|
2020-05-21 03:24:09 +02:00
|
|
|
if (!('ontouchstart' in document.documentElement)) {
|
|
|
|
Core.adaptGuess = true;
|
|
|
|
}
|
|
|
|
|
2020-05-22 23:23:54 +02:00
|
|
|
Core.map = new google.maps.Map(document.getElementById('map'), {
|
2020-05-17 19:29:06 +02:00
|
|
|
disableDefaultUI: true,
|
|
|
|
clickableIcons: false,
|
2020-05-22 23:22:11 +02:00
|
|
|
draggableCursor: 'crosshair',
|
|
|
|
draggingCursor: 'grabbing'
|
2020-05-17 19:29:06 +02:00
|
|
|
});
|
|
|
|
|
2020-05-22 23:23:54 +02:00
|
|
|
Core.map.fitBounds(guessMapBounds);
|
2020-05-17 19:29:06 +02:00
|
|
|
|
2020-05-22 23:23:54 +02:00
|
|
|
Core.map.addListener('click', function (e) {
|
2020-05-22 23:22:11 +02:00
|
|
|
if (Core.rounds[Core.rounds.length - 1].guessPosition) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-05-20 03:19:53 +02:00
|
|
|
if (Core.guessMarker) {
|
|
|
|
Core.guessMarker.setPosition(e.latLng);
|
2020-05-17 19:29:06 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-05-20 03:19:53 +02:00
|
|
|
Core.guessMarker = new google.maps.Marker({
|
2020-05-22 23:23:54 +02:00
|
|
|
map: Core.map,
|
2020-05-17 19:29:06 +02:00
|
|
|
position: e.latLng,
|
2020-05-19 16:18:12 +02:00
|
|
|
clickable: false,
|
|
|
|
draggable: true,
|
|
|
|
label: {
|
|
|
|
color: '#ffffff',
|
|
|
|
fontFamily: 'Roboto',
|
|
|
|
fontSize: '18px',
|
|
|
|
fontWeight: '500',
|
|
|
|
text: '?'
|
|
|
|
}
|
2020-05-17 19:29:06 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
document.getElementById('guessButton').disabled = false;
|
|
|
|
});
|
2020-05-19 16:18:12 +02:00
|
|
|
|
2020-05-20 03:19:53 +02:00
|
|
|
Core.panorama = new google.maps.StreetViewPanorama(document.getElementById('panorama'), {
|
2020-05-19 16:18:12 +02:00
|
|
|
disableDefaultUI: true,
|
|
|
|
linksControl: true,
|
2020-05-21 12:17:53 +02:00
|
|
|
showRoadLabels: false,
|
|
|
|
motionTracking: false
|
2020-05-19 16:18:12 +02:00
|
|
|
});
|
|
|
|
|
2020-05-20 03:19:53 +02:00
|
|
|
Core.panorama.addListener('position_changed', function () {
|
|
|
|
Core.rewriteGoogleLink();
|
2020-05-19 16:18:12 +02:00
|
|
|
});
|
|
|
|
|
2020-05-20 03:19:53 +02:00
|
|
|
Core.panorama.addListener('pov_changed', function () {
|
|
|
|
Core.rewriteGoogleLink();
|
2020-05-19 16:18:12 +02:00
|
|
|
});
|
|
|
|
|
2020-05-22 01:31:32 +02:00
|
|
|
Core.initialize();
|
2020-05-17 19:29:06 +02:00
|
|
|
|
2020-05-21 01:59:31 +02:00
|
|
|
document.getElementById('showGuessButton').onclick = function () {
|
|
|
|
this.style.visibility = 'hidden';
|
|
|
|
document.getElementById('guess').style.visibility = 'visible';
|
|
|
|
}
|
|
|
|
|
|
|
|
document.getElementById('closeGuessButton').onclick = function () {
|
|
|
|
document.getElementById('showGuessButton').style.visibility = null;
|
|
|
|
document.getElementById('guess').style.visibility = null;
|
|
|
|
}
|
|
|
|
|
2020-05-20 03:19:53 +02:00
|
|
|
document.getElementById('guessButton').onclick = function () {
|
|
|
|
if (!Core.guessMarker) {
|
|
|
|
return;
|
2020-05-19 03:25:42 +02:00
|
|
|
}
|
|
|
|
|
2020-05-20 03:19:53 +02:00
|
|
|
this.disabled = true;
|
2020-05-20 01:08:01 +02:00
|
|
|
|
2020-05-21 23:43:17 +02:00
|
|
|
Core.evaluateGuess();
|
2020-05-20 03:19:53 +02:00
|
|
|
}
|
2020-05-19 16:18:12 +02:00
|
|
|
|
2020-05-20 03:19:53 +02:00
|
|
|
document.getElementById('continueButton').onclick = function () {
|
2020-05-21 23:43:17 +02:00
|
|
|
Core.prepareNewRound();
|
|
|
|
}
|
2020-05-19 16:18:12 +02:00
|
|
|
|
2020-05-21 23:43:17 +02:00
|
|
|
document.getElementById('showSummaryButton').onclick = function () {
|
|
|
|
Core.showSummary();
|
|
|
|
}
|
2020-05-17 19:29:06 +02:00
|
|
|
|
2020-05-21 23:43:17 +02:00
|
|
|
document.getElementById('startNewGameButton').onclick = function () {
|
|
|
|
Core.startNewGame();
|
2020-05-20 03:19:53 +02:00
|
|
|
}
|
2020-05-24 14:47:15 +02:00
|
|
|
|
|
|
|
window.onbeforeunload = function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.returnValue = '';
|
|
|
|
};
|
2020-05-20 03:19:53 +02:00
|
|
|
})();
|