Geoguessr Unity Script

For a full list of features included in this script, see this document https://docs.google.com/document/d/18nLXSQQLOzl4WpUgZkM-mxhhQLY6P3FKonQGp-H0fqI/edit?usp=sharing

Versione datata 29/04/2022. Vedi la nuova versione l'ultima versione.

  1. // ==UserScript==
  2. // @name Geoguessr Unity Script
  3. // @description For a full list of features included in this script, see this document https://docs.google.com/document/d/18nLXSQQLOzl4WpUgZkM-mxhhQLY6P3FKonQGp-H0fqI/edit?usp=sharing
  4. // @version 6.3.0
  5. // @author Jupaoqq
  6. // @match https://www.geoguessr.com/*
  7. // @run-at document-start
  8. // @license MIT
  9. // @namespace https://greatest.deepsurf.us/users/838374
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. /**
  14. * Custom your minimap here!
  15. */
  16.  
  17. /**
  18. * 1: replace "roadmap" in the customMode field with any of the options below:
  19. * "roadmap" displays the default road map view. This is the default map type.
  20. * "satellite" displays Google Earth satellite images.
  21. * "hybrid" displays a mixture of normal and satellite views.
  22. * "terrain" displays a physical map based on terrain information.
  23. */
  24.  
  25. let customMode = "roadmap";
  26.  
  27. /**
  28. * 2: Go to https://mapstyle.withgoogle.com/ first click "No thanks, take me to the old style wizard"
  29. * then click "MORE OPTIONS" to hide or reveal certain features.
  30. * When you are done, click "FINISH", then "COPY JSON", and replace my settings in custom with your settings below.
  31. */
  32.  
  33. let custom =
  34.  
  35. [
  36. {
  37. "featureType": "administrative",
  38. "stylers": [
  39. {
  40. "visibility": "off"
  41. }
  42. ]
  43. },
  44. {
  45. "featureType": "landscape",
  46. "stylers": [
  47. {
  48. "visibility": "off"
  49. }
  50. ]
  51. },
  52. {
  53. "featureType": "poi.park",
  54. "stylers": [
  55. {
  56. "visibility": "off"
  57. }
  58. ]
  59. },
  60. {
  61. "featureType": "road",
  62. "elementType": "labels",
  63. "stylers": [
  64. {
  65. "visibility": "off"
  66. }
  67. ]
  68. },
  69. {
  70. "featureType": "transit",
  71. "stylers": [
  72. {
  73. "visibility": "off"
  74. }
  75. ]
  76. }
  77. ]
  78.  
  79. /**
  80. * End of Minimap customization instruction section
  81. */
  82.  
  83. /**
  84. * Overlay anything on the minimap here!
  85. * 1. overlay an GeoJSON object
  86. * 2. overlay a custom image
  87. */
  88.  
  89. /**
  90. * Overlay an GeoJSON object:
  91. */
  92.  
  93. // change the GeoJson display style.
  94. // strokeOpacity, strokeWeight, fillOpacity takes a value between 0 and 1.
  95. // strokeColor and fillColor supports Hexadecimal color (#00FF00 is green)
  96. // If clickable is set to true, you would not be able to make a guess within the shape
  97.  
  98. let GEOJSON_STYLE =
  99. {
  100. strokeColor: "black",
  101. strokeOpacity: 1,
  102. strokeWeight: 0.2,
  103. fillColor: "#00FF00",
  104. fillOpacity: 0,
  105. clickable: false,
  106. }
  107.  
  108. // replace the URL with your desired link
  109. // For example, search "Germany GeoJson" on Github, find this link (https://github.com/isellsoap/deutschlandGeoJSON/blob/main/4_kreise/4_niedrig.geo.json)
  110. // Then click "Download" to get the raw.githubusercontent.com link (https://raw.githubusercontent.com/isellsoap/deutschlandGeoJSON/main/4_kreise/4_niedrig.geo.json)
  111. // and replace the URL below with that URL.
  112. // State zipcode: see this site https://github.com/OpenDataDE/State-zip-code-GeoJSON
  113.  
  114. let YOUR_URL = "https://raw.githubusercontent.com/severinlandolt/map-switzerland/main/02%20GeoJSON/CH_Kantonsgrenzen_100_geo.json"
  115.  
  116. // set it to true to add your custom GeoJSON by copy it to the code below (this is for
  117.  
  118. let GeoJsonCustomUser = false
  119.  
  120. // replace with your custom GeoJson, go to https://geojson.io/ to customize it then copy the Json to here
  121.  
  122. let CUSTOM_GEOJSON =
  123.  
  124. {
  125. "type": "FeatureCollection",
  126. "features": [
  127. {
  128. "type": "Feature",
  129. "properties": {},
  130. "geometry": {
  131. "type": "LineString",
  132. "coordinates": [
  133. [
  134. 2.493896484375,
  135. 52.7163309360463
  136. ],
  137. [
  138. 2.4609375,
  139. 53.15994678846807
  140. ],
  141. [
  142. 3.2025146484375,
  143. 53.179703893605385
  144. ],
  145. [
  146. 3.2080078125,
  147. 52.96518371955126
  148. ],
  149. [
  150. 2.48291015625,
  151. 52.948637884883205
  152. ]
  153. ]
  154. }
  155. },
  156. {
  157. "type": "Feature",
  158. "properties": {},
  159. "geometry": {
  160. "type": "LineString",
  161. "coordinates": [
  162. [
  163. 3.218994140625,
  164. 52.05586831074774
  165. ],
  166. [
  167. 3.218994140625,
  168. 52.13685974852633
  169. ],
  170. [
  171. 2.515869140625,
  172. 52.1267438596429
  173. ],
  174. [
  175. 2.515869140625,
  176. 51.77803705914517
  177. ],
  178. [
  179. 3.2354736328125,
  180. 51.78993084774129
  181. ],
  182. [
  183. 3.228607177734375,
  184. 51.96119237712624
  185. ],
  186. [
  187. 2.8571319580078125,
  188. 51.95230623740452
  189. ]
  190. ]
  191. }
  192. },
  193. {
  194. "type": "Feature",
  195. "properties": {
  196. "stroke": "#555555",
  197. "stroke-width": 2,
  198. "stroke-opacity": 1
  199. },
  200. "geometry": {
  201. "type": "LineString",
  202. "coordinates": [
  203. [
  204. 2.5048828125,
  205. 52.619725272670266
  206. ],
  207. [
  208. 2.5103759765625,
  209. 52.274880130680536
  210. ],
  211. [
  212. 2.867431640625,
  213. 52.284962354465726
  214. ],
  215. [
  216. 3.2299804687499996,
  217. 52.29504228453735
  218. ],
  219. [
  220. 3.2135009765625,
  221. 52.63973017532399
  222. ],
  223. [
  224. 2.5096893310546875,
  225. 52.621392697207625
  226. ]
  227. ]
  228. }
  229. }
  230. ]
  231. }
  232.  
  233. /**
  234. * Overlay a custom image:
  235. */
  236.  
  237. // set it to true to add your image overlay
  238.  
  239. let OverlayCustom = false
  240.  
  241. // replace the URL with your desired link
  242.  
  243. let OVERLAY_URL = "https://www.battleface.com/blog/wp-content/uploads/2020/10/patreon-profile-tom-geowizard.jpg"
  244.  
  245. // set the bounds for the image - latitude (North and South), longitude (North and South)
  246.  
  247. let OVERLAY_BOUNDS =
  248. {
  249. north: 53,
  250. west: -3,
  251. south: 51,
  252. east: 1,
  253. };
  254.  
  255. // change the image overlay display style.
  256.  
  257. let OVERLAY_STYLE =
  258. {
  259. fillOpacity: 0.2,
  260. clickable: false,
  261. }
  262.  
  263. /**
  264. * End of Minimap Overlay instruction section
  265. */
  266.  
  267. // API Keys
  268.  
  269. var MS_API_KEY = "Ap2DwDDitzY7jJuYeIJF6YyfqDkYt-QxIBjeQ6SDEJelSfb6ghAVb-V4I-G3om-s";
  270. var YANDEX_API_KEY = "b704b5a9-3d67-4d19-b702-ec7807cecfc6";
  271. var KAKAO_API_KEY = "cbacbe41e3a223d794f321de4f3e247b";
  272. var MAPBOX_API_KEY = "pk.eyJ1IjoianVwYW9xcSIsImEiOiJjbDB2dTBnbngweWIzM2NtdWR5NXZ1dncyIn0.bJixk3kN5Mmedw_C3vQmmw";
  273. const MAPS_API_URL = "https://maps.googleapis.com/maps/api/js"; // removed "?" from the link
  274. var MAPILLARY_API_KEY_LIST =
  275. ["MLY|6723031704435203|5afd537469b114cf814881137ad74b7c",
  276. "MLY|6691659414239148|b45e7e82cde126044cbc2cf5d4a7c9b1",
  277. "MLY|5074369465929308|f7ad2802cbaf26c63f88046a292df68b",
  278. "MLY|7451643761528219|6477f2db0e3928b51e45ec9311983936",
  279. "MLY|4855256237866198|6d0464771831c8a4bf2be095e1e1aabc",
  280. "MLY|4772941976102161|8458d4f08d2e1970cdfe0a4e242c04ff",
  281. "MLY|4492067214235489|94c44703942362ad6f6b70b5d32c3a45",
  282. "MLY|4618251611628426|0cef71d6ec8b997a5ec06ecdeabf11ec",
  283. "MLY|4096846270415982|fa2ce29641503e6ef665f17459633570",
  284. "MLY|4231415756962414|fe353880fd246e8a4a6ae32152f7dbb0",]
  285.  
  286. var MAPILLARY_API_KEY = MAPILLARY_API_KEY_LIST[Math.floor(Math.random() * MAPILLARY_API_KEY_LIST.length)];
  287.  
  288. console.log("Geoguessr Unity Script v6.3.0 by Jupaoqq");
  289.  
  290.  
  291. // Store each player instance
  292.  
  293. let YandexPlayer, KakaoPlayer, GooglePlayer, MapillaryPlayer, MSStreetPlayer, MapboxPlayer, MapboxMarker;
  294. let YANDEX_INJECTED = false;
  295. let BAIDU_INJECTED = false;
  296. let KAKAO_INJECTED = false;
  297. let MAPILLARY_INJECTED = false;
  298. let MS_INJECTED = false;
  299. let MAPBOX_INJECTED = false;
  300. let rainLayer;
  301.  
  302. // Game mode detection
  303.  
  304. let isBattleRoyale = false;
  305. let isDuel = false;
  306. let isBullseye = false;
  307. let isLiveChallenge = false;
  308.  
  309. // Player detection and coordinate conversion
  310.  
  311. let nextPlayer = "Google";
  312. let nextPlayer_save = "Google";
  313. let global_lat = 0;
  314. let global_lng = 0;
  315. let global_cc = null;
  316. let global_panoID = null;
  317. let global_BDID, global_BDAh, global_BDBh;
  318. let yId, yTime, yEnd, iId;
  319. let global_heading = null;
  320. let global_pitch = null;
  321.  
  322. let krCoordinates = [38.75292321084364, 124.2804539232574, 33.18509676203202, 129.597381999198]
  323. let global_radi = 100
  324.  
  325. // Callback variables
  326.  
  327. let eventListenerAttached = false;
  328. let povListenerAttached = false;
  329. let playerLoaded = false;
  330. let teleportLoaded = false;
  331. let syncLoaded = false;
  332.  
  333. // Minimize Yandex API use
  334.  
  335. let yandex_map = false;
  336. let Kakao_map = false;
  337. let Wikipedia_map = false;
  338. let Minecraft_map = false;
  339. let bing_map = false;
  340.  
  341. // Mapillary Image Key
  342.  
  343. let mmKey = 0;
  344.  
  345. // Handle Yandex compass
  346.  
  347. let COMPASS = null;
  348.  
  349. // Handle undo
  350.  
  351. let locHistory = [];
  352. let defaultPanoIdChange = true;
  353.  
  354. // Round check
  355.  
  356. let ROUND = 0;
  357. let CURRENT_ROUND_DATA = null;
  358.  
  359. let switch_call = true;
  360. let one_reset = false;
  361. // let cnt = 0;
  362.  
  363. let cn_tips = false;
  364. var isFirefox = typeof InstallTrigger !== 'undefined';
  365.  
  366. let linksList = []
  367. let fire1 = true;
  368. let allowDetect = false;
  369. let planetType = "None";
  370.  
  371. // Satellite Map Radius (in Meters)
  372. let ms_radius = 15000;
  373. let sat_choice = false;
  374.  
  375. // Create the Maps, but not reload API
  376. let partialCreateYandex = false;
  377. let partialCreateKakao = false;
  378. let partialCreateMapillary = false;
  379. let partialCreateMS = false;
  380. let partialCreateMapbox = false;
  381.  
  382. // let NEW_ROUND_LOADED = false;
  383.  
  384. // Geoguessr Canvas String Names
  385.  
  386. let GENERAL_LAYOUT = ".game-layout__canvas";
  387. let GENERAL_CANVAS = ".game-layout__panorama-canvas";
  388. let BR_CANVAS = ".br-game-layout__panorama-canvas";
  389. let BR_WRAPPER = ".br-game-layout__panorama-wrapper";
  390. let BR_LAYOUT = ".br-game-layout";
  391. let FAIL_TO_LOAD_CANVAS = ".game-layout__panorama-message";
  392. let DUEL_LAYOUT = ".game_layout__TO_jf";
  393. let DUELS_CANVAS = ".game-panorama_panorama__rdhFg";
  394. let DUELS_CANVAS2 = ".game-panorama_panoramaCanvas__PNKve";
  395. let BULLSEYE_CANVAS = ".game-panorama_panorama__ncMwh";
  396. let BULLSEYE_CANVAS2 = ".game-panorama_panoramaCanvas__r_5ea";
  397. let LIVE_CANVAS = ".game-panorama_panorama__Qpsxl";
  398. let LIVE_CANVAS2 = ".game-panorama_panoramaCanvas__LaXCd";
  399. let DUELS_POPUP = ".overlay_overlay__AR02x";
  400. let BR_POPUP = ".popup__content";
  401.  
  402. let BR_LOAD_KAKAO = false;
  403. let BR_LOAD_YANDEX = false;
  404. let BR_LOAD_MS = false;
  405. let BR_LOAD_MP = false;
  406. let BR_LOAD_MAPILLARY = false;
  407.  
  408. let ms_sat_map = false;
  409. let rtded = false;
  410. let NM = false;
  411. let NP = false;
  412. let NZ = false;
  413.  
  414. let initBing = false;
  415.  
  416. let menuLocCounter = 0;
  417. let wikiUrl = "";
  418. let bullseyeMapillary = false;
  419. let randomPlanets = false;
  420.  
  421. let GAME_CANVAS = "";
  422. let DUEL_CANVAS = "";
  423.  
  424. function sleep(milliseconds) {
  425. var start = new Date().getTime();
  426. for (var i = 0; i < 1e7; i++) {
  427. if ((new Date().getTime() - start) > milliseconds){
  428. break;
  429. }
  430. }
  431. }
  432.  
  433. // window.addEventListener('popstate', function(event) {
  434. // var photo = document.getElementById("sat_map");
  435. // console.log(photo);
  436. // document.body.appendChild(photo);
  437. // }, false);
  438.  
  439.  
  440.  
  441. /**
  442. * Helper Functions
  443. */
  444.  
  445. // Highlight API Load Message
  446.  
  447. function myHighlight(...args) {
  448. console.log(`%c${[...args]}`, "color: dodgerblue; font-size: 24px;");
  449. }
  450.  
  451. // Hex to number conversion for Baidu coordinate conversion
  452.  
  453. function hex2a(hexx) {
  454. var hex = hexx.toString();
  455. var str = '';
  456. for (var i = 0; i < hex.length; i += 2)
  457. {
  458. str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
  459. }
  460. return str;
  461. }
  462.  
  463. // Coordinate computation given heading, distance and current coordinates for teleport
  464.  
  465. function FindPointAtDistanceFrom(lat, lng, initialBearingRadians, distanceKilometres) {
  466. const radiusEarthKilometres = 6371.01;
  467. var distRatio = distanceKilometres / radiusEarthKilometres;
  468. var distRatioSine = Math.sin(distRatio);
  469. var distRatioCosine = Math.cos(distRatio);
  470.  
  471. var startLatRad = DegreesToRadians(lat);
  472. var startLonRad = DegreesToRadians(lng);
  473.  
  474. var startLatCos = Math.cos(startLatRad);
  475. var startLatSin = Math.sin(startLatRad);
  476.  
  477. var endLatRads = Math.asin((startLatSin * distRatioCosine) + (startLatCos * distRatioSine * Math.cos(initialBearingRadians)));
  478.  
  479. var endLonRads = startLonRad
  480. + Math.atan2(
  481. Math.sin(initialBearingRadians) * distRatioSine * startLatCos,
  482. distRatioCosine - startLatSin * Math.sin(endLatRads));
  483.  
  484. return { lat: RadiansToDegrees(endLatRads), lng: RadiansToDegrees(endLonRads) };
  485. }
  486.  
  487. function DegreesToRadians(degrees) {
  488. const degToRadFactor = Math.PI / 180;
  489. return degrees * degToRadFactor;
  490. }
  491.  
  492. function RadiansToDegrees(radians) {
  493. const radToDegFactor = 180 / Math.PI;
  494. return radians * radToDegFactor;
  495. }
  496.  
  497. function toRadians(degrees) {
  498. return degrees * Math.PI / 180;
  499. };
  500.  
  501. // Converts from radians to degrees.
  502. function toDegrees(radians) {
  503. return radians * 180 / Math.PI;
  504. }
  505.  
  506. function bearing(start_latitude, start_longitude, stop_latitude, stop_longitude){
  507. let y = Math.sin(stop_longitude-start_longitude) * Math.cos(stop_latitude);
  508. let x = Math.cos(start_latitude)*Math.sin(stop_latitude) -
  509. Math.sin(start_latitude)*Math.cos(stop_latitude)*Math.cos(stop_longitude-start_longitude);
  510. let brng = Math.atan2(y, x) * 180 / Math.PI;
  511. return brng
  512. }
  513.  
  514. // Check if two floating point numbers are really really really really close to each other (to 10 decimal points)
  515. function almostEqual (a, b) {
  516. return a.toFixed(10) === b.toFixed(10)
  517. }
  518.  
  519. function almostEqual2 (a, b) {
  520. return a.toFixed(3) === b.toFixed(3)
  521. }
  522.  
  523. function moveFrom(coords, angle, distance){
  524. const R_EARTH = 6378.137;
  525. const M = (1 / ((2 * Math.PI / 360) * R_EARTH)) / 1000;
  526. let radianAngle = -angle * Math.PI / 180;
  527. let x = 0 + (distance * Math.cos(radianAngle));
  528. let y = 0 + (distance * Math.sin(radianAngle));
  529.  
  530. let newLat = coords.lat + (y * M);
  531. let newLng = coords.lng + (x * M) / Math.cos(coords.lat * (Math.PI / 180));
  532. return { lat: newLat, lng: newLng };
  533. }
  534.  
  535. function getBBox(coordinates, meters){
  536. let SW = moveFrom(coordinates, 135, meters);
  537. let NE = moveFrom(coordinates, 315, meters);
  538. return `${SW.lng},${SW.lat},${NE.lng},${NE.lat}`;
  539. }
  540.  
  541. // function getBBox2(coordinates, meters){
  542. // let SW = moveFrom(coordinates, 135, meters * 1.44);
  543. // let NE = moveFrom(coordinates, 315, meters * 1.44);
  544. // return [NE.lat,SW.lng,SW.lat,NE.lng];
  545. // }
  546.  
  547. function getBBox2(coordinates, meters){
  548. let SW = moveFrom(coordinates, 135, meters * 1.44);
  549. let NE = moveFrom(coordinates, 315, meters * 1.44);
  550. if (NE.lat > 90)
  551. {
  552. SW.lat -= (NE.lat - 90);
  553. NE.lat = 90;
  554. }
  555. if (SW.lat < -90)
  556. {
  557. NE.lat += (-90 - SW.lat);
  558. SW.lat = -90;
  559. }
  560. if (SW.lng < -180)
  561. {
  562. NE.lng += (-180 - SW.lng);
  563. SW.lng = -180;
  564. }
  565. if (NE.lng > 180)
  566. {
  567. SW.lng -= (NE.lng - 180);
  568. NE.lng = 180;
  569. }
  570. return [NE.lat,SW.lng,SW.lat,NE.lng];
  571. }
  572.  
  573. function distance(lat1, lon1, lat2, lon2) {
  574. var p = 0.017453292519943295; // Math.PI / 180
  575. var c = Math.cos;
  576. var a = 0.5 - c((lat2 - lat1) * p)/2 +
  577. c(lat1 * p) * c(lat2 * p) *
  578. (1 - c((lon2 - lon1) * p))/2;
  579.  
  580. return 1000 * 12742 * Math.asin(Math.sqrt(a)); // 2 * R; R = 6371 km
  581. }
  582.  
  583. // Script injection, extracted from extenssr:
  584. // https://gitlab.com/nonreviad/extenssr/-/blob/main/src/injected_scripts/maps_api_injecter.ts
  585.  
  586. function overrideOnLoad(googleScript, observer, overrider) {
  587. const oldOnload = googleScript.onload
  588. googleScript.onload = (event) => {
  589. const google = window.google
  590. if (google) {
  591. observer.disconnect()
  592. overrider(google)
  593. }
  594. if (oldOnload) {
  595. oldOnload.call(googleScript, event)
  596. }
  597. }
  598. }
  599.  
  600. function grabGoogleScript(mutations) {
  601. for (const mutation of mutations) {
  602. for (const newNode of mutation.addedNodes) {
  603. const asScript = newNode
  604. if (asScript && asScript.src && asScript.src.startsWith('https://maps.googleapis.com/')) {
  605. //asScript.src = "https://maps.googleapis.com/maps/api/js?key=AIzaSyDqRTXlnHXELLKn7645Q1L_5oc4CswKZK4&v=3&libraries=places,drawing&language=ja&region=JP"
  606. return asScript
  607. }
  608. }
  609. }
  610. return null
  611. }
  612.  
  613. function injecter(overrider) {
  614. if (document.documentElement)
  615. {
  616. injecterCallback(overrider);
  617. }
  618. else
  619. {
  620. alert("Script didn't load, refresh to try loading the script");
  621. }
  622. }
  623.  
  624.  
  625. function injecterCallback(overrider)
  626. {
  627. new MutationObserver((mutations, observer) => {
  628. const googleScript = grabGoogleScript(mutations)
  629. if (googleScript) {
  630. overrideOnLoad(googleScript, observer, overrider)
  631. }
  632. }).observe(document.documentElement, { childList: true, subtree: true })
  633. }
  634.  
  635. function magic_formula(boundary)
  636. {
  637. let area = Math.abs((boundary[0] - boundary[2]) * (boundary[1] - boundary[3]))
  638. // console.log(boundary);
  639. // console.log(area);
  640. let dist = Math.pow((area / 50000), 0.25) * 20000
  641. if (dist < 250) dist = 250
  642. return dist
  643. }
  644.  
  645. function formatDist()
  646. {
  647. if (ms_radius > 999)
  648. {
  649. let d = ms_radius / 1000.0;
  650. return parseFloat(d.toPrecision(2)).toString() + "km";
  651. }
  652. else
  653. {
  654. let d = ms_radius;
  655. return parseFloat(d.toPrecision(3)).toString() + "m";
  656. }
  657. }
  658.  
  659. // Getter function for the button elements
  660.  
  661. function setButtons()
  662. {
  663. // console.log("set")
  664. return [document.getElementById("Teleport Forward"), document.getElementById("Teleport Reverse"), document.getElementById("Teleport Button"), document.getElementById("plus"), document.getElementById("minus"),
  665. document.getElementById("reset"), document.getElementById("switch"), document.getElementById("Show Buttons"),
  666. document.getElementById("Date Button"), document.getElementById("minus year"), document.getElementById("plus year"),
  667. document.getElementById("Teleport Options Button"), document.getElementById("Satellite Switch"),
  668. document.getElementById("Restrict Bounds Main"),
  669. document.getElementById("Restrict Distance"), document.getElementById("Increase Restrict Distance"),
  670. document.getElementById("Decrease Restrict Distance"), document.getElementById("Restrict Bounds Enable"),
  671. document.getElementById("Restrict Distance Reset")];
  672. }
  673.  
  674. function setButtons2()
  675. {
  676. // console.log("set")
  677. return [document.getElementById("Show Buttons"),
  678. document.getElementById("Youtube Button"),
  679. document.getElementById("Info Menu"),
  680. document.getElementById("Teleport Menu"),
  681. document.getElementById("Satellite Menu"),
  682. document.getElementById("Mosaic Menu"),
  683. document.getElementById("Minimap Menu Button"),
  684. document.getElementById("Space Menu Button"),
  685. document.getElementById("Time Machine Button"),
  686. ]
  687. }
  688.  
  689. // Store default position for the button elements
  690.  
  691. function btnPosFinal(element)
  692. {
  693. if (element.id !== "Show Buttons")
  694. {
  695. if (element.classList.contains("menu-btn"))
  696. {
  697. element.style.right = "0.5em";
  698. }
  699.  
  700. if (element.classList.contains("full") || element.classList.contains("extra-full"))
  701. {
  702. element.style.right = "4em";
  703. }
  704. else if (element.classList.contains("half"))
  705. {
  706. if (element.classList.contains("horizontal-1"))
  707. {
  708. element.style.right = "4em";
  709. }
  710. else if (element.classList.contains("horizontal-2"))
  711. {
  712. element.style.right = "11.75em";
  713. }
  714. else if (element.classList.contains("horizontal-3"))
  715. {
  716. element.style.right = "19.5em";
  717. }
  718. }
  719. else if (element.classList.contains("small"))
  720. {
  721. if (element.classList.contains("horizontal-1"))
  722. {
  723. element.style.right = "17em";
  724. }
  725. else if (element.classList.contains("horizontal-3"))
  726. {
  727. element.style.right = "4em";
  728. }
  729. }
  730. else if (element.classList.contains("large"))
  731. {
  732. element.style.right = "6.5em";
  733. }
  734.  
  735. if (element.classList.contains("vertical-0"))
  736. {
  737. element.style.top = "6em";
  738. }
  739. else if (element.classList.contains("vertical-1"))
  740. {
  741. element.style.top = "9.5em";
  742. }
  743. else if (element.classList.contains("vertical-2"))
  744. {
  745. element.style.top = "12em";
  746. }
  747. else if (element.classList.contains("vertical-3"))
  748. {
  749. element.style.top = "14.5em";
  750. }
  751. else if (element.classList.contains("vertical-4"))
  752. {
  753. element.style.top = "17em";
  754. }
  755. else if (element.classList.contains("vertical-5"))
  756. {
  757. element.style.top = "19.5em";
  758. }
  759. else if (element.classList.contains("vertical-6"))
  760. {
  761. element.style.top = "22em";
  762. }
  763. else if (element.classList.contains("vertical-7"))
  764. {
  765. element.style.top = "24.5em";
  766. }
  767. }
  768. }
  769.  
  770. function handleDropdown()
  771. {
  772. function dropdownHelper1(nm)
  773. {
  774. let hC = 0
  775. for (let mapDiv of document.getElementsByClassName(nm)){
  776. mapDiv.style.top = (11.85 + (hC * 1.65)).toString() + "em";
  777. hC++;
  778. }
  779. }
  780. function dropdownHelper2(nm)
  781. {
  782. let hC = 0
  783. for (let mapDiv of document.getElementsByClassName(nm)){
  784. mapDiv.style.top = (14.1 + (hC * 1.65)).toString() + "em";
  785. hC++;
  786. }
  787. }
  788. // let classN = ["preset-minimap", "overlay-minimap", "space-mainmap", "space-minimap"]
  789. let classN = ["preset-minimap", "overlay-minimap", "space-minimap", "space-2minimap", "space-3minimap"]
  790. for (let x of classN)
  791. {
  792. dropdownHelper1(x);
  793. }
  794. let classN2 = ["satellite-style", "satellite-type", "grid-size", "grid-opt"];
  795. for (let x of classN2)
  796. {
  797. dropdownHelper2(x);
  798. }
  799. allowDetect = true;
  800. }
  801.  
  802. function resetBtnPos()
  803. {
  804. let [
  805. mainMenuBtn,
  806. YoutubeBtn,
  807. infoMenu,
  808. teleportMenu,
  809. satelliteMenu,
  810. mosaicMenu,
  811. MinimapMenuBtn,
  812. SpaceMenuBtn,
  813. ClockMenuBtn
  814. ] = setButtons2();
  815.  
  816. // Manu Buttons
  817.  
  818. mainMenuBtn.style.top = "6em";
  819. YoutubeBtn.style.top = "6em";
  820. infoMenu.style.top = "9.5em";
  821. teleportMenu.style.top = "12.5em";
  822. MinimapMenuBtn.style.top = "15.5em";
  823. satelliteMenu.style.top = "18.5em";
  824. SpaceMenuBtn.style.top = "21.5em";
  825. mosaicMenu.style.top = "24.5em";
  826. ClockMenuBtn.style.top = "27.5em";
  827.  
  828. mainMenuBtn.style.right = "0.5em";
  829. mainMenuBtn.style.width = "3em";
  830.  
  831. for (let element of document.getElementsByClassName("unity-btn")){
  832. btnPosFinal(element);
  833. }
  834. handleDropdown();
  835.  
  836. }
  837.  
  838. // Adjust Buttons for different game modes
  839.  
  840. function AdjustBtnPos(top, right, arg)
  841. {
  842. if (arg)
  843. {
  844. resetBtnPos();
  845. }
  846. for (let element of document.getElementsByClassName("unity-btn")){
  847. let eTop = element.style.top;
  848. let eRight = element.style.right;
  849. element.style.top = "calc(" + top.toString() + " + " + eTop + ")";
  850. element.style.right = "calc(" + right.toString() + " + " + eRight + ")";
  851. // console.log(element.style.top)
  852. }
  853. }
  854.  
  855. function handleStyles()
  856. {
  857. let unityCSS =
  858. `visibility:hidden;
  859. border-radius: 25px;
  860. opacity: 0.8;
  861. height:2em;
  862. position:fixed;
  863. z-index:99999;
  864. background-color: #ba55d3;
  865. box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.1);
  866. border: none;
  867. color: white;
  868. padding: none;
  869. text-align: center;
  870. vertical-align: text-top;
  871. text-decoration: none;
  872. display: inline-block;
  873. font-size: 16px;`;
  874.  
  875. for (let element of document.getElementsByClassName("unity-btn")){
  876. if (element.id !== "Show Buttons")
  877. {
  878. element.style = unityCSS;
  879. // const classNames = ["preset-minimap", "overlay-minimap", "satellite-style", "satellite-type", "space-mainmap", "space-minimap"]
  880. const classNames = ["preset-minimap", "overlay-minimap", "satellite-style", "satellite-type", "space-minimap","space-2minimap","space-3minimap", "grid-size", "grid-opt"]
  881. if (classNames.some(className => element.classList.contains(className)))
  882. {
  883. element.style.height = "1.5em";
  884. element.style.background = "#ff69b4";
  885. if (["Clear", "Default", "Satellite", "solarNoon", "Earth", "Grid 0"].includes(element.id))
  886. {
  887. if (element.id == "Clear")
  888. {
  889. element.loaded = true;
  890. }
  891. element.style.background = "#ff1493";
  892. if (typeof element.dim !== typeof null)
  893. {
  894. if (element.dim == "2D" || element.dim == "3D")
  895. {
  896. element.style.background = "#ff69b4";
  897. }
  898. }
  899. }
  900. }
  901.  
  902. if (element.classList.contains("menu-btn"))
  903. {
  904. element.style.width = "3em";
  905. element.style.height = "2.5em";
  906. // element.style.borderStyle = "solid";
  907. // element.style.borderWidth = "0.1px"
  908. // element.style.borderColor = "black";
  909.  
  910. }
  911.  
  912. if (element.classList.contains("extra-height"))
  913. {
  914. element.style.height = "4.5em";
  915. }
  916.  
  917. if (element.classList.contains("extra-full"))
  918. {
  919. element.style.width = "22.75em";
  920. }
  921. else if (element.classList.contains("full"))
  922. {
  923. element.style.width = "15em";
  924. }
  925. else if (element.classList.contains("half"))
  926. {
  927. element.style.width = "7.25em";
  928. }
  929. else if (element.classList.contains("small"))
  930. {
  931. element.style.width = "2em";
  932. }
  933. else if (element.classList.contains("large"))
  934. {
  935. element.style.width = "10em";
  936. }
  937. btnPosFinal(element);
  938. }
  939. }
  940.  
  941. let dict = {
  942. 'Info Menu': ["url(https://www.svgrepo.com/show/299161/big-data.svg)", "#ff9999"],
  943. 'Teleport Menu': ["url(https://www.svgrepo.com/show/12767/car.svg)", "#ffcba4"],
  944. "Time Machine Button": ["url(https://www.svgrepo.com/show/38630/clock.svg)", "#D8BFD8"],
  945. 'Minimap Menu Button': ["url(https://www.svgrepo.com/show/116365/map.svg)", "#faf0be"],
  946. 'Mosaic Menu': ["url(https://www.svgrepo.com/show/77240/map.svg)", "#E6E6FA"],
  947. 'Satellite Menu': ["url(https://www.svgrepo.com/show/29288/satellite.svg)", "#e8f48c"],
  948. 'Space Menu Button': ["url(https://www.svgrepo.com/show/120980/saturn.svg)", "#e0ffff"]
  949. };
  950.  
  951. for (let element of document.getElementsByClassName("menu-btn"))
  952. {
  953. element.style.backgroundImage = dict[element.id][0];
  954. element.style.backgroundColor = dict[element.id][1];
  955. element.style.backgroundRepeat = "no-repeat";
  956. element.style.backgroundOrigin = "content-box";
  957. element.style.visibility = "";
  958. }
  959.  
  960. handleDropdown();
  961. }
  962.  
  963. /**
  964. * Creates Unity buttons
  965. *
  966. * @returns Promise
  967. */
  968.  
  969. function hideOtherBtn()
  970. {
  971. for (let element of document.getElementsByClassName("unity-btn")){
  972. if (element.id !== "Show Buttons")
  973. {
  974. element.style.visibility = "hidden";
  975. }
  976. if (nextPlayer == "Youtube" && element.id == "Youtube Button")
  977. {
  978. element.style.visibility = "";
  979. }
  980. if (nextPlayer == "Wikipedia" && element.id == "local language")
  981. {
  982. element.style.visibility = "";
  983. }
  984. }
  985. }
  986.  
  987. function switchBtn(arg)
  988. {
  989. for (let element of document.getElementsByClassName("unity-btn")){
  990. if (element.id !== "Show Buttons" && !element.classList.contains("menu-btn") && !element.classList.contains(arg))
  991. {
  992. element.style.visibility = "hidden";
  993. }
  994. if (nextPlayer == "Youtube" && element.id == "Youtube Button")
  995. {
  996. element.style.visibility = "";
  997. }
  998. if (nextPlayer == "Wikipedia" && element.id == "local language")
  999. {
  1000. element.style.visibility = "";
  1001. }
  1002. }
  1003. }
  1004.  
  1005.  
  1006.  
  1007. function UnityInitiate() {
  1008. const google = window.google;
  1009. let curPosition;
  1010. let kakao_enabled = true;
  1011.  
  1012. ZoomControls();
  1013.  
  1014. function svCheck(data, status) {
  1015. if (status === 'OK') {
  1016. // console.log("STATUS OK");
  1017. let l = data.location.latLng.toString().split(',');
  1018. let lat = l[0].replaceAll('(', '');
  1019. let lng = l[1].replaceAll(')', '');
  1020. if (lat == curPosition.lat && lng == curPosition.lng && !switch_call)
  1021. {
  1022. console.log("Trying more distance");
  1023. teleportMain.distance += 100;
  1024. teleportMain.innerHTML = "Teleport: " + teleportMain.distance + " m";
  1025. }
  1026. else
  1027. {
  1028. // console.log("Teleport Success");
  1029. GooglePlayer.setPosition(data.location.latLng);
  1030. GooglePlayer.setPov({
  1031. heading: switchCovergeButton.heading,
  1032. pitch: 0,
  1033. })
  1034. if (teleportMain.distance > 150)
  1035. {
  1036. teleportMain.distance = 100;
  1037. teleportMain.innerHTML = "Teleport: " + teleportMain.distance + " m";
  1038. }
  1039. }
  1040. switch_call = false;
  1041. }
  1042. else {
  1043. console.log("STATUS NOT OK");
  1044. teleportMain.distance += 100;
  1045. teleportMain.innerHTML = "Teleport: " + teleportMain.distance + " m";
  1046. }
  1047. }
  1048.  
  1049. google.maps.Map = class extends google.maps.Map {
  1050. constructor(...args) {
  1051. super(...args);
  1052. if (GeoJsonCustomUser)
  1053. {
  1054. if (GeoJsonCustomUser)
  1055. {
  1056. this.data.addGeoJson(CUSTOM_GEOJSON);
  1057. }
  1058. this.data.setStyle(function(feature) {
  1059. return GEOJSON_STYLE
  1060. });
  1061. }
  1062. if (OverlayCustom)
  1063. {
  1064. let customOverlay = new google.maps.GroundOverlay(OVERLAY_URL, OVERLAY_BOUNDS, OVERLAY_STYLE);
  1065. customOverlay.setMap(this);
  1066. }
  1067.  
  1068. for (let mapDiv of document.getElementsByClassName("preset-minimap")){
  1069. google.maps.event.addDomListener(mapDiv, "click", () => {
  1070.  
  1071. MinimapBtn.current = mapDiv.id;
  1072. if (mapDiv.id == "Hybrid")
  1073. {
  1074. this.setMapTypeId('hybrid');
  1075. }
  1076. else if (mapDiv.id == "Terrain")
  1077. {
  1078. this.setMapTypeId('terrain');
  1079. }
  1080. else if (mapDiv.id == "Satellite")
  1081. {
  1082. this.setMapTypeId('satellite');
  1083. }
  1084. else if (mapDiv.id == "Custom")
  1085. {
  1086. this.setMapTypeId(customMode);
  1087. }
  1088. else
  1089. {
  1090. this.setMapTypeId('roadmap');
  1091. }
  1092. // this.setTilt(45);
  1093. for (let ar of presetMinimap)
  1094. {
  1095. if (ar[1] == mapDiv.id)
  1096. {
  1097. this.set('styles', ar[0]);
  1098. }
  1099. }
  1100. for (let element of document.getElementsByClassName("preset-minimap")){
  1101. if (element.id == MinimapBtn.current)
  1102. {
  1103. element.style.background = "#ff1493";
  1104. }
  1105. else
  1106. {
  1107. element.style.background = "#ff69b4";
  1108. }
  1109. if (rtded || nextPlayer == "Planets") {
  1110. if (["Borders", "Satellite", "Terrain", "Hybrid", "Custom"].includes(element.id))
  1111. {
  1112. element.style.backgroundColor = "red";
  1113. element.disabled = true;
  1114. }
  1115. }
  1116. }
  1117. });
  1118. }
  1119.  
  1120. for (let mapDiv of document.getElementsByClassName("overlay-minimap")){
  1121. google.maps.event.addDomListener(mapDiv, "click", () => {
  1122. OverlayBtn.current = mapDiv.id;
  1123. // console.log(mapDiv.url)
  1124. // console.log(mapDiv.id)
  1125. // console.log(mapDiv.loaded)
  1126. if (!mapDiv.loaded)
  1127. {
  1128. this.data.loadGeoJson(mapDiv.url, {
  1129. id: mapDiv.id
  1130. });
  1131. mapDiv.loaded = true;
  1132. }
  1133. if (mapDiv.id == "Clear")
  1134. {
  1135. this.overlayMapTypes.clear();
  1136. this.data.setStyle(function(feature) {
  1137. return GEOJSON_INVISIBLE
  1138. });
  1139. for (let element of document.getElementsByClassName("overlay-minimap")){
  1140. if (element.id === "Clear")
  1141. {
  1142. element.style.background = "#ff1493";
  1143. }
  1144. else
  1145. {
  1146. element.style.background = "#ff69b4";
  1147. if (["Coverage", "Official", "OSM"].includes(element.id))
  1148. {
  1149. if (rtded || nextPlayer == "Planets")
  1150. {
  1151. element.style.background = "red";
  1152. }
  1153. }
  1154. if (["Coverage", "Official", "City Lights", "OSM", "Watercolor", "Toner", "Fire"].includes(element.id))
  1155. {
  1156. element.loaded = false;
  1157. }
  1158. }
  1159. }
  1160. }
  1161. else
  1162. {
  1163. if (["Coverage", "Official", "City Lights", "OSM", "Watercolor", "Toner", "Fire"].includes(mapDiv.id))
  1164. {
  1165. this.overlayMapTypes.clear();
  1166. const coverageLayer = new google.maps.ImageMapType({
  1167. getTileUrl ({ x, y }, z) {
  1168.  
  1169. // Omits photospheres
  1170. // return `https://mts1.googleapis.com/vt?hl=en-US&lyrs=svv|cb_client:apiv3&style=5,8&x=${x}&y=${y}&z=${z}`
  1171.  
  1172. // Omits unofficial and trekker, but also half of mongolia
  1173.  
  1174. if (mapDiv.id == "Official")
  1175. {
  1176. return `https://mts1.googleapis.com/vt?hl=en-US&lyrs=svv|cb_client:app&style=5,8&x=${x}&y=${y}&z=${z}`
  1177. }
  1178. else if (mapDiv.id == "OSM")
  1179. {
  1180. return `https://tile.openstreetmap.org/${z}/${x}/${y}.png`
  1181. }
  1182. else if (mapDiv.id == "City Lights")
  1183. {
  1184. return `https://map1.vis.earthdata.nasa.gov/wmts-webmerc/VIIRS_CityLights_2012/default/{time}/GoogleMapsCompatible_Level8/${z}/${y}/${x}.jpg`
  1185. }
  1186. else if (mapDiv.id == "Watercolor")
  1187. {
  1188. return `https://stamen-tiles.a.ssl.fastly.net/watercolor/${z}/${x}/${y}.jpg`
  1189. }
  1190. else if (mapDiv.id == "Toner")
  1191. {
  1192. return `https://stamen-tiles.a.ssl.fastly.net/toner/${z}/${x}/${y}.png`
  1193. }
  1194. else if (mapDiv.id == "Fire")
  1195. {
  1196. return `https://tile.thunderforest.com/spinal-map/${z}/${x}/${y}.png?apikey=1360c6d2440c4202bf725238d1b9c761`
  1197. }
  1198. // return `https://maps.googleapis.com/maps/vt?pb=!1m5!1m4!1i${z}!2i${x}!3i${y}!4i256!2m8!1e2!2ssvv!4m2!1scb_client!2sapp!4m2!1scc!2s*211m3*211e3*212b1*213e2*211m3*211e2*212b1*213e2!3m3!3sUS!12m1!1e68!4e0`
  1199.  
  1200. // Includes everything
  1201. else if (mapDiv.id == "Coverage")
  1202. {
  1203. return `https://maps.googleapis.com/maps/vt?pb=!1m5!1m4!1i${z}!2i${x}!3i${y}!4i256!2m8!1e2!2ssvv!4m2!1scb_client!2sapiv3!4m2!1scc!2s*211m3*211e3*212b1*213e2*211m3*211e2*212b1*213e2!3m3!3sUS!12m1!1e68!4e0`
  1204. }
  1205. },
  1206. maxZoom: 20,
  1207. tileSize: new google.maps.Size(256, 256),
  1208. })
  1209. this.overlayMapTypes.push(coverageLayer);
  1210.  
  1211. // let other = "Official";
  1212. // if (mapDiv.id == "Official")
  1213. // {
  1214. // other = "Coverage";
  1215. // }
  1216.  
  1217. for (let element of document.getElementsByClassName("overlay-minimap")){
  1218. if (["Clear", "City Lights", "Watercolor", "Toner", "Fire"].includes(element.id))
  1219. {
  1220. element.style.background = "#ff69b4";
  1221. element.loaded = false;
  1222. }
  1223. if (["Coverage", "Official", "OSM"].includes(element.id))
  1224. {
  1225. if (!rtded && nextPlayer !== "Planets")
  1226. {
  1227. element.style.background = "#ff69b4";
  1228. element.loaded = false;
  1229. }
  1230. }
  1231. }
  1232. mapDiv.style.background = "#ff1493";
  1233. mapDiv.loaded = true;
  1234. }
  1235. else
  1236. {
  1237. this.data.setStyle(function(feature) {
  1238. return GEOJSON_STYLE
  1239. });
  1240. for (let element of document.getElementsByClassName("overlay-minimap")){
  1241. if (element.id !== "Clear" && element.loaded)
  1242. {
  1243. element.style.background = "#ff1493";
  1244. }
  1245. else
  1246. {
  1247. element.style.background = "#ff69b4";
  1248. }
  1249. if (["Coverage", "Official", "OSM"].includes(element.id))
  1250. {
  1251. if (rtded || nextPlayer == "Planets")
  1252. {
  1253. element.style.background = "red";
  1254. }
  1255. }
  1256.  
  1257. }
  1258. }
  1259. }
  1260. });
  1261. }
  1262.  
  1263.  
  1264.  
  1265.  
  1266. for (let spMini of document.getElementsByClassName("spaceMM")) {
  1267. google.maps.event.addDomListener(spMini, "click", () => {
  1268. OverlayBtn.current = spMini.id;
  1269. setMapstylePlanet(planetType);
  1270. if (spMini.id == "Earth") {
  1271. this.overlayMapTypes.clear();
  1272. this.setMapTypeId('roadmap');
  1273. this.set('styles', default_preset);
  1274. // for (let element of document.getElementsByClassName("space-minimap")) {
  1275. // if (element.id === spMini.id) {
  1276. // element.style.background = "#ff1493";
  1277. // }
  1278. // else {
  1279. // element.style.background = "#ff69b4";
  1280. // }
  1281. // }
  1282. }
  1283. else
  1284. {
  1285. this.set('styles', blank);
  1286. setTimeout(this.set('styles', blank), 1000)
  1287. this.overlayMapTypes.clear();
  1288. const coverageLayer = new google.maps.ImageMapType({
  1289. getTileUrl({ x, y }, z) {
  1290. if (spMini.id.includes("Moon") || spMini.id.includes("Mars"))
  1291. {
  1292. if (spMini.id.includes("Label")) {
  1293. return spMini.url + z + "/" + x + "/" + y + ".png";
  1294. }
  1295. else
  1296. {
  1297. y = Math.pow(2, z) - y - 1;
  1298. return spMini.url + z + "/" + x + "/" + y + ".png";;
  1299. }
  1300. }
  1301. else
  1302. {
  1303. return handleSpURL(spMini.url, x, y, z);;
  1304. }
  1305. },
  1306. maxZoom: 20,
  1307. tileSize: new google.maps.Size(256, 256),
  1308. })
  1309.  
  1310. this.overlayMapTypes.push(coverageLayer);
  1311.  
  1312. if (spMini.id == ("Mars (Labels)"))
  1313. {
  1314. const coverageLayer2 = new google.maps.ImageMapType({
  1315. getTileUrl({ x, y }, z) {
  1316. y = Math.pow(2, z) - y - 1;
  1317. return `http://s3-eu-west-1.amazonaws.com/whereonmars.cartodb.net/celestia_mars-shaded-16k_global/${z}/${x}/${y}.png`;
  1318. },
  1319. maxZoom: 20,
  1320. tileSize: new google.maps.Size(256, 256),
  1321. opacity: 0.5
  1322. })
  1323. this.overlayMapTypes.push(coverageLayer2);
  1324. }
  1325. }
  1326. for (let element of document.getElementsByClassName("spaceMM")) {
  1327. if (element.id === spMini.id) {
  1328. element.style.background = "#ff1493";
  1329. }
  1330. else if (element.id.includes(planetType)) {
  1331. element.style.background = "#ff69b4";
  1332. }
  1333. }
  1334. });
  1335. }
  1336.  
  1337.  
  1338. }
  1339.  
  1340. }
  1341.  
  1342. const svService = new google.maps.StreetViewService();
  1343. google.maps.StreetViewPanorama = class extends google.maps.StreetViewPanorama {
  1344. constructor(...args) {
  1345. super(...args);
  1346. GooglePlayer = this;
  1347.  
  1348. const isGamePage = () => location.pathname.startsWith("/challenge/") || location.pathname.startsWith("/results/") ||
  1349. location.pathname.startsWith("/game/")|| location.pathname.startsWith("/battle-royale/") ||
  1350. location.pathname.startsWith("/duels/") || location.pathname.startsWith("/team-duels/") || location.pathname.startsWith("/bullseye/")
  1351. || location.pathname.startsWith("/live-challenge/");
  1352.  
  1353. this.addListener('position_changed', () => {
  1354. // Maybe this could be used to update the position in the other players
  1355. // so that they are always in sync
  1356. try {
  1357. if (!isGamePage()) return;
  1358. // timeMachineBtn.panoId = GooglePlayer.pano;
  1359. // timeMachineBtn.index = -1;
  1360. const lat = this.getPosition().lat();
  1361. const lng = this.getPosition().lng();
  1362. const { heading } = this.getPov();
  1363.  
  1364. curPosition = { lat, lng, heading };
  1365.  
  1366. if (switchCovergeButton.useGoogle)
  1367. {
  1368. switchCovergeButton.lng = lng;
  1369. switchCovergeButton.lat = lat;
  1370. switchCovergeButton.heading = heading;
  1371. if (!timeMachineBtn.list.some(row => row.includes(GooglePlayer.pano)))
  1372. {
  1373. timeMachineBtn.innerHTML = "Time Machine";
  1374. timeMachineBtn.panoId = GooglePlayer.pano;
  1375. timeMachineBtn.index = -1;
  1376. timeMachineBtn.plusminusLock = true;
  1377. timeMachineNewerBtn.style.backgroundColor = "red";
  1378. timeMachineNewerBtn.disabled = true;
  1379. timeMachineOlderBtn.style.backgroundColor = "red";
  1380. timeMachineOlderBtn.disabled = true;
  1381. }
  1382. }
  1383. switchCovergeButton.useGoogle = true;
  1384. teleportMain.google = true;
  1385.  
  1386.  
  1387. if (RestrictBoundsBtn.enabled)
  1388. {
  1389. let dist = distance(lat, lng , global_lat, global_lng);
  1390. if (dist > RestrictBoundsBtn.maxDist)
  1391. {
  1392. let prevD = distance(RestrictBoundsBtn.lat, RestrictBoundsBtn.lng, global_lat, global_lng);
  1393. if (prevD > RestrictBoundsBtn.maxDist)
  1394. {
  1395. svService.getPanorama({ location: { lat: global_lat, lng: global_lng }, radius: 1000 }, svCheck);
  1396. RestrictBoundsBtn.lng = global_lng;
  1397. RestrictBoundsBtn.lat = global_lat;
  1398. }
  1399. else
  1400. {
  1401. svService.getPanorama({ location: { lat: RestrictBoundsBtn.lat, lng: RestrictBoundsBtn.lng }, radius: 1000 }, svCheck);
  1402. }
  1403. }
  1404. else
  1405. {
  1406. RestrictBoundsBtn.lng = lng;
  1407. RestrictBoundsBtn.lat = lat;
  1408. }
  1409. let d = Math.round(distance(RestrictBoundsBtn.lat, RestrictBoundsBtn.lng , global_lat, global_lng));
  1410. let pct = Math.round((d / RestrictBoundsBtn.maxDist*100));
  1411. RestrictBoundsBtn.innerHTML = "<font size=2>Straight Line Distance: " + d + "m (" + pct + "%)</font>";
  1412. }
  1413. }
  1414. catch (e) {
  1415. console.error("Error:", e);
  1416. }
  1417. });
  1418. this.addListener('pov_changed', () => {
  1419. const { heading, pitch } = this.getPov();
  1420. if (KakaoPlayer) {
  1421. if (typeof KakaoPlayer !== 'string' )
  1422. {
  1423. const vp = KakaoPlayer.getViewpoint();
  1424. // Prevent a recursive loop: only update kakao's viewpoint if it got out of sync with google's
  1425. if ((!almostEqual(vp.pan, heading) || !almostEqual(vp.tilt, pitch)) && nextPlayer == "Kakao") {
  1426. KakaoPlayer.setViewpoint({ pan: heading, tilt: pitch, zoom: vp.zoom });
  1427. }
  1428. }
  1429. }
  1430. });
  1431. }
  1432. };
  1433.  
  1434. var mainMenuBtn = document.createElement("Button");
  1435. mainMenuBtn.classList.add("unity-btn", "main-btn");
  1436. mainMenuBtn.id = "Show Buttons";
  1437. mainMenuBtn.hide = true;
  1438. mainMenuBtn.menuBtnCache = true;
  1439. mainMenuBtn.innerHTML = "<font size=2>Unity<br><font size=1>v6.3.0</font>";
  1440. mainMenuBtn.style =
  1441. "border-radius: 10px;visibility:hidden;height:2.5em;position:absolute;z-index:99999;background-repeat:no-repeat;background-image:linear-gradient(180deg, #0066cc 50%, #ffcc00 50%);border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;line-height: 15px;";
  1442. // document.querySelector(".game-layout__status").appendChild(mainMenuBtn)
  1443. document.body.appendChild(mainMenuBtn);
  1444. mainMenuBtn.addEventListener("click", () => {
  1445. if (mainMenuBtn.hide) {
  1446. for (let element of document.getElementsByClassName("unity-btn")){
  1447. // if (!element.classList.contains("preset-minimap") && !element.classList.contains("overlay-minimap"))
  1448. // {
  1449. // element.style.visibility = "";
  1450. // if ((nextPlayer != "Youtube") && element.id == "Youtube Button")
  1451. // {
  1452. // element.style.visibility = "hidden";
  1453. // }
  1454. // }
  1455. if (element.classList.contains("menu-btn"))
  1456. {
  1457. element.style.visibility = "";
  1458. }
  1459. }
  1460. mainMenuBtn.menuBtnCache = true;
  1461. mainMenuBtn.hide = false;
  1462. }
  1463. else {
  1464. hideOtherBtn();
  1465. mainMenuBtn.menuBtnCache = false;
  1466. mainMenuBtn.hide = true;
  1467. }
  1468. });
  1469.  
  1470.  
  1471. var infoBtn = document.createElement("Button");
  1472. infoBtn.classList.add("unity-btn", "info-btn", "full", "vertical-1", "extra-height");
  1473. infoBtn.id = "Info Button";
  1474. infoBtn.innerHTML = "Geoguessr Unity Script<font size=1><br>&#169; Jupaoqq | v6.3.0</font>";
  1475. document.body.appendChild(infoBtn);
  1476. // infoBtn.addEventListener("click", () => {
  1477. // window.open('https://docs.google.com/document/d/18nLXSQQLOzl4WpUgZkM-mxhhQLY6P3FKonQGp-H0fqI/edit?usp=sharing');
  1478. // });
  1479.  
  1480. var HelpBtn = document.createElement("Button");
  1481. HelpBtn.classList.add("unity-btn", "info-btn", "half", "horizontal-1", "vertical-3");
  1482. HelpBtn.id = "Help Button";
  1483. HelpBtn.innerHTML = "Help & Credits";
  1484.  
  1485. document.body.appendChild(HelpBtn);
  1486. HelpBtn.addEventListener("click", () => {
  1487. window.open('https://docs.google.com/document/d/18nLXSQQLOzl4WpUgZkM-mxhhQLY6P3FKonQGp-H0fqI/edit?usp=sharing');
  1488. });
  1489.  
  1490. var UpdateBtn = document.createElement("Button");
  1491. UpdateBtn.classList.add("unity-btn", "info-btn", "half", "horizontal-2", "vertical-3");
  1492. UpdateBtn.id = "Update Button";
  1493. UpdateBtn.innerHTML = "Check Update";
  1494.  
  1495. document.body.appendChild(UpdateBtn);
  1496. UpdateBtn.addEventListener("click", () => {
  1497. window.open('https://greatest.deepsurf.us/en/scripts/436813-geoguessr-unity-script');
  1498. });
  1499.  
  1500. var menuResetBtn = document.createElement("Button");
  1501. menuResetBtn.classList.add("unity-btn", "info-btn", "large", "vertical-4");
  1502. menuResetBtn.id = "Menu Reset";
  1503. menuResetBtn.innerHTML = "Menu Position";
  1504. document.body.appendChild(menuResetBtn);
  1505. menuResetBtn.addEventListener("click", () => {
  1506. menuLocCounter = 0;
  1507. btnAll();
  1508. });
  1509.  
  1510. var menuUpBtn = document.createElement("Button");
  1511. menuUpBtn.classList.add("unity-btn", "info-btn", "small", "horizontal-1", "vertical-4");
  1512. menuUpBtn.id = "Menu Up";
  1513. menuUpBtn.innerHTML = "↑";
  1514. document.body.appendChild(menuUpBtn);
  1515. menuUpBtn.addEventListener("click", () => {
  1516. AdjustBtnPos("-2em", "0em", false);
  1517. menuLocCounter++;
  1518. });
  1519.  
  1520. var menuDownBtn = document.createElement("Button");
  1521. menuDownBtn.classList.add("unity-btn", "info-btn", "small", "horizontal-3", "vertical-4");
  1522. menuDownBtn.id = "Menu down";
  1523. menuDownBtn.innerHTML = "↓";
  1524. document.body.appendChild(menuDownBtn);
  1525. menuDownBtn.addEventListener("click", () => {
  1526. AdjustBtnPos("2em", "0em", false);
  1527. menuLocCounter--;
  1528. });
  1529.  
  1530. var infoMenu = document.createElement("Button");
  1531. infoMenu.classList.add("unity-btn", "menu-btn");
  1532. infoMenu.classList.add();
  1533. infoMenu.id = "Info Menu";
  1534. // infoMenu.innerHTML = "In";
  1535. document.body.appendChild(infoMenu);
  1536. infoMenu.addEventListener("click", () => {
  1537. switchBtn("info-btn");
  1538. if (menuDownBtn.style.visibility == "hidden")
  1539. {
  1540. for (let element of document.getElementsByClassName("info-btn"))
  1541. {
  1542. element.style.visibility = "";
  1543. }
  1544. }
  1545. else
  1546. {
  1547. for (let element of document.getElementsByClassName("info-btn"))
  1548. {
  1549. element.style.visibility = "hidden";
  1550. }
  1551. }
  1552. });
  1553.  
  1554. var playYoutubeBtn = document.createElement("Button");
  1555. playYoutubeBtn.classList.add("unity-btn", "full", "vertical-0");
  1556. playYoutubeBtn.id = "Youtube Button";
  1557. playYoutubeBtn.innerHTML = "Play video";
  1558. document.body.appendChild(playYoutubeBtn);
  1559. playYoutubeBtn.addEventListener("click", () => {
  1560. let iframe = document.getElementById("i_container");
  1561. iframe.style.position = "absolute";
  1562. iframe.allow = "autoplay";
  1563. let srcString = "https://www.youtube.com/embed/" + yId + "?&playlist=" + yId + "&autoplay=1&modestbranding=1&controls=0&start=";
  1564. if (yTime == "0" && yEnd == "0")
  1565. {
  1566. }
  1567. else
  1568. {
  1569. srcString += yTime + "&end=" + yEnd;
  1570. }
  1571. iframe.src = srcString;
  1572. iframe.style.visibility = "";
  1573. playYoutubeBtn.innerHTML = "Play video from start";
  1574. });
  1575.  
  1576. // Teleport Module Buttons
  1577. // Class: teleport-btn
  1578. // Button: teleportMenu
  1579. // Buttons: teleportForward, teleportReverse, teleportMain, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, TeleportArisBtn
  1580.  
  1581. function teleportModule(dir)
  1582. {
  1583. if (switchCovergeButton.init)
  1584. {
  1585. // console.log("run");
  1586. switchCovergeButton.init = false;
  1587. if (teleportMain.google)
  1588. {
  1589. switchCovergeButton.useGoogle = true;
  1590. teleportMain.google = true;
  1591. }
  1592. else
  1593. {
  1594. switchCovergeButton.useGoogle = false;
  1595. teleportMain.google = false;
  1596. }
  1597. }
  1598. else
  1599. {
  1600. // console.log(teleportMenu.google)
  1601. if (teleportMain.google && GooglePlayer != null)
  1602. {
  1603. let heading = GooglePlayer.getPov().heading;
  1604. if (!dir)
  1605. {
  1606. heading = (heading + 180) % 360;
  1607. }
  1608. let place = FindPointAtDistanceFrom(curPosition.lat, curPosition.lng , DegreesToRadians(heading), teleportMain.distance * 0.001)
  1609. svService.getPanorama({ location: place, radius: 1000, source: teleportMain.teleType}, svCheck);
  1610. }
  1611. }
  1612. }
  1613.  
  1614. var teleportForward = document.createElement("Button");
  1615. teleportForward.classList.add("unity-btn", "teleport-btn", "half", "horizontal-1", "vertical-1");
  1616. teleportForward.id = "Teleport Forward";
  1617. teleportForward.innerHTML = "↑ Forward";
  1618. document.body.appendChild(teleportForward);
  1619.  
  1620. teleportForward.addEventListener("click", () => {
  1621. teleportModule(true);
  1622. });
  1623.  
  1624. var teleportReverse = document.createElement("Button");
  1625. teleportReverse.classList.add("unity-btn", "teleport-btn", "half", "horizontal-2", "vertical-1");
  1626. teleportReverse.id = "Teleport Reverse";
  1627. teleportReverse.innerHTML = "↓ Reverse";
  1628. document.body.appendChild(teleportReverse);
  1629.  
  1630. teleportReverse.addEventListener("click", () => {
  1631. teleportModule(false);
  1632. });
  1633.  
  1634. var teleportMain = document.createElement("Button");
  1635. teleportMain.classList.add("unity-btn", "teleport-btn", "large", "vertical-2");
  1636. teleportMain.teleType = "default";
  1637. teleportMain.id = "Teleport Button";
  1638. teleportMain.distance = 100;
  1639. teleportMain.google = true;
  1640. teleportMain.innerHTML = "Teleport: 100m";
  1641. document.body.appendChild(teleportMain);
  1642.  
  1643. var teleportMoreBtn = document.createElement("Button");
  1644. teleportMoreBtn.classList.add("unity-btn", "teleport-btn", "small", "horizontal-3", "vertical-2");
  1645. teleportMoreBtn.id = "plus"
  1646. teleportMoreBtn.innerHTML = "+";
  1647. document.body.appendChild(teleportMoreBtn);
  1648. teleportMoreBtn.addEventListener("click", () => {
  1649. if (teleportMain.distance > 21 && teleportMain.distance < 149) {
  1650. teleportMain.distance = teleportMain.distance + 25;
  1651. }
  1652. teleportMain.innerHTML = "Teleport: " + teleportMain.distance + " m";
  1653. });
  1654.  
  1655. var teleportLessBtn = document.createElement("Button");
  1656. teleportLessBtn.classList.add("unity-btn", "teleport-btn", "small", "horizontal-1", "vertical-2");
  1657. teleportLessBtn.id = "minus"
  1658. teleportLessBtn.innerHTML = "-";
  1659. document.body.appendChild(teleportLessBtn);
  1660. teleportLessBtn.addEventListener("click", () => {
  1661. if (teleportMain.distance > 26) {
  1662. teleportMain.distance = teleportMain.distance - 25;
  1663. }
  1664. teleportMain.innerHTML = "Teleport: " + teleportMain.distance + " m";
  1665. });
  1666.  
  1667. var teleportDistResetBtn = document.createElement("Button");
  1668. teleportDistResetBtn.classList.add("unity-btn", "teleport-btn", "half", "horizontal-1", "vertical-3");
  1669. teleportDistResetBtn.id = "reset"
  1670. teleportDistResetBtn.innerHTML = "Reset Teleport";
  1671. document.body.appendChild(teleportDistResetBtn);
  1672. teleportDistResetBtn.addEventListener("click", () => {
  1673. teleportMain.distance = 100;
  1674. teleportMain.innerHTML = "Teleport: " + teleportMain.distance + " m";
  1675. });
  1676.  
  1677. var TeleportArisBtn = document.createElement("Button");
  1678. TeleportArisBtn.classList.add("unity-btn", "teleport-btn", "half", "horizontal-2", "vertical-3");
  1679. TeleportArisBtn.id = "Teleport Options Button";
  1680. TeleportArisBtn.innerHTML = "+ Unofficial";
  1681. document.body.appendChild(TeleportArisBtn);
  1682. TeleportArisBtn.addEventListener("click", () => {
  1683. if (teleportMain.teleType == "default")
  1684. {
  1685. teleportMain.teleType = "outdoor"
  1686. TeleportArisBtn.innerHTML = "No Unofficial";
  1687. }
  1688. else
  1689. {
  1690. teleportMain.teleType = "default"
  1691. TeleportArisBtn.innerHTML = "+ Unofficial";
  1692. }
  1693. });
  1694.  
  1695.  
  1696. var RestrictBoundsBtn = document.createElement("Button");
  1697. RestrictBoundsBtn.classList.add("unity-btn", "teleport-btn", "full", "horizontal-1", "vertical-4");
  1698. RestrictBoundsBtn.id = "Restrict Bounds Main";
  1699. RestrictBoundsBtn.innerHTML = "No Escape Mode Disabled";
  1700. RestrictBoundsBtn.enabled = false;
  1701. RestrictBoundsBtn.lat = 0;
  1702. RestrictBoundsBtn.lng = 0;
  1703. RestrictBoundsBtn.maxDist = 250;
  1704. document.body.appendChild(RestrictBoundsBtn);
  1705.  
  1706.  
  1707. var RestrictBoundsDistBtn = document.createElement("Button");
  1708. RestrictBoundsDistBtn.classList.add("unity-btn", "teleport-btn", "large", "vertical-5");
  1709. RestrictBoundsDistBtn.id = "Restrict Distance";
  1710. RestrictBoundsDistBtn.innerHTML = "Limit: 250m";
  1711. document.body.appendChild(RestrictBoundsDistBtn);
  1712.  
  1713. var RestrictMoreBtn = document.createElement("Button");
  1714. RestrictMoreBtn.classList.add("unity-btn", "teleport-btn", "small", "horizontal-3", "vertical-5");
  1715. RestrictMoreBtn.id = "Increase Restrict Distance";
  1716. RestrictMoreBtn.innerHTML = "+";
  1717. document.body.appendChild(RestrictMoreBtn);
  1718. RestrictMoreBtn.addEventListener("click", () => {
  1719. if (RestrictBoundsBtn.maxDist > 49 && RestrictBoundsBtn.maxDist < 249) {
  1720. RestrictBoundsBtn.maxDist = RestrictBoundsBtn.maxDist + 50;
  1721. }
  1722. else if (RestrictBoundsBtn.maxDist > 249 && RestrictBoundsBtn.maxDist < 999) {
  1723. RestrictBoundsBtn.maxDist = RestrictBoundsBtn.maxDist + 250;
  1724. }
  1725. else if (RestrictBoundsBtn.maxDist > 999 && RestrictBoundsBtn.maxDist < 9999) {
  1726. RestrictBoundsBtn.maxDist = RestrictBoundsBtn.maxDist + 1000;
  1727. }
  1728. else if (RestrictBoundsBtn.maxDist > 9999) {
  1729. RestrictBoundsBtn.maxDist = 100000000;
  1730. }
  1731. if (RestrictBoundsBtn.maxDist < 10001)
  1732. {
  1733. RestrictBoundsDistBtn.innerHTML = "Limit: " + RestrictBoundsBtn.maxDist + "m";
  1734. }
  1735. else
  1736. {
  1737. RestrictBoundsDistBtn.innerHTML = "Limit: &#8734;";
  1738. }
  1739. });
  1740.  
  1741. var RestrictLessBtn = document.createElement("Button");
  1742. RestrictLessBtn.classList.add("unity-btn", "teleport-btn", "small", "horizontal-1", "vertical-5");
  1743. RestrictLessBtn.id = "Decrease Restrict Distance";
  1744. RestrictLessBtn.innerHTML = "-";
  1745. document.body.appendChild(RestrictLessBtn);
  1746. RestrictLessBtn.addEventListener("click", () => {
  1747. if (RestrictBoundsBtn.maxDist > 51 && RestrictBoundsBtn.maxDist < 251) {
  1748. RestrictBoundsBtn.maxDist = RestrictBoundsBtn.maxDist - 50;
  1749. }
  1750. else if (RestrictBoundsBtn.maxDist > 251 && RestrictBoundsBtn.maxDist < 1001) {
  1751. RestrictBoundsBtn.maxDist = RestrictBoundsBtn.maxDist - 250;
  1752. }
  1753. else if (RestrictBoundsBtn.maxDist > 1001 && RestrictBoundsBtn.maxDist < 10001) {
  1754. RestrictBoundsBtn.maxDist = RestrictBoundsBtn.maxDist - 1000;
  1755. }
  1756. else if (RestrictBoundsBtn.maxDist > 10001) {
  1757. RestrictBoundsBtn.maxDist = 10000;
  1758. }
  1759. if (RestrictBoundsBtn.maxDist < 10001)
  1760. {
  1761. RestrictBoundsDistBtn.innerHTML = "Limit: " + RestrictBoundsBtn.maxDist + "m";
  1762. }
  1763. else
  1764. {
  1765. RestrictBoundsDistBtn.innerHTML = "Limit: &#8734;";
  1766. }
  1767. });
  1768.  
  1769. var RestrictBoundsEnableBtn = document.createElement("Button");
  1770. RestrictBoundsEnableBtn.classList.add("unity-btn", "teleport-btn", "half", "horizontal-2", "vertical-6");
  1771. RestrictBoundsEnableBtn.id = "Restrict Bounds Enable";
  1772. RestrictBoundsEnableBtn.innerHTML = "Enable Limit";
  1773. document.body.appendChild(RestrictBoundsEnableBtn);
  1774. RestrictBoundsEnableBtn.addEventListener("click", () => {
  1775. if (RestrictBoundsBtn.enabled)
  1776. {
  1777. RestrictBoundsBtn.enabled = false;
  1778. RestrictBoundsEnableBtn.innerHTML = "Enable Limit";
  1779. RestrictBoundsBtn.innerHTML = "No Escape Mode Disabled";
  1780. }
  1781. else
  1782. {
  1783. RestrictBoundsBtn.enabled = true;
  1784. RestrictBoundsEnableBtn.innerHTML = "Disable Limit";
  1785. RestrictBoundsBtn.innerHTML = "No Escape Mode Enabled";
  1786. }
  1787. });
  1788.  
  1789. var RestrictResetBtn = document.createElement("Button");
  1790. RestrictResetBtn.classList.add("unity-btn", "teleport-btn", "half", "horizontal-1", "vertical-6");
  1791. RestrictResetBtn.id = "Restrict Distance Reset";
  1792. RestrictResetBtn.innerHTML = "Reset Limit";
  1793. document.body.appendChild(RestrictResetBtn);
  1794. RestrictResetBtn.addEventListener("click", () => {
  1795. RestrictBoundsBtn.maxDist = 250;
  1796. RestrictBoundsDistBtn.innerHTML = "Limit: " + RestrictBoundsBtn.maxDist + "m";
  1797. });
  1798.  
  1799.  
  1800.  
  1801. // Switch Coverage Module
  1802.  
  1803. var switchCovergeButton = document.createElement("Button");
  1804. switchCovergeButton.classList.add("unity-btn", "timemachine-btn", "full", "vertical-1");
  1805. switchCovergeButton.sat = false;
  1806. switchCovergeButton.id = "switch";
  1807. switchCovergeButton.init = false;
  1808. switchCovergeButton.useGoogle = false;
  1809. switchCovergeButton.lng = 0
  1810. switchCovergeButton.lat = 0
  1811. switchCovergeButton.heading = 0
  1812. switchCovergeButton.innerHTML = "Switch to Google Streetview";
  1813. document.body.appendChild(switchCovergeButton);
  1814. switchCovergeButton.addEventListener("click", () => {
  1815. nextPlayer = nextPlayer_save;
  1816. let GOOGLE_MAPS_CANVAS1 = document.querySelector(GENERAL_CANVAS);
  1817. let GOOGLE_MAPS_CANVAS2 = document.querySelector(BR_CANVAS);
  1818. let GOOGLE_MAPS_CANVAS3 = document.querySelector(".inactive");
  1819. let GOOGLE_MAPS_CANVAS4 = document.querySelector(BULLSEYE_CANVAS2);
  1820. let GOOGLE_MAPS_CANVAS5 = document.querySelector(LIVE_CANVAS2);
  1821. let duel = false;
  1822.  
  1823. let GOOGLE_MAPS_CANVAS = null;
  1824. if (GOOGLE_MAPS_CANVAS1 !== null)
  1825. {
  1826. GOOGLE_MAPS_CANVAS = GOOGLE_MAPS_CANVAS1;
  1827. }
  1828. else if (GOOGLE_MAPS_CANVAS2 !== null)
  1829. {
  1830. GOOGLE_MAPS_CANVAS = GOOGLE_MAPS_CANVAS2;
  1831. }
  1832. else if (GOOGLE_MAPS_CANVAS4 !== null)
  1833. {
  1834. GOOGLE_MAPS_CANVAS = GOOGLE_MAPS_CANVAS4;
  1835. }
  1836. else if (GOOGLE_MAPS_CANVAS5 !== null)
  1837. {
  1838. GOOGLE_MAPS_CANVAS = GOOGLE_MAPS_CANVAS5;
  1839. }
  1840. if (GOOGLE_MAPS_CANVAS3 !== null)
  1841. {
  1842. duel = true;
  1843. }
  1844.  
  1845. let KAKAO_MAPS_CANVAS = document.getElementById("roadview");
  1846. let YANDEX_MAPS_CANVAS = document.querySelector(".ymaps-2-1-79-panorama-screen");
  1847. let MAPILLARY_MAPS_CANVAS = document.getElementById("mapillary-player")
  1848. let BAIDU_MAPS_CANVAS = document.getElementById("i_container");
  1849. let MS_MAPS_CANVAS = document.getElementById("ms-player");
  1850. let MAPBOX_MAPS_CANVAS = document.getElementById("sat_map");
  1851. // if (nextPlayer !== "Baidu") {
  1852. if (switchCovergeButton.useGoogle == false) {
  1853. if (duel)
  1854. {
  1855. document.getElementById("default_player").className = "game-panorama_panoramaCanvas__PNKve";
  1856. if (nextPlayer == "Kakao")
  1857. {
  1858. KAKAO_MAPS_CANVAS.className = "inactive";
  1859. }
  1860. else if (nextPlayer == "Bing Streetside")
  1861. {
  1862. MS_MAPS_CANVAS.className = "inactive";
  1863. }
  1864. else if (nextPlayer == "Mapbox Satellite")
  1865. {
  1866. MAPBOX_MAPS_CANVAS.className = "inactive";
  1867. }
  1868. else if (nextPlayer == "Yandex")
  1869. {
  1870. YANDEX_MAPS_CANVAS.style.visibility = "hidden";
  1871. YANDEX_MAPS_CANVAS.style.zIndex = "none";
  1872. }
  1873. else
  1874. {
  1875. MAPILLARY_MAPS_CANVAS.className = "inactive";
  1876. MAPILLARY_MAPS_CANVAS.style.visibility = "hidden";
  1877. }
  1878. }
  1879. else
  1880. {
  1881. GOOGLE_MAPS_CANVAS.style.visibility = "";
  1882. if (nextPlayer == "Kakao")
  1883. {
  1884. KAKAO_MAPS_CANVAS.style.visibility = "hidden";
  1885. }
  1886. else if (nextPlayer == "Yandex")
  1887. {
  1888. YANDEX_MAPS_CANVAS.style.visibility = "hidden";
  1889. }
  1890. else if (nextPlayer == "Baidu" || nextPlayer == "Youtube" || nextPlayer == "Image" || nextPlayer === "Wikipedia" || nextPlayer === "Minecraft")
  1891. {
  1892. BAIDU_MAPS_CANVAS.style.visibility = "hidden";
  1893. }
  1894. else if (nextPlayer == "Mapillary" || nextPlayer == "Google")
  1895. {
  1896. MAPILLARY_MAPS_CANVAS.style.visibility = "hidden";
  1897. }
  1898. else if (nextPlayer == "Bing Streetside" || nextPlayer == "Planets")
  1899. {
  1900. MS_MAPS_CANVAS.style.visibility = "hidden";
  1901. }
  1902. else if (nextPlayer == "Mapbox Satellite")
  1903. {
  1904. MAPBOX_MAPS_CANVAS.style.visibility = "hidden";
  1905. }
  1906.  
  1907.  
  1908. }
  1909. const lat = GooglePlayer.getPosition().lat();
  1910. const lng = GooglePlayer.getPosition().lng();
  1911. switch_call = true;
  1912. if (!almostEqual2(lat, switchCovergeButton.lat) || !almostEqual2(lat, switchCovergeButton.lng)) {
  1913. svService.getPanorama({ location: { lat: switchCovergeButton.lat, lng: switchCovergeButton.lng }, radius: 1000 }, svCheck);
  1914. }
  1915. switchCovergeButton.useGoogle = true;
  1916. teleportMain.google = true;
  1917. switchCovergeButton.init = false;
  1918.  
  1919. console.log("use Google");
  1920. }
  1921. else {
  1922. if (MS_MAPS_CANVAS)
  1923. {
  1924. MS_MAPS_CANVAS.style.visibility = "hidden";
  1925. }
  1926.  
  1927. if (duel)
  1928. {
  1929. document.getElementById("default_player").className = "inactive";
  1930. if (nextPlayer == "Kakao")
  1931. {
  1932. KAKAO_MAPS_CANVAS.className = "game-panorama_panoramaCanvas__PNKve";
  1933. }
  1934. else if (nextPlayer == "Bing Streetside" || nextPlayer == "Planets")
  1935. {
  1936. MS_MAPS_CANVAS.className = "game-panorama_panoramaCanvas__PNKve";
  1937. }
  1938. else if (nextPlayer == "Mapbox Satellite")
  1939. {
  1940. MAPBOX_MAPS_CANVAS.className = "game-panorama_panoramaCanvas__PNKve";
  1941. }
  1942. else if (nextPlayer == "Yandex")
  1943. {
  1944. YANDEX_MAPS_CANVAS.style.visibility = "";
  1945. YANDEX_MAPS_CANVAS.style.zIndex = "1";
  1946. }
  1947. else
  1948. {
  1949. MAPILLARY_MAPS_CANVAS.className = "game-panorama_panoramaCanvas__PNKve";
  1950. MAPILLARY_MAPS_CANVAS.style.visibility = "";
  1951. MapillaryPlayer.resize();
  1952. //window.dispatchEvent(new Event('resize'));
  1953. // document.querySelector(".mapillary-canvas").style.;
  1954. // mapillary-canvas
  1955. }
  1956.  
  1957. }
  1958. else
  1959. {
  1960. GOOGLE_MAPS_CANVAS.style.visibility = "hidden";
  1961. if (nextPlayer == "Kakao")
  1962. {
  1963. KAKAO_MAPS_CANVAS.style.visibility = "";
  1964. }
  1965. else if (nextPlayer == "Yandex")
  1966. {
  1967. YANDEX_MAPS_CANVAS.style.visibility = "";
  1968. }
  1969. else if (nextPlayer == "Baidu" || nextPlayer == "Youtube" || nextPlayer == "Image" || nextPlayer === "Wikipedia" || nextPlayer === "Minecraft")
  1970. {
  1971. BAIDU_MAPS_CANVAS.style.visibility = "";
  1972. }
  1973. else if (nextPlayer == "Mapillary" || nextPlayer == "Google" )
  1974. {
  1975. MAPILLARY_MAPS_CANVAS.style.visibility = "";
  1976. }
  1977. else if (nextPlayer == "Bing Streetside" || nextPlayer == "Planets")
  1978. {
  1979. MS_MAPS_CANVAS.style.visibility = "";
  1980. }
  1981. else if (nextPlayer == "Mapbox Satellite")
  1982. {
  1983. MAPBOX_MAPS_CANVAS.style.visibility = "";
  1984. }
  1985. }
  1986. switchCovergeButton.useGoogle = false;
  1987. teleportMain.google = false;
  1988. switchCovergeButton.init = true;
  1989. console.log("use Others");
  1990. }
  1991. if (switchCovergeButton.useGoogle)
  1992. {
  1993. if (nextPlayer == "Google")
  1994. {
  1995. switchCovergeButton.innerHTML = "Switch to Mapillary";
  1996. satelliteSwitchButton.disabled = false;
  1997. satelliteSwitchButton.style.background = "#ba55d3";
  1998. }
  1999. else
  2000. {
  2001. switchCovergeButton.innerHTML = "Switch to " + nextPlayer;
  2002. satelliteSwitchButton.disabled = true;
  2003. satelliteSwitchButton.style.background = "red";
  2004. }
  2005. }
  2006. else
  2007. {
  2008. if (nextPlayer == "Google" || nextPlayer == "Baidu")
  2009. {
  2010. switchCovergeButton.innerHTML = "Switch to Google Streetview";
  2011. satelliteSwitchButton.disabled = true;
  2012. satelliteSwitchButton.style.background = "red";
  2013. }
  2014. else
  2015. {
  2016. switchCovergeButton.innerHTML = "Switch to Google Streetview";
  2017. satelliteSwitchButton.disabled = false;
  2018. satelliteSwitchButton.style.background = "#ba55d3";
  2019. }
  2020. }
  2021. });
  2022.  
  2023.  
  2024. var timeMachineNewerBtn = document.createElement("Button");
  2025. timeMachineNewerBtn.classList.add("unity-btn", "timemachine-btn", "small", "horizontal-3", "vertical-2");
  2026. timeMachineNewerBtn.id = "plus year"
  2027. timeMachineNewerBtn.innerHTML = "+";
  2028. document.body.appendChild(timeMachineNewerBtn);
  2029. timeMachineNewerBtn.addEventListener("click", () => {
  2030. if (timeMachineBtn.index < timeMachineBtn.list.length - 1 && !timeMachineBtn.plusminusLock) {
  2031. timeMachineBtn.index = timeMachineBtn.index + 1;
  2032. GooglePlayer.setPano(timeMachineBtn.list[timeMachineBtn.index][0]);
  2033. timeMachineBtn.innerHTML = "<font size=2>[" + (timeMachineBtn.index + 1) + "] " + timeMachineBtn.list[timeMachineBtn.index][1] + "</font>";
  2034. // console.log(timeMachineBtn.index)
  2035. }
  2036. GenBtnColor();
  2037.  
  2038. });
  2039.  
  2040. var timeMachineOlderBtn = document.createElement("Button");
  2041. timeMachineOlderBtn.classList.add("unity-btn", "timemachine-btn", "small", "horizontal-1", "vertical-2");
  2042. timeMachineOlderBtn.id = "minus year"
  2043. timeMachineOlderBtn.innerHTML = "-";
  2044. document.body.appendChild(timeMachineOlderBtn);
  2045. timeMachineOlderBtn.addEventListener("click", () => {
  2046. if (timeMachineBtn.index > 0 && !timeMachineBtn.plusminusLock) {
  2047. timeMachineBtn.index = timeMachineBtn.index - 1;
  2048. GooglePlayer.setPano(timeMachineBtn.list[timeMachineBtn.index][0]);
  2049. timeMachineBtn.innerHTML = "<font size=2>[" + (timeMachineBtn.index + 1) + "] " + timeMachineBtn.list[timeMachineBtn.index][1] + "</font>";
  2050. // console.log(timeMachineBtn.index)
  2051. }
  2052. GenBtnColor();
  2053. });
  2054.  
  2055. function svCheck2(data, status) {
  2056. let l = []
  2057. if (status === 'OK') {
  2058. // console.log("OK for " + data.location.latLng + " at ID " + data.location.pano);
  2059. // console.log(data.time)
  2060. for (const alt of data.time) {
  2061. let date = Object.values(alt).find((value) => value instanceof Date)
  2062.  
  2063. l.push([alt.pano, date.toDateString()]);
  2064. }
  2065. // console.log(l);
  2066. timeMachineBtn.list = l
  2067. timeMachineBtn.index = l.length - 1;
  2068. timeMachineBtn.innerHTML = "<font size=2>[" + (timeMachineBtn.index + 1) + "] " + timeMachineBtn.list[timeMachineBtn.index][1] + "</font>";
  2069. GenBtnColor();
  2070. timeMachineBtn.plusminusLock = false;
  2071. // timeMachineOlderBtn.click()
  2072. // timeMachineBtn.innerHTML = "Default Date";
  2073. }
  2074. }
  2075.  
  2076. function waitPopulate()
  2077. {
  2078. // console.log(timeMachineBtn.list);
  2079. if (timeMachineBtn.list.length !== 0)
  2080. {
  2081. timeMachineBtn.index = timeMachineBtn.list.length - 1;
  2082. GooglePlayer.setPano(timeMachineBtn.list[timeMachineBtn.index][0]);
  2083. }
  2084. else
  2085. {
  2086. setTimeout(waitPopulate, 250);
  2087. }
  2088. }
  2089.  
  2090. var timeMachineBtn = document.createElement("Button");
  2091. timeMachineBtn.classList.add("unity-btn", "timemachine-btn", "large", "vertical-2");
  2092. timeMachineBtn.id = "Date Button";
  2093. timeMachineBtn.plusminusLock = true;
  2094. timeMachineBtn.panoId = 0;
  2095. timeMachineBtn.index = -1;
  2096. timeMachineBtn.list = [];
  2097. timeMachineBtn.innerHTML = "Time Machine";
  2098. document.body.appendChild(timeMachineBtn);
  2099. timeMachineBtn.addEventListener("click", () => {
  2100. // console.log(timeMachineBtn.index)
  2101. if (timeMachineBtn.panoId != 0)
  2102. {
  2103. if(timeMachineBtn.index == -1)
  2104. {
  2105. timeMachineBtn.list = [];
  2106. svService.getPanorama({pano: timeMachineBtn.panoId}, svCheck2);
  2107. waitPopulate();
  2108. }
  2109. else
  2110. {
  2111. waitPopulate();
  2112. timeMachineBtn.innerHTML = "<font size=2>[" + (timeMachineBtn.index + 1) + "] " + timeMachineBtn.list[timeMachineBtn.index][1] + "</font>";
  2113. GenBtnColor();
  2114. }
  2115. }
  2116. else
  2117. {
  2118. timeMachineBtn.panoId = GooglePlayer.pano;
  2119. svService.getPanorama({pano: timeMachineBtn.panoId}, svCheck2);
  2120. waitPopulate();
  2121. }
  2122. });
  2123.  
  2124.  
  2125. var timeMachineMenu = document.createElement("Button");
  2126. timeMachineMenu.classList.add("unity-btn", "menu-btn");
  2127. timeMachineMenu.id = "Time Machine Button";
  2128. document.body.appendChild(timeMachineMenu);
  2129. timeMachineMenu.addEventListener("click", () => {
  2130. switchBtn("timemachine-btn");
  2131. if (timeMachineBtn.style.visibility == "hidden")
  2132. {
  2133. for (let element of document.getElementsByClassName("timemachine-btn"))
  2134. {
  2135. element.style.visibility = "";
  2136. }
  2137. }
  2138. else
  2139. {
  2140. for (let element of document.getElementsByClassName("timemachine-btn"))
  2141. {
  2142. element.style.visibility = "hidden";
  2143. }
  2144. }
  2145. });
  2146.  
  2147.  
  2148. var teleportMenu = document.createElement("Button");
  2149. teleportMenu.classList.add("unity-btn", "menu-btn");
  2150. teleportMenu.id = "Teleport Menu";
  2151. document.body.appendChild(teleportMenu);
  2152. teleportMenu.addEventListener("click", () => {
  2153. switchBtn("teleport-btn");
  2154. if (teleportForward.style.visibility == "hidden")
  2155. {
  2156. for (let element of document.getElementsByClassName("teleport-btn"))
  2157. {
  2158. element.style.visibility = "";
  2159. }
  2160. }
  2161. else
  2162. {
  2163. for (let element of document.getElementsByClassName("teleport-btn"))
  2164. {
  2165. element.style.visibility = "hidden";
  2166. }
  2167. }
  2168. });
  2169.  
  2170. // Satellite Module Buttons
  2171. // Class: satelliteSwitchButton, satellite-menu
  2172. // subclass 1: satellite-btn-type
  2173. // subclass 2: satellite-btn-style
  2174. // Buttons: satelliteRadius, satelliteType, satelliteStyle
  2175. // satelliteDefault, satelliteNight, satelliteClassic, roadDefault, roadClassic
  2176. // skyDefault, skyCurrent, skyLocal
  2177.  
  2178. var satelliteTypeBtn = document.createElement("Button");
  2179. satelliteTypeBtn.classList.add("unity-btn", "satellite-btn", "half", "horizontal-1", "vertical-2");
  2180. satelliteTypeBtn.id = "Satellite Type Button";
  2181. satelliteTypeBtn.innerHTML = "Map Style";
  2182. satelliteTypeBtn.currentId = "Satellite"
  2183. satelliteTypeBtn.currentDim = "2.5D"
  2184. document.body.appendChild(satelliteTypeBtn);
  2185.  
  2186.  
  2187. var satelliteStyleBtn = document.createElement("Button");
  2188. satelliteStyleBtn.classList.add("unity-btn", "satellite-btn", "half", "horizontal-2", "vertical-2");
  2189. satelliteStyleBtn.id = "Satellite Style Button";
  2190. satelliteStyleBtn.innerHTML = "Time";
  2191. satelliteStyleBtn.current = "solarNoon";
  2192. document.body.appendChild(satelliteStyleBtn);
  2193.  
  2194. for (let satT of satType)
  2195. {
  2196. let satTButton = document.createElement("Button");
  2197. satTButton.id = satT[0];
  2198. satTButton.dim = satT[1];
  2199. satTButton.classList.add("unity-btn", "satellite-btn", "satellite-type", "half", "horizontal-1");
  2200. satTButton.innerHTML = satTButton.id + " " + satTButton.dim;
  2201. // if (satTButton.dim == "2.5D")
  2202. // {
  2203. // satTButton.title = "Hide House";
  2204. // }
  2205. satTButton.addEventListener("click", () => {
  2206. let changeSatStyle = styleMapboxAll(satelliteTypeBtn.currentId, satelliteTypeBtn.currentDim, satelliteStyleBtn.current, satTButton.id, satTButton.dim, satelliteStyleBtn.current, true);
  2207. satelliteTypeBtn.currentId = satTButton.id;
  2208. satelliteTypeBtn.currentDim = satTButton.dim;
  2209. if (changeSatStyle)
  2210. {
  2211. satelliteStyleBtn.current = "solarNoon";
  2212. }
  2213. handleSatColor();
  2214. })
  2215. document.body.appendChild(satTButton);
  2216. }
  2217.  
  2218. for (let satS of satStyle)
  2219. {
  2220. let satSButton = document.createElement("Button");
  2221. satSButton.id = satS[0];
  2222. satSButton.classList.add("unity-btn", "satellite-btn", "satellite-style", "half", "horizontal-2");
  2223. satSButton.innerHTML = satS[1];
  2224. satSButton.addEventListener("click", () => {
  2225. let changeSatStyle = styleMapboxAll(satelliteTypeBtn.currentId, satelliteTypeBtn.currentDim, satelliteStyleBtn.current, satelliteTypeBtn.currentId, satelliteTypeBtn.currentDim, satSButton.id, false);
  2226. satelliteStyleBtn.current = satSButton.id;
  2227. handleSatColor();
  2228. })
  2229.  
  2230. document.body.appendChild(satSButton);
  2231. }
  2232.  
  2233. function handleSatColor()
  2234. {
  2235. for (let element of document.getElementsByClassName("satellite-type")){
  2236. if (element.id == satelliteTypeBtn.currentId && element.dim == satelliteTypeBtn.currentDim)
  2237. {
  2238. element.style.background = "#ff1493";
  2239. }
  2240. else
  2241. {
  2242. element.style.background = "#ff69b4";
  2243. }
  2244. }
  2245. for (let element of document.getElementsByClassName("satellite-style")){
  2246. if (element.id == satelliteStyleBtn.current)
  2247. {
  2248. element.style.background = "#ff1493";
  2249. }
  2250. else
  2251. {
  2252. element.style.background = "#ff69b4";
  2253. }
  2254. }
  2255. }
  2256.  
  2257. function handleSatMenu(cond)
  2258. {
  2259. let transition = true;
  2260. if (cond)
  2261. {
  2262. transition = (satelliteSwitchButton.innerHTML == "Streetview mode");
  2263. }
  2264. else
  2265. {
  2266. transition = (satelliteSwitchButton.innerHTML !== "Streetview mode");
  2267. }
  2268. if (transition)
  2269. {
  2270. for (let element of document.getElementsByClassName("satellite-btn"))
  2271. {
  2272. if (element.id !== "Satellite Switch")
  2273. {
  2274. element.style.visibility = "hidden";
  2275. }
  2276. }
  2277. }
  2278. else
  2279. {
  2280. for (let element of document.getElementsByClassName("satellite-btn"))
  2281. {
  2282. if (element.id !== "Satellite Switch")
  2283. {
  2284. element.style.visibility = "";
  2285. }
  2286. }
  2287. }
  2288. }
  2289.  
  2290. var satelliteSwitchButton = document.createElement("Button");
  2291. satelliteSwitchButton.classList.add("unity-btn", "satellite-btn", "full", "vertical-1");
  2292. satelliteSwitchButton.id = "Satellite Switch";
  2293. satelliteSwitchButton.state = false;
  2294. satelliteSwitchButton.innerHTML = "Streetview mode";
  2295. document.body.appendChild(satelliteSwitchButton);
  2296. satelliteSwitchButton.addEventListener("click", () => {
  2297. handleSatMenu(false);
  2298. if (!initBing)
  2299. {
  2300. let di = formatDist();
  2301. // satelliteRadius.innerHTML = `Satellite (${di})`;
  2302. satelliteSwitchButton.innerHTML = `Satellite (${di})`;
  2303.  
  2304. initBing = true;
  2305. MAPBOX_INJECTED = false;
  2306. BR_LOAD_MP = true;
  2307.  
  2308. let canvas = document.getElementById("sat_map");
  2309. if (!canvas)
  2310. {
  2311. injectMapboxPlayer();
  2312. }
  2313. else
  2314. {
  2315. changeInnerHTML(canvas, false);
  2316. MAPBOX_INJECTED = true;
  2317. }
  2318. nextPlayer = "Mapbox Satellite";
  2319. injectCanvas();
  2320. satCallback();
  2321.  
  2322. sat_choice = true;
  2323. console.log("Load Mapbox Satellite API")
  2324. //
  2325. }
  2326. else
  2327. {
  2328. if (!satelliteSwitchButton.innerHTML.includes("Satellite"))
  2329. {
  2330. // console.log("true!!")
  2331. let di2 = formatDist();
  2332. satelliteSwitchButton.innerHTML = `Satellite (${di2})`;
  2333.  
  2334. nextPlayer = "Mapbox Satellite";
  2335. injectCanvas();
  2336. satCallback();
  2337. nextPlayer = nextPlayer_save;
  2338.  
  2339. sat_choice = true;
  2340. // console.log("hello")
  2341. }
  2342. else
  2343. {
  2344. satelliteSwitchButton.innerHTML = "Streetview mode";
  2345. if (nextPlayer_save == "Mapbox Satellite")
  2346. {
  2347. nextPlayer = "Google";
  2348. }
  2349. else
  2350. {
  2351. nextPlayer = nextPlayer_save;
  2352. }
  2353.  
  2354. injectCanvas();
  2355. if (sat_choice)
  2356. {
  2357. if (nextPlayer !== "Google")
  2358. {
  2359. goToLocation(true);
  2360. }
  2361. handleButtons();
  2362. }
  2363. sat_choice = false;
  2364. }
  2365. if (satelliteSwitchButton.innerHTML !== "Streetview mode" || nextPlayer == "Baidu")
  2366. {
  2367. switchCovergeButton.disabled = true;
  2368. switchCovergeButton.style.background = "red";
  2369. }
  2370. else
  2371. {
  2372. switchCovergeButton.disabled = false;
  2373. switchCovergeButton.style.background = "#ba55d3";
  2374. }
  2375. }
  2376. });
  2377.  
  2378. var satelliteMenu = document.createElement("Button");
  2379. satelliteMenu.classList.add("unity-btn", "menu-btn");
  2380. satelliteMenu.id = "Satellite Menu";
  2381. document.body.appendChild(satelliteMenu);
  2382. satelliteMenu.addEventListener("click", () => {
  2383. switchBtn("satellite-btn");
  2384. if (satelliteSwitchButton.style.visibility == "hidden")
  2385. {
  2386. satelliteSwitchButton.style.visibility = "";
  2387. handleSatMenu(true);
  2388. }
  2389. else
  2390. {
  2391. for (let element of document.getElementsByClassName("satellite-btn"))
  2392. {
  2393. element.style.visibility = "hidden";
  2394. }
  2395. }
  2396.  
  2397. });
  2398.  
  2399.  
  2400. // Mosaic Module Buttons
  2401.  
  2402. var mosaicMain = document.createElement("Button");
  2403. mosaicMain.classList.add("unity-btn", "mosaic-btn", "full", "vertical-1");
  2404. mosaicMain.id = "Mosaic Enable";
  2405. mosaicMain.grid = 0;
  2406. // mosaicMain.random = false;
  2407. mosaicMain.color = false;
  2408. mosaicMain.label = true;
  2409. // mosaicMain.blink = false;
  2410. mosaicMain.innerHTML = "Mosaic Mode";
  2411. document.body.appendChild(mosaicMain);
  2412.  
  2413. var mosaicGridSize = document.createElement("Button");
  2414. mosaicGridSize.classList.add("unity-btn", "mosaic-btn", "half", "horizontal-2", "vertical-2");
  2415. mosaicGridSize.id = "Mosaic Grid";
  2416. mosaicGridSize.innerHTML = "Grid Size";
  2417. document.body.appendChild(mosaicGridSize);
  2418.  
  2419. let gridWidth = [0, 3, 5, 7, 10, 20, 50, 100];
  2420. for (let i = 0; i < gridWidth.length; i++)
  2421. {
  2422. let gridButton = document.createElement("Button");
  2423. gridButton.id = `Grid ${gridWidth[i]}`;
  2424. gridButton.classList.add("unity-btn", "mosaic-btn", "grid-size", "half", "horizontal-2");
  2425. if (i !== 0)
  2426. {
  2427. gridButton.innerHTML = `${gridWidth[i]} x ${gridWidth[i]}`;
  2428. }
  2429. else
  2430. {
  2431. gridButton.innerHTML = `No Grid`;
  2432. }
  2433. document.body.appendChild(gridButton);
  2434. gridButton.addEventListener("click", () => {
  2435. mosaicMain.color = false;
  2436. mosaicMain.label = true;
  2437. loadGridBtn(gridWidth[i]);
  2438. });
  2439. }
  2440.  
  2441. var mosaicGridOpt = document.createElement("Button");
  2442. mosaicGridOpt.classList.add("unity-btn", "mosaic-btn", "half", "horizontal-1", "vertical-2");
  2443. mosaicGridOpt.id = "Mosaic Options";
  2444. mosaicGridOpt.innerHTML = "Options";
  2445. document.body.appendChild(mosaicGridOpt);
  2446.  
  2447. // ["Blink Mode"]
  2448. let gridOpt = ["Add Color", "Remove Label", "Reveal 5%", "Reveal All", "Peek (0.25s)", "Peek (0.5s)" , "Peek (1s)", "Peek (3s)"];
  2449. for (let i = 0; i < gridOpt.length; i++)
  2450. {
  2451. let gridButton = document.createElement("Button");
  2452. gridButton.id = `Grid ${gridOpt[i]}`;
  2453. gridButton.classList.add("unity-btn", "mosaic-btn", "grid-opt", "half", "horizontal-1");
  2454. gridButton.innerHTML = `${gridOpt[i]}`;
  2455. document.body.appendChild(gridButton);
  2456. if (gridOpt[i] == "Reveal All")
  2457. {
  2458. gridButton.addEventListener("click", () => {
  2459. let gridCanvas = document.getElementById("grid");
  2460. if (gridCanvas)
  2461. {
  2462. gridCanvas.style.visibility = "hidden";
  2463. }
  2464. });
  2465. }
  2466. else if (gridOpt[i].includes("Peek"))
  2467. {
  2468. gridButton.addEventListener("click", () => {
  2469. let gridCanvas = document.getElementById("grid");
  2470. if (gridCanvas)
  2471. {
  2472. gridCanvas.style.visibility = "hidden";
  2473. let time = 500;
  2474. if (gridOpt[i].includes("0.25s"))
  2475. {
  2476. time = 250;
  2477. }
  2478. else if (gridOpt[i].includes("0.5s"))
  2479. {
  2480. time = 500;
  2481. }
  2482. else if (gridOpt[i].includes("1s"))
  2483. {
  2484. time = 1000;
  2485. }
  2486. else if (gridOpt[i].includes("3s"))
  2487. {
  2488. time = 3000;
  2489. }
  2490. setTimeout(function() {gridCanvas.style.visibility = "";}, time);
  2491. }
  2492. });
  2493. }
  2494. else if (gridOpt[i] == "Reveal 5%")
  2495. {
  2496. gridButton.addEventListener("click", () => {
  2497. for (let grid of document.getElementsByClassName("grid-btn"))
  2498. {
  2499. let num = Math.random();
  2500. if (num > 0.95)
  2501. {
  2502. grid.style.visibility = "hidden";
  2503. }
  2504. }
  2505. });
  2506. }
  2507. else if (gridOpt[i] == "Add Color")
  2508. {
  2509. gridButton.addEventListener("click", () => {
  2510. mosaicMain.color = true;
  2511. for (let grid of document.getElementsByClassName("grid-btn"))
  2512. {
  2513. grid.style.background = '#' + (Math.random() * 0xFFFFFF<<0).toString(16);
  2514. }
  2515. });
  2516. }
  2517. else if (gridOpt[i] == "Remove Label")
  2518. {
  2519. gridButton.addEventListener("click", () => {
  2520. mosaicMain.label = false;
  2521. for (let grid of document.getElementsByClassName("grid-btn"))
  2522. {
  2523. grid.innerHTML = "";
  2524. }
  2525. });
  2526. }
  2527. }
  2528.  
  2529. var mosaicMenu = document.createElement("Button");
  2530. mosaicMenu.classList.add("unity-btn", "menu-btn");
  2531. mosaicMenu.id = "Mosaic Menu";
  2532. document.body.appendChild(mosaicMenu);
  2533. mosaicMenu.addEventListener("click", () => {
  2534. switchBtn("mosaic-btn");
  2535. if (mosaicMain.style.visibility == "hidden")
  2536. {
  2537. for (let element of document.getElementsByClassName("mosaic-btn"))
  2538. {
  2539. element.style.visibility = "";
  2540. }
  2541. }
  2542. else
  2543. {
  2544. for (let element of document.getElementsByClassName("mosaic-btn"))
  2545. {
  2546. element.style.visibility = "hidden";
  2547. }
  2548. }
  2549. });
  2550.  
  2551. // Minimap Module
  2552.  
  2553. var MinimapBtn = document.createElement("Button");
  2554. MinimapBtn.classList.add("unity-btn", "minimap-btn", "half", "horizontal-2", "vertical-1");
  2555. MinimapBtn.id = "Minimap Button";
  2556. MinimapBtn.innerHTML = "Minimap Style";
  2557. MinimapBtn.current = "Default";
  2558. // MinimapBtn.childVisible = false;
  2559. document.body.appendChild(MinimapBtn);
  2560.  
  2561. for (let a of presetMinimap)
  2562. {
  2563. let aButton = document.createElement("Button");
  2564. aButton.id = a[1];
  2565. aButton.classList.add("unity-btn", "minimap-btn", "preset-minimap", "half", "horizontal-2");
  2566. aButton.innerHTML = a[1];
  2567. document.body.appendChild(aButton);
  2568. }
  2569.  
  2570. var OverlayBtn = document.createElement("Button");
  2571. OverlayBtn.classList.add("unity-btn", "minimap-btn", "half", "horizontal-1", "vertical-1");
  2572. OverlayBtn.id = "Overlay Button";
  2573. OverlayBtn.innerHTML = "Overlay";
  2574. OverlayBtn.current = "Clear";
  2575. // OverlayBtn.childVisible = false;
  2576. document.body.appendChild(OverlayBtn);
  2577.  
  2578. for (let b of presetOverlay)
  2579. {
  2580. let bButton = document.createElement("Button");
  2581. bButton.id = b[0];
  2582. bButton.url = b[1];
  2583. bButton.loaded = false;
  2584. bButton.classList.add("unity-btn", "minimap-btn", "overlay-minimap", "half", "horizontal-1");
  2585. bButton.innerHTML = b[0];
  2586. document.body.appendChild(bButton);
  2587. }
  2588.  
  2589. var MinimapMenuBtn = document.createElement("Button");
  2590. MinimapMenuBtn.classList.add("unity-btn", "menu-btn");
  2591. MinimapMenuBtn.id = "Minimap Menu Button";
  2592. document.body.appendChild(MinimapMenuBtn);
  2593. MinimapMenuBtn.addEventListener("click", () => {
  2594. switchBtn("minimap-btn");
  2595. if (OverlayBtn.style.visibility !== "hidden")
  2596. {
  2597. for (let element of document.getElementsByClassName("minimap-btn")){
  2598. element.style.visibility="hidden";
  2599. }
  2600. }
  2601. else
  2602. {
  2603. for (let element of document.getElementsByClassName("minimap-btn")){
  2604. element.style.visibility="";
  2605. }
  2606. }
  2607. });
  2608.  
  2609.  
  2610.  
  2611.  
  2612.  
  2613.  
  2614.  
  2615. // Space Buttons Module
  2616.  
  2617. // var SpaceMainmapBtn = document.createElement("Button");
  2618. // SpaceMainmapBtn.classList.add("unity-btn", "space-btn", "half", "horizontal-2", "vertical-1");
  2619. // SpaceMainmapBtn.id = "SpMini Button";
  2620. // SpaceMainmapBtn.innerHTML = "Minimap Style";
  2621. // SpaceMainmapBtn.current = "Default";
  2622. // // SpaceMainmapBtn.childVisible = false;
  2623. // document.body.appendChild(SpaceMainmapBtn);
  2624.  
  2625. // for (let a of spaceMainmap)
  2626. // {
  2627. // let saButton = document.createElement("Button");
  2628. // saButton.id = a[0];
  2629. // saButton.url = a[1];
  2630. // saButton.classList.add("unity-btn", "space-btn", "space-mainmap", "half", "horizontal-2");
  2631. // saButton.innerHTML = a[0];
  2632. // document.body.appendChild(saButton);
  2633. // }
  2634.  
  2635. var SpaceOverlayBtn = document.createElement("Button");
  2636. SpaceOverlayBtn.classList.add("unity-btn", "space-btn", "extra-full", "horizontal-1", "vertical-1");
  2637. SpaceOverlayBtn.id = "SpOver Button";
  2638. SpaceOverlayBtn.innerHTML = "Space";
  2639. SpaceOverlayBtn.current = "Clear";
  2640. // SpaceOverlayBtn.childVisible = false;
  2641. document.body.appendChild(SpaceOverlayBtn);
  2642.  
  2643. for (let b of spaceMinimap)
  2644. {
  2645. let sbButton = document.createElement("Button");
  2646. sbButton.id = b[0];
  2647. sbButton.url = b[1];
  2648. sbButton.classList.add("unity-btn", "space-btn", "spaceMM", "space-minimap", "half", "horizontal-1");
  2649. sbButton.innerHTML = b[0];
  2650. document.body.appendChild(sbButton);
  2651. }
  2652.  
  2653. for (let c of spaceMinimap2)
  2654. {
  2655. let scButton = document.createElement("Button");
  2656. scButton.id = c[0];
  2657. scButton.url = c[1];
  2658. scButton.classList.add("unity-btn", "space-btn", "spaceMM", "space-2minimap", "half", "horizontal-2");
  2659. scButton.innerHTML = c[0];
  2660. document.body.appendChild(scButton);
  2661. }
  2662.  
  2663. for (let d of spaceMinimap3)
  2664. {
  2665. let sdButton = document.createElement("Button");
  2666. sdButton.id = d[0];
  2667. sdButton.url = d[1];
  2668. sdButton.classList.add("unity-btn", "space-btn", "spaceMM", "space-3minimap", "half", "horizontal-3");
  2669. sdButton.innerHTML = d[0];
  2670. document.body.appendChild(sdButton);
  2671. }
  2672.  
  2673.  
  2674. var SpaceMenuBtn = document.createElement("Button");
  2675. SpaceMenuBtn.classList.add("unity-btn", "menu-btn");
  2676. SpaceMenuBtn.id = "Space Menu Button";
  2677. document.body.appendChild(SpaceMenuBtn);
  2678. SpaceMenuBtn.addEventListener("click", () => {
  2679. switchBtn("space-btn");
  2680. if (document.getElementById("Ceres").style.visibility !== "hidden")
  2681. {
  2682. for (let element of document.getElementsByClassName("space-btn")){
  2683. element.style.visibility = "hidden";
  2684. }
  2685. }
  2686. else
  2687. {
  2688. for (let element of document.getElementsByClassName("space-btn")){
  2689. element.style.visibility = "";
  2690. }
  2691. }
  2692. });
  2693.  
  2694. var wikiLocalLang = document.createElement("Button");
  2695. wikiLocalLang.classList.add("unity-btn", "full", "horizontal-1", "vertical-0");
  2696. wikiLocalLang.id = "local language";
  2697. wikiLocalLang.state = true;
  2698. wikiLocalLang.innerHTML = "Switch to Local Language";
  2699. document.body.appendChild(wikiLocalLang);
  2700. wikiLocalLang.addEventListener("click", () => {
  2701. if (wikiLocalLang.state && global_cc)
  2702. {
  2703. let cc = langDict[global_cc];
  2704. let fi = "en";
  2705. if (typeof cc !== typeof undefined)
  2706. {
  2707. fi = cc[Math.floor(Math.random() * cc.length)];
  2708. }
  2709. wiki(fi, document.getElementById("i_container"), teleportMenu);
  2710. wikiLocalLang.innerHTML = "Switch to English";
  2711. wikiLocalLang.state = false;
  2712. }
  2713. else
  2714. {
  2715. wiki("en", document.getElementById("i_container"), teleportMenu);
  2716. wikiLocalLang.innerHTML = "Switch to Local Language";
  2717. wikiLocalLang.state = true;
  2718. }
  2719. });
  2720.  
  2721.  
  2722.  
  2723.  
  2724. handleStyles();
  2725.  
  2726.  
  2727.  
  2728. console.log("Script buttons Loaded");
  2729. }
  2730.  
  2731. // Handle Grid Mode
  2732.  
  2733. function loadGridBtn(num)
  2734. {
  2735. let gridCanvas = document.getElementById("grid");
  2736. let reload = false;
  2737. if (!gridCanvas && num !== 0)
  2738. {
  2739. let gridBtn = document.createElement("div");
  2740. gridBtn.id = "grid";
  2741. // visibility: hidden;
  2742. gridBtn.style =
  2743. `
  2744. display: grid;
  2745. gap: 0px;
  2746. top: 0px;
  2747. left: 0px;
  2748. position: absolute;
  2749. width: 100%;
  2750. height: 100%;
  2751. z-index: 1;
  2752. `;
  2753. GAME_CANVAS.appendChild(gridBtn);
  2754. gridCanvas = gridBtn;
  2755. reload = true;
  2756. }
  2757.  
  2758. if (gridCanvas)
  2759. {
  2760. let mosaicMenu = document.getElementById("Mosaic Enable");
  2761. if (num !== mosaicMenu.grid || reload)
  2762. {
  2763. console.log("Generate Mosaic tiles");
  2764. gridCanvas.innerHTML = "";
  2765. mosaicMenu.grid = num;
  2766. // cond = true;
  2767. if (num !== 0)
  2768. {
  2769. gridCanvas.style.visibility = "";
  2770. for (let i = 1; i < num+1; i++)
  2771. {
  2772. for (let ii = 1; ii < num+1; ii++)
  2773. {
  2774. let btn1 = document.createElement("Button");
  2775. btn1.style =
  2776. `grid-column: ${ii};
  2777. grid-row: ${i};
  2778. `;
  2779. btn1.classList.add("grid-btn");
  2780. if (num < 21 && mosaicMenu.label)
  2781. {
  2782. btn1.innerHTML = `(${ii}, ${i})`;
  2783. }
  2784. btn1.addEventListener("click", () => {
  2785. btn1.style.visibility = "hidden";
  2786. });
  2787. if (mosaicMenu.color)
  2788. {
  2789. btn1.style.background = '#' + (Math.random() * 0xFFFFFF<<0).toString(16);
  2790. }
  2791. gridCanvas.appendChild(btn1);
  2792. }
  2793. }
  2794. mosaicMenu.grid = num;
  2795. }
  2796. else
  2797. {
  2798. gridCanvas.style.visibility = "hidden";
  2799. }
  2800.  
  2801. for (let grid2 of document.getElementsByClassName("grid-size"))
  2802. {
  2803. grid2.style.background = "#ff69b4";
  2804. if (parseInt(grid2.id.replace(/\D/g,'')) == mosaicMenu.grid)
  2805. {
  2806. grid2.style.background = "#ff1493";
  2807. }
  2808. }
  2809. }
  2810.  
  2811. if (num !== 0)
  2812. {
  2813. gridCanvas.style.visibility = "";
  2814. for (let grid1 of document.getElementsByClassName("grid-btn"))
  2815. {
  2816. grid1.style.visibility = "";
  2817. }
  2818. }
  2819.  
  2820.  
  2821.  
  2822.  
  2823. }
  2824. }
  2825.  
  2826.  
  2827. function GenBtnColor()
  2828. {
  2829. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  2830. let timeMachineOlderBtn = document.getElementById("minus year");
  2831. let timeMachineNewerBtn = document.getElementById("plus year");
  2832. let timeMachineBtn = document.getElementById("Date Button");
  2833. if (timeMachineBtn.index == timeMachineBtn.list.length - 1)
  2834. {
  2835. timeMachineNewerBtn.style.backgroundColor = "red";
  2836. timeMachineNewerBtn.disabled = true;
  2837. }
  2838. else
  2839. {
  2840. timeMachineNewerBtn.style.backgroundColor = "#ba55d3";
  2841. timeMachineNewerBtn.disabled = false;
  2842. }
  2843. if (timeMachineBtn.index == 0)
  2844. {
  2845. timeMachineOlderBtn.style.backgroundColor = "red";
  2846. timeMachineOlderBtn.disabled = true;
  2847. }
  2848. else
  2849. {
  2850. timeMachineOlderBtn.style.backgroundColor = "#ba55d3";
  2851. timeMachineOlderBtn.disabled = false;
  2852. }
  2853. }
  2854.  
  2855. /**
  2856. * Handle Keyboard inputs
  2857. */
  2858.  
  2859. function kBoard()
  2860. {
  2861. document.addEventListener('keydown', logKey);
  2862. }
  2863.  
  2864. function logKey(e) {
  2865. // console.log(e.code);
  2866. let mainMenuBtn = document.getElementById("Show Buttons");
  2867. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  2868. if (e.code == "Space")
  2869. {
  2870. setHidden(true);
  2871. }
  2872. if (e.code == "Digit4")
  2873. {
  2874. document.getElementById("Teleport Forward").click();
  2875. }
  2876. if (e.code == "Digit3")
  2877. {
  2878. document.getElementById("Teleport Reverse").click();
  2879. }
  2880. else if (e.code == "Digit5")
  2881. {
  2882. document.getElementById("minus year").click();
  2883. }
  2884. else if (e.code == "Digit6")
  2885. {
  2886. document.getElementById("Date Button").click();
  2887. }
  2888. else if (e.code == "Digit7")
  2889. {
  2890. document.getElementById("plus year").click();
  2891. }
  2892. else if (e.code == "Digit8")
  2893. {
  2894. if (mainMenuBtn.style.visibility == "hidden")
  2895. {
  2896. mainMenuBtn.style.visibility = "";
  2897. }
  2898. else
  2899. {
  2900. mainMenuBtn.style.visibility = "hidden";
  2901. }
  2902. }
  2903. else if (e.code == "Digit9")
  2904. {
  2905. document.getElementById("Restrict Bounds Main").maxDist = 100000000;
  2906. document.getElementById("Increase Restrict Distance").click();
  2907. if (!document.getElementById("Restrict Bounds Main").enabled)
  2908. {
  2909. document.getElementById("Restrict Bounds Enable").click();
  2910. }
  2911. }
  2912. }
  2913.  
  2914.  
  2915. /**
  2916. * Hide or reveal the buttons, and disable buttons if such feature is not available
  2917. */
  2918.  
  2919. function setHidden(cond)
  2920. {
  2921. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  2922. let teleportBtn = document.getElementById("Teleport Forward");
  2923. let mainMenuBtn = document.getElementById("Show Buttons");
  2924. if (mainMenuBtn != null)
  2925. {
  2926. mainMenuBtn.style.visibility = "";
  2927. mainMenuBtn.hide = true;
  2928. // console.log(["cache", mainMenuBtn.menuBtnCache]);
  2929. if (cond)
  2930. {
  2931. if (teleportBtn != null)
  2932. {
  2933. for (let element of document.getElementsByClassName("unity-btn")){
  2934. element.style.visibility = "hidden";
  2935. }
  2936. }
  2937. let iframe = document.getElementById("i_container");
  2938. if (iframe != null)
  2939. {
  2940. if (!isBattleRoyale)
  2941. {
  2942. iframe.src = ""
  2943. }
  2944. else
  2945. {
  2946. // TODO
  2947. }
  2948. }
  2949.  
  2950. }
  2951. else
  2952. {
  2953. for (let element of document.getElementsByClassName("unity-btn")){
  2954. if (element.id !== "Show Buttons" && !element.classList.contains("menu-btn"))
  2955. {
  2956. element.style.visibility = "hidden";
  2957. }
  2958. }
  2959. }
  2960. }
  2961. }
  2962.  
  2963. function setDisable(cond) {
  2964. let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  2965. let btnList = [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ];
  2966.  
  2967. function setAll(cond1, cond2)
  2968. {
  2969. for (let btn of btnList)
  2970. {
  2971. btn.style.backgroundColor = cond1;
  2972. btn.disabled = cond2;
  2973. }
  2974. }
  2975.  
  2976. function setMapstyle(cond1, cond2)
  2977. {
  2978. for (let mapDiv of document.getElementsByClassName("preset-minimap"))
  2979. {
  2980. if (["Borders", "Satellite", "Terrain", "Hybrid", "Custom"].includes(mapDiv.id))
  2981. {
  2982. mapDiv.style.backgroundColor = cond1;
  2983. mapDiv.disabled = cond2;
  2984. }
  2985. }
  2986. for (let mapDiv2 of document.getElementsByClassName("overlay-minimap"))
  2987. {
  2988. if (["Coverage", "Official", "OSM"].includes(mapDiv2.id))
  2989. {
  2990. mapDiv2.style.backgroundColor = cond1;
  2991. mapDiv2.disabled = cond2;
  2992. }
  2993. }
  2994. }
  2995.  
  2996. // console.log(cond)
  2997.  
  2998. if (teleportBtn != null) {
  2999. setMapstylePlanet("None");
  3000. if (rtded) {
  3001. setAll("red", true);
  3002. setMapstyle("red", true);
  3003. }
  3004. else
  3005. {
  3006. setMapstyle("#ff69b4", false)
  3007. if (cond == ms_sat_map)
  3008. {
  3009. setAll("red", true);
  3010. }
  3011. else if (cond == "NMPZ") {
  3012. setAll("red", true);
  3013. if (cond !== "Baidu")
  3014. {
  3015. satelliteSwitchButton.style.backgroundColor = "#ba55d3";
  3016. satelliteSwitchButton.disabled = false;
  3017. }
  3018. if (NZ)
  3019. {
  3020. if (ms_radius > 5000)
  3021. {
  3022. ms_radius = 5000;
  3023. }
  3024. }
  3025. if (NM)
  3026. {
  3027. if (ms_radius > 2000)
  3028. {
  3029. ms_radius = 2000;
  3030. }
  3031. }
  3032. if (NM && NZ)
  3033. {
  3034. if (ms_radius > 1000)
  3035. {
  3036. ms_radius = 1000;
  3037. }
  3038. }
  3039. if (NM && NP && NZ)
  3040. {
  3041. if (ms_radius > 500)
  3042. {
  3043. ms_radius = 500;
  3044. }
  3045. }
  3046. }
  3047. else if (cond == "Google" || nextPlayer === "Wikipedia") {
  3048. setAll("#ba55d3", false);
  3049. if (bullseyeMapillary && cond == "Google")
  3050. {
  3051. switchCovergeButton.style.backgroundColor = "red";
  3052. switchCovergeButton.disabled = true;
  3053. }
  3054. }
  3055. else if (cond === "Baidu" || cond === "Youtube" || cond === "Image" || nextPlayer === "Minecraft") {
  3056. setAll("red", true);
  3057. switchCovergeButton.style.backgroundColor = "#ba55d3";
  3058. switchCovergeButton.disabled = false;
  3059. if (cond !== "Baidu")
  3060. {
  3061. satelliteSwitchButton.style.backgroundColor = "#ba55d3";
  3062. satelliteSwitchButton.disabled = false;
  3063. }
  3064. }
  3065. else if (cond == "Kakao" || cond == "Yandex" || cond == "Mapillary" || cond == "Bing Streetside" || cond == "Mapbox Satellite") {
  3066. setAll("#ba55d3", false);
  3067. timeMachineBtn.style.backgroundColor = "red";
  3068. timeMachineBtn.disabled = true;
  3069. let li = [RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn]
  3070. for (let btns of li)
  3071. {
  3072. btns.style.backgroundColor = "red";
  3073. btns.disabled = true;
  3074. }
  3075.  
  3076. }
  3077. else if (cond == "Planets") {
  3078. setAll("red", true);
  3079. console.log("setting map style");
  3080. setMapstyle("red", true);
  3081. setMapstylePlanet(planetType);
  3082. }
  3083. }
  3084. timeMachineNewerBtn.style.backgroundColor = "red";
  3085. timeMachineNewerBtn.disabled = true;
  3086. timeMachineOlderBtn.style.backgroundColor = "red";
  3087. timeMachineOlderBtn.disabled = true;
  3088.  
  3089. }
  3090. }
  3091.  
  3092. function setMapstylePlanet(cond)
  3093. {
  3094. for (let mapDiv of document.getElementsByClassName("spaceMM"))
  3095. {
  3096. if (cond == "None" && mapDiv.id.includes("Earth"))
  3097. {
  3098. mapDiv.style.backgroundColor = "#ff1493";
  3099. mapDiv.disabled = false;
  3100. }
  3101. else if (mapDiv.id.includes(cond) || mapDiv.id.includes("Earth"))
  3102. {
  3103. mapDiv.style.backgroundColor = "#ff69b4";
  3104. mapDiv.disabled = false;
  3105. }
  3106. else
  3107. {
  3108. mapDiv.style.backgroundColor = "red";
  3109. mapDiv.disabled = true;
  3110. }
  3111. }
  3112. }
  3113.  
  3114.  
  3115. /**
  3116. * This observer stays alive while the script is running
  3117. */
  3118.  
  3119.  
  3120.  
  3121. function launchObserver() {
  3122. UnityInitiate();
  3123. handleTeleport();
  3124. SyncListener();
  3125. kBoard();
  3126. console.log("Main Observer");
  3127. // const OBSERVER = new MutationObserver((mutations, observer) => {
  3128. // detectGamePage();
  3129. // });
  3130. // OBSERVER.observe(document.head, { attributes: true, childList: true, subtree: true });
  3131. let observer3 = new MutationObserver((mutations) => {
  3132. mutations.forEach((mutation) => {
  3133. if (oldHref != document.location.href && allowDetect) {
  3134. oldHref = document.location.href;
  3135. detectGamePage();
  3136. }
  3137. if (mutation.removedNodes)
  3138. {
  3139. for (let m of mutation.removedNodes) {
  3140. if (m.classList)
  3141. {
  3142. let sat = m.getElementsByTagName('sat-map');
  3143. if (sat.length !== 0)
  3144. {
  3145. let sat0 = sat[0];
  3146. sat0.style.display = "none";
  3147. // console.log(sat0)
  3148. sat0.querySelector('.mapboxgl-map').classList.remove("inactive", "game-panorama_panorama__ncMwh", "game-panorama_panorama__Qpsxl", "br-game-layout__panorama", "game-layout__panorama", "game-panorama_panorama__rdhFg")
  3149. document.body.appendChild(sat0);
  3150. }
  3151. }
  3152. }
  3153. }
  3154. if (mutation.addedNodes)
  3155. {
  3156. for (let m of mutation.addedNodes) {
  3157. // console.log(m);
  3158. if (m.classList)
  3159. {
  3160. // let sat3 = m.getElementsByClassName("tooltip_tooltip__CHe2s");
  3161. let PATHNAME = window.location.pathname;
  3162. // let sat4 = m.getElementsByClassName('fullscreen-spinner_square__mwMfl');
  3163. // console.log(m.classList.contains('round-starting_wrapper__1G_FC'));
  3164. if (m.getElementsByClassName("tooltip_tooltip__CHe2s").length !== 0)
  3165. {
  3166. // console.log("detect setting")
  3167. let mainMenuBtn = document.getElementById("Show Buttons");
  3168. if (mainMenuBtn != null && !cn_tips)
  3169. {
  3170. // console.log("try to show show buttons")
  3171. mainMenuBtn.style.visibility = "";
  3172. if (mainMenuBtn.menuBtnCache)
  3173. {
  3174. for (let element of document.getElementsByClassName("menu-btn"))
  3175. {
  3176. element.style.visibility = "";
  3177. }
  3178. }
  3179. }
  3180. detectGamePage();
  3181. }
  3182. else if (m.getElementsByClassName(FAIL_TO_LOAD_CANVAS).length !== 0)
  3183. {
  3184. console.log("Fail to load canvas message")
  3185. if (allowDetect)
  3186. {
  3187. detectGamePage();
  3188. }
  3189. }
  3190. else if ((PATHNAME.startsWith("/challenge/") ||PATHNAME.startsWith("/results/") ||
  3191. PATHNAME.startsWith("/game/")|| PATHNAME.startsWith("/battle-royale/") ||
  3192. PATHNAME.startsWith("/duels/") || PATHNAME.startsWith("/team-duels/") ||
  3193. PATHNAME.startsWith("/bullseye/")) && (m.getElementsByClassName('fullscreen-spinner_square__mwMfl').length !== 0))
  3194. {
  3195. // console.log("detect spinner")
  3196. if (allowDetect)
  3197. {
  3198. detectGamePage();
  3199. }
  3200. }
  3201. else if ((PATHNAME.startsWith("/duels/") || PATHNAME.startsWith("/team-duels/")) && (m.classList.contains('new-round_roundInfo__UlMCc')))
  3202. {
  3203. // console.log("detect duel")
  3204. if (allowDetect)
  3205. {
  3206. detectGamePage();
  3207. }
  3208. }
  3209. else if (PATHNAME.startsWith("/live-challenge/") && (m.classList.contains('round-starting_wrapper__1G_FC')))
  3210. {
  3211. // console.log("detect live challie")
  3212. if (allowDetect)
  3213. {
  3214. detectGamePage();
  3215. }
  3216. }
  3217.  
  3218. let sat = m.getElementsByClassName('result-layout_bottom__qLPd2');
  3219.  
  3220. if (m.getElementsByClassName('result-layout_bottom__qLPd2').length !== 0)
  3221. {
  3222. // console.log("Round middle Callback");
  3223. nextButtonCallback();
  3224. }
  3225.  
  3226. let sat2 = m.getElementsByClassName('guess-map__canvas-container');
  3227. if (sat2.length !== 0)
  3228. {
  3229. // console.log("Minimap Callback");
  3230. handleMinimapCallback();
  3231. }
  3232. }
  3233. }
  3234. }
  3235. })
  3236. })
  3237. observer3.observe(document.body, {childList: true, subtree: true, attributes: false, characterData: false})
  3238. }
  3239.  
  3240.  
  3241. /**
  3242. * Once the Google Maps API was loaded we can do more stuff
  3243. */
  3244.  
  3245. var oldHref = document.location.href;
  3246.  
  3247. window.addEventListener('DOMContentLoaded', (event) => {
  3248.  
  3249. if (!document.getElementById("Show Buttons"))
  3250. {
  3251. injecter(() => {
  3252. launchObserver();
  3253. })
  3254. }
  3255. });
  3256.  
  3257. const base62 = {
  3258. charset: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
  3259. .split(''),
  3260. encode: integer => {
  3261. if (integer === 0) {
  3262. return 0;
  3263. }
  3264. let s = [];
  3265. while (integer > 0) {
  3266. s = [base62.charset[integer % 62], ...s];
  3267. integer = Math.floor(integer / 62);
  3268. }
  3269. return s.join('');
  3270. },
  3271. decode: chars => chars.split('').reverse().reduce((prev, curr, i) =>
  3272. prev + (base62.charset.indexOf(curr) * (62 ** i)), 0)
  3273. };
  3274.  
  3275.  
  3276. /**
  3277. * Check whether the current page is a game, if so which game mode
  3278. */
  3279.  
  3280. function detectGamePage() {
  3281. // console.log("detect game change");
  3282. if (document.querySelector(FAIL_TO_LOAD_CANVAS) !== null && !one_reset)
  3283. {
  3284. one_reset = true;
  3285. console.log("Hide fail to load panorama canvas");
  3286. document.querySelector(FAIL_TO_LOAD_CANVAS).style.visibility = "hidden";
  3287. }
  3288. function loadModule()
  3289. {
  3290. // console.log("load module")
  3291.  
  3292. if (toLoad) {
  3293. // console.log("initializeCanvas")
  3294. initializeCanvas();
  3295. }
  3296. waitLoad();
  3297.  
  3298. }
  3299. let toLoad = !playerLoaded && !YANDEX_INJECTED && !KAKAO_INJECTED && !MAPILLARY_INJECTED && !MS_INJECTED && !MAPBOX_INJECTED;
  3300. const PATHNAME = window.location.pathname;
  3301. // console.log(PATHNAME)
  3302. if (PATHNAME.startsWith("/game/") || PATHNAME.startsWith("/challenge/")) {
  3303. // console.log("Game page");
  3304. isBattleRoyale = false;
  3305. isDuel = false;
  3306. loadModule();
  3307. }
  3308. else if (PATHNAME.startsWith("/battle-royale/")) {
  3309. if (document.querySelector(BR_LAYOUT) == null) {
  3310. // console.log("Battle Royale Lobby");
  3311. rstValues();
  3312. }
  3313. else {
  3314. // console.log("Battle Royale");
  3315. isBattleRoyale = true;
  3316. isDuel = false;
  3317. loadModule();
  3318. }
  3319. }
  3320. else if (PATHNAME.startsWith("/duels/") || PATHNAME.startsWith("/team-duels/")) {
  3321. if (document.querySelector(DUEL_LAYOUT) == null) {
  3322. // console.log("Battle Royale Lobby");
  3323. rstValues();
  3324. }
  3325. else {
  3326. // console.log("Duels");
  3327. isBattleRoyale = true;
  3328. isDuel = true;
  3329. loadModule();
  3330. }
  3331. }
  3332. else if (PATHNAME.startsWith("/bullseye/")) {
  3333. if (document.querySelector(".game_layout__0vAWj") == null) {
  3334. // console.log("Battle Royale Lobby");
  3335. rstValues();
  3336. }
  3337. else {
  3338. // console.log("bullseye");
  3339. isBattleRoyale = true;
  3340. isBullseye = true;
  3341. // console.log(document.getElementById("player"));
  3342. if (document.getElementById("player") == null)
  3343. {
  3344. loadModule();
  3345. }
  3346. }
  3347. }
  3348. else if (PATHNAME.startsWith("/live-challenge/")) {
  3349. if (document.querySelector(".panorama-question_layout__DYh_Y") == null) {
  3350. // console.log("Battle Royale Lobby");
  3351. rstValues();
  3352. }
  3353. else {
  3354. // console.log("bullseye");
  3355. isLiveChallenge = true;
  3356. isBattleRoyale = true;
  3357. loadModule();
  3358. }
  3359. }
  3360. else {
  3361. rstValues();
  3362. // console.log("Not a Game page");
  3363. }
  3364. }
  3365.  
  3366. function rstValues()
  3367. {
  3368. ROUND = 0;
  3369. YandexPlayer = null;
  3370. KakaoPlayer = null;
  3371. MapillaryPlayer = null;
  3372. MSStreetPlayer = null;
  3373. // MapboxPlayer = null;
  3374. // MapboxMarker = null;
  3375.  
  3376. BAIDU_INJECTED = false;
  3377. YANDEX_INJECTED = false;
  3378. KAKAO_INJECTED = false;
  3379. MAPILLARY_INJECTED = false;
  3380. MS_INJECTED = false;
  3381. MAPBOX_INJECTED = false;
  3382.  
  3383. nextPlayer = "Google";
  3384. nextPlayer_save = "Google";
  3385. global_lat = 0;
  3386. global_lng = 0;
  3387. global_panoID = null;
  3388. global_cc = null;
  3389. global_BDAh = null;
  3390. global_BDBh = null;
  3391. global_BDID = null;
  3392. yId = null;
  3393. yTime = null;
  3394. yEnd = null;
  3395. iId = null;
  3396.  
  3397. COMPASS = null;
  3398. eventListenerAttached = false;
  3399. povListenerAttached = false;
  3400. playerLoaded = false;
  3401. locHistory = [];
  3402. one_reset = false;
  3403. setHidden(true);
  3404. yandex_map = false;
  3405. Kakao_map = false;
  3406. Wikipedia_map = false;
  3407. Minecraft_map = false;
  3408. bing_map = false;
  3409. mmKey = 0;
  3410. CURRENT_ROUND_DATA = null;
  3411. ms_radius = 15000;
  3412.  
  3413. isDuel = false;
  3414. isBattleRoyale = false;
  3415. isBullseye = false;
  3416. isLiveChallenge = false;
  3417.  
  3418. BR_LOAD_KAKAO = false;
  3419. BR_LOAD_YANDEX = false;
  3420. BR_LOAD_MS = false;
  3421. BR_LOAD_MP = false;
  3422. BR_LOAD_MAPILLARY = false;
  3423.  
  3424. ms_sat_map = false;
  3425. rtded = false;
  3426.  
  3427. linksList = [];
  3428.  
  3429. NM = false;
  3430. NP = false;
  3431. NZ = false;
  3432. initBing = false;
  3433.  
  3434. planetType = "None";
  3435. wikiUrl = "";
  3436. bullseyeMapillary = false;
  3437.  
  3438. GAME_CANVAS = "";
  3439. DUEL_CANVAS = "";
  3440. randomPlanets = false;
  3441.  
  3442. let RestrictBoundsBtn = document.getElementById("Restrict Bounds Main");
  3443. let RestrictBoundsEnableBtn = document.getElementById("Restrict Bounds Enable");
  3444. if (RestrictBoundsBtn && RestrictBoundsEnableBtn)
  3445. {
  3446. RestrictBoundsBtn.innerHTML = "No Escape Mode Disabled";
  3447. RestrictBoundsBtn.enabled = false;
  3448. RestrictBoundsEnableBtn.innerHTML = "Enable Limit";
  3449. }
  3450. }
  3451.  
  3452. /**
  3453. * Wait for various players to load
  3454. */
  3455.  
  3456. function btnAll()
  3457. {
  3458. // console.log([document.querySelector(BULLSEYE_CANVAS), "???"])
  3459. if (document.querySelector(".ticket-bar_root__H8RcX") != null)
  3460. {
  3461. if (document.querySelector(BR_CANVAS) != null)
  3462. {
  3463. AdjustBtnPos("-2em + 2px", "300px", true);
  3464. }
  3465. else if (document.querySelector(DUELS_CANVAS) != null)
  3466. {
  3467. AdjustBtnPos("6em", "0em", true);
  3468. }
  3469. else if (document.querySelector(BULLSEYE_CANVAS) != null)
  3470. {
  3471. AdjustBtnPos("5em", "18.5em", true);
  3472. }
  3473. else if (document.querySelector(LIVE_CANVAS) != null)
  3474. {
  3475. AdjustBtnPos("4em", "15.5em", true);
  3476. }
  3477. else
  3478. {
  3479. AdjustBtnPos("4em", "0em", true);
  3480. }
  3481. }
  3482. else
  3483. {
  3484. if (document.querySelector(BR_CANVAS) != null)
  3485. {
  3486. AdjustBtnPos("-6em + 2px", "300px", true);
  3487. }
  3488. else if (document.querySelector(DUELS_CANVAS) != null)
  3489. {
  3490. AdjustBtnPos("2em", "0em", true);
  3491. }
  3492. else if (document.querySelector(BULLSEYE_CANVAS) != null)
  3493. {
  3494. AdjustBtnPos("1em", "18.5em", true);
  3495. }
  3496. else if (document.querySelector(LIVE_CANVAS) != null)
  3497. {
  3498. AdjustBtnPos("0em", "15.5em", true);
  3499. }
  3500. else
  3501. {
  3502. AdjustBtnPos("0em", "0em", true);
  3503. }
  3504. }
  3505. if (menuLocCounter > 0)
  3506. {
  3507. for (let i = 0; i < menuLocCounter; i++) {
  3508. AdjustBtnPos("-2em", "0em", false);
  3509. }
  3510. }
  3511. else if (menuLocCounter < 0)
  3512. {
  3513. for (let i = 0; i < -menuLocCounter; i++) {
  3514. AdjustBtnPos("2em", "0em", false);
  3515. }
  3516. }
  3517. }
  3518.  
  3519. function waitLoad() {
  3520. if (!YandexPlayer || !KakaoPlayer || !MapillaryPlayer || !MSStreetPlayer || !MapboxPlayer || !document.getElementById("i_container") || !YANDEX_INJECTED || !KAKAO_INJECTED || !MAPILLARY_INJECTED || !MS_INJECTED || !MAPBOX_INJECTED) {
  3521. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  3522.  
  3523. if (isBullseye && (document.getElementById("player") == null))
  3524. {
  3525. BAIDU_INJECTED = false;
  3526. YANDEX_INJECTED = false;
  3527. KAKAO_INJECTED = false;
  3528. MAPILLARY_INJECTED = false;
  3529. MS_INJECTED = false;
  3530. MAPBOX_INJECTED = false;
  3531. initializeCanvas();
  3532. // document.querySelector(BULLSEYE_CANVAS).id = "player";
  3533. // injectContainer();
  3534. }
  3535. btnAll();
  3536. // console.log("wait");
  3537. // console.log([!YandexPlayer, !KakaoPlayer,!MapillaryPlayer,!MSStreetPlayer,!MapboxPlayer,!document.getElementById("i_container"),!YANDEX_INJECTED,!KAKAO_INJECTED,!MAPILLARY_INJECTED,!MS_INJECTED,!MAPBOX_INJECTED])
  3538. setTimeout(waitLoad, 250);
  3539. } else {
  3540. checkRound();
  3541. }
  3542. }
  3543.  
  3544. /**
  3545. * Checks for round changes
  3546. */
  3547.  
  3548. function checkRound() {
  3549. // console.log("Check Round");
  3550. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  3551. let switchCovergeButton = document.getElementById("switch");
  3552. if (!isBattleRoyale) {
  3553. // console.log("Check Round");
  3554. let currentRound = getRoundFromPage();
  3555. if (ROUND != currentRound) {
  3556. // fire1 = true;
  3557. switchCovergeButton.init = true;
  3558. console.log("New round");
  3559. ROUND = currentRound;
  3560. // NEW_ROUND_LOADED = true;
  3561. COMPASS = null;
  3562. locHistory = [];
  3563. wikiUrl = "";
  3564. one_reset = false;
  3565. getMapData();
  3566. // nextButtonCallback();
  3567. }
  3568. }
  3569. else {
  3570. getMapData();
  3571. }
  3572. }
  3573.  
  3574. /**
  3575. * Add listeners if buttons have been created
  3576. */
  3577.  
  3578. function finalDetail()
  3579. {
  3580. let target = document.querySelector("a[data-qa='play-same-map']");
  3581. if (target)
  3582. {
  3583. var div = document.createElement("div");
  3584. div.classList.add("buttons_buttons__0B3SB")
  3585. document.querySelector('.result-layout_content__jAHfP').appendChild(div);
  3586. for (var rd of linksList)
  3587. {
  3588. let str;
  3589. if (rd[1] == "Mapbox Satellite")
  3590. {
  3591. str = "Google Maps";
  3592. }
  3593. else
  3594. {
  3595. str = rd[1];
  3596. }
  3597. // console.log(rd)
  3598. let cl = target.cloneNode( true );
  3599. let tx = "View R" + rd[0] + " in " + str;
  3600. cl.querySelector('.button_label__kpJrA').innerHTML = tx;
  3601. cl.removeAttribute('data-qa');
  3602. cl.removeAttribute('href');
  3603. cl.urlStr = rd[2];
  3604. cl.addEventListener("click", (e) => {
  3605. window.open(cl.urlStr);
  3606. })
  3607. cl.style = "top:10px;right:-10px;";
  3608. div.appendChild(cl);
  3609. }
  3610. }
  3611. else
  3612. {
  3613. setTimeout(finalDetail, 500);
  3614. }
  3615. }
  3616.  
  3617. function nextButtonCallback()
  3618. {
  3619. let nextButton = document.querySelector("button[data-qa='close-round-result']");
  3620. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  3621. // if (nextButton != null && fire1)
  3622. // {
  3623. // fire1 = false;
  3624. nextButton.addEventListener("click", (e) => {
  3625.  
  3626. if (ROUND == 5)
  3627. {
  3628. console.log("Game Finished")
  3629. if (linksList)
  3630. {
  3631. finalDetail();
  3632. }
  3633. }
  3634. })
  3635. let urlStr = ""
  3636.  
  3637. if (nextPlayer !== "Google" && nextPlayer !== "Planets")
  3638. {
  3639. // console.log("Clone buttons");
  3640. let clone = document.querySelector("button[data-qa='close-round-result']").cloneNode( true );
  3641. let tx;
  3642. if (nextPlayer == "Mapbox Satellite")
  3643. {
  3644. tx = "View Location in Google Maps";
  3645. }
  3646. else
  3647. {
  3648. tx = "View Location in " + nextPlayer;
  3649. }
  3650. clone.querySelector('.button_label__kpJrA').innerHTML = tx;
  3651. clone.setAttribute('id', "LinkBtn");
  3652. clone.removeAttribute('data-qa');
  3653. if (nextPlayer == "Baidu")
  3654. {
  3655. urlStr = "https://map.baidu.com/?panotype=street&pid=" + global_BDID + "&panoid=" + global_BDID + "&from=api";
  3656. }
  3657. else if (nextPlayer == "Youtube")
  3658. {
  3659. urlStr = "https://www.youtube.com/watch?v=" + yId;
  3660. }
  3661. else if (nextPlayer == "Image")
  3662. {
  3663. urlStr = iId;
  3664. }
  3665. else if (nextPlayer == "Kakao")
  3666. {
  3667. urlStr = "https://map.kakao.com/link/roadview/" + global_lat + "," + global_lng;
  3668. }
  3669. else if (nextPlayer == "Mapillary")
  3670. {
  3671. urlStr = "https://www.mapillary.com/app/?pKey=" + mmKey + "&focus=photo";
  3672. }
  3673. else if (nextPlayer == "Yandex")
  3674. {
  3675. urlStr = "https://yandex.com/maps/?&panorama%5Bdirection%5D=16%2C0&panorama%5Bpoint%5D=" + global_lng + "%2C" + global_lat;
  3676. }
  3677. else if (nextPlayer == "Bing Streetside")
  3678. {
  3679. urlStr = "https://bing.com/maps/default.aspx?cp=" + global_lat + "~" + global_lng + "&lvl=20&style=r";
  3680. }
  3681. else if (nextPlayer == "Mapbox Satellite")
  3682. {
  3683. urlStr = `http://www.google.com/maps/place/${global_lat},${global_lng}`;
  3684. }
  3685. else if (nextPlayer == "Wikipedia")
  3686. {
  3687. urlStr = wikiUrl;
  3688. }
  3689. // IMPLEMENT WIKIPEDIA
  3690. clone.addEventListener("click", (e) => {
  3691. window.open(urlStr);
  3692. })
  3693. if (ROUND == 5)
  3694. {
  3695. clone.style = "top:10px;";
  3696. }
  3697. else
  3698. {
  3699. clone.style = "right:-10px;";
  3700. }
  3701. linksList.push([ROUND, nextPlayer, urlStr]);
  3702. document.querySelector('.round-result_actions__5j26U').appendChild(clone);
  3703. }
  3704. // }
  3705. // else
  3706. // {
  3707. // setTimeout(nextButtonCallback, 1000);
  3708. // }
  3709. }
  3710.  
  3711. function guessButtonCallback()
  3712. {
  3713. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  3714. let guessButton = document.querySelector("button[data-qa='perform-guess']");
  3715. let mainMenuBtn = document.getElementById("Show Buttons");
  3716. if (guessButton != null)
  3717. {
  3718.  
  3719. guessButton.addEventListener("click", (e) => {
  3720. if (mainMenuBtn != null)
  3721. {
  3722. console.log("try to hide show buttons")
  3723. mainMenuBtn.style.visibility = "hidden";
  3724. setHidden(true);
  3725. }
  3726. })
  3727. }
  3728. else
  3729. {
  3730. setTimeout(guessButtonCallback, 1000);
  3731. }
  3732. }
  3733.  
  3734. /**
  3735. * Load different streetview players
  3736. */
  3737.  
  3738. function loaderChecker(data)
  3739. {
  3740. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  3741.  
  3742. let substrings = ["Yandex", "Bing Streetside", "Kakao", "Mapbox", "Bing Satellite", "Planets"]
  3743. bullseyeMapillary = ((isBullseye || isLiveChallenge) && !["Mapillary", "A United World", "A Unity World", "Unity Test","Unity Special Edition"].some(v => data.includes(v)));
  3744. if (substrings.some(v => data.includes(v)) || rtded || bullseyeMapillary)
  3745. {
  3746. MapillaryPlayer = "MA";
  3747. MAPILLARY_INJECTED = true;
  3748.  
  3749. console.log("Not loading Mapillary");
  3750. }
  3751. else
  3752. {
  3753. BR_LOAD_MAPILLARY = true;
  3754. injectMapillaryPlayer();
  3755. }
  3756.  
  3757. if (data.includes("A United World") || data.includes("A Unity World") || data.includes("Unity Test") || data.includes("Unity Special Edition"))
  3758. {
  3759. console.log("Complete Map");
  3760. data = "Yandex Bing Streetside Kakao Mapbox";
  3761. }
  3762.  
  3763. if (data.includes("Yandex"))
  3764. {
  3765. console.log("Yandex Map");
  3766. if (data == "Yandex Bing Streetside Kakao Mapbox")
  3767. {
  3768. yandex_map = false;
  3769. }
  3770. else
  3771. {
  3772. yandex_map = true;
  3773. }
  3774. injectYandexScript().then(() => {
  3775. console.log("Ready to inject Yandex player");
  3776. injectYandexPlayer();
  3777. }).catch((error) => {
  3778. console.log(error);
  3779. });
  3780. BR_LOAD_YANDEX = true;
  3781. }
  3782. else
  3783. {
  3784. // console.log("Not Yandex map");
  3785. YANDEX_INJECTED = true;
  3786. YandexPlayer = "YD";
  3787. }
  3788.  
  3789. if (data.includes("Bing Streetside") || data.includes("Planets"))
  3790. {
  3791. console.log("Bing Map");
  3792. if (data.includes("Planets"))
  3793. {
  3794. let tempRad2;
  3795. tempRad2 = data.split("Planets")[1];
  3796. if (/\d/.test(tempRad2))
  3797. {
  3798. ms_radius = parseInt(tempRad2.replace(/\D/g,'')) * 1000;
  3799. }
  3800. bing_map = true;
  3801.  
  3802. for (let pl of spaceList)
  3803. {
  3804. if (data.includes(pl))
  3805. {
  3806. planetType = pl;
  3807. }
  3808. }
  3809. if (planetType == "Solar System")
  3810. {
  3811. randomPlanets = true;
  3812. }
  3813. console.log(planetType)
  3814. // else if (data.includes("GTA V"))
  3815. // {
  3816. // planetType = "GTAV";
  3817. // }
  3818. // else if (data.includes("GTA San Andreas"))
  3819. // {
  3820. // planetType = "GTASA";
  3821. // }
  3822.  
  3823. }
  3824. if (data == "Yandex Bing Streetside Kakao Mapbox")
  3825. {
  3826. bing_map = false;
  3827. }
  3828. injectMSPlayer();
  3829. // initBing = true;
  3830. BR_LOAD_MS = true;
  3831. }
  3832. else
  3833. {
  3834. // console.log("Not Bing map");
  3835. MS_INJECTED = true;
  3836. MSStreetPlayer = "MS";
  3837. }
  3838.  
  3839.  
  3840. let canvas = document.getElementById("sat_map");
  3841. if (data.includes("Bing Satellite") || data.includes("Mapbox") || data.includes("Unity Satellite") || (sat_choice && !rtded))
  3842. {
  3843. if (data == "Yandex Bing Streetside Kakao Mapbox")
  3844. {
  3845. ms_sat_map = false;
  3846. }
  3847. else
  3848. {
  3849. ms_sat_map = true;
  3850. }
  3851. let tempRad;
  3852. if (data.includes("Bing Satellite"))
  3853. {
  3854. tempRad = data.split("Bing Satellite")[1];
  3855. }
  3856. else if (data.includes("Mapbox"))
  3857. {
  3858. tempRad = data.split("Mapbox")[1];
  3859. }
  3860. else if (data.includes("Unity Satellite"))
  3861. {
  3862. tempRad = data.split("Unity Satellite")[1];
  3863. }
  3864.  
  3865.  
  3866. if (/\d/.test(tempRad))
  3867. {
  3868. ms_radius = parseInt(tempRad.replace(/\D/g,'')) * 1000;
  3869. }
  3870. console.log("Mapbox Satellite Map");
  3871. // console.log(canvas)
  3872.  
  3873. if (!canvas)
  3874. {
  3875. injectMapboxPlayer();
  3876. }
  3877. else
  3878. {
  3879. changeInnerHTML(canvas, false);
  3880. MAPBOX_INJECTED = true;
  3881. }
  3882. initBing = true;
  3883. BR_LOAD_MP = true;
  3884. }
  3885. else
  3886. {
  3887. if (canvas == null)
  3888. {
  3889. MapboxPlayer = "MP";
  3890. }
  3891. MAPBOX_INJECTED = true;
  3892. // console.log("Not Mapbox Satellite map");
  3893.  
  3894. }
  3895.  
  3896. if (data.includes("Kakao"))
  3897. {
  3898. console.log("Kakao Map");
  3899. if (data == "Yandex Bing Streetside Kakao Mapbox")
  3900. {
  3901. Kakao_map = false;
  3902. }
  3903. else
  3904. {
  3905. Kakao_map = true;
  3906. }
  3907. injectKakaoScript().then(() => {
  3908. console.log("Ready to inject Kakao player");
  3909. }).catch((error) => {
  3910. console.log(error);
  3911. });
  3912. BR_LOAD_KAKAO = true;
  3913. }
  3914. else{
  3915. KAKAO_INJECTED = true;
  3916. KakaoPlayer = "KK";
  3917. // console.log("Not Kakao map");
  3918. }
  3919.  
  3920. if (data.includes("Wikipedia"))
  3921. {
  3922. console.log("Wikipedia Map");
  3923. Wikipedia_map = true;
  3924.  
  3925. }
  3926. else{
  3927. // console.log("Not Wikipedia map");
  3928. }
  3929.  
  3930. if (data.includes("Minecraft"))
  3931. {
  3932. console.log("Minecraft Map");
  3933. Minecraft_map = true;
  3934.  
  3935. }
  3936. else{
  3937. // console.log("Not Minecraft map");
  3938. }
  3939.  
  3940.  
  3941.  
  3942.  
  3943. if (!data.includes("China Tips for each province"))
  3944. {
  3945. cn_tips = false;
  3946. document.getElementById("Show Buttons").style.visibility = "";
  3947. setHidden(false);
  3948. }
  3949. else
  3950. {
  3951. cn_tips = true;
  3952. guaranteeUI();
  3953. }
  3954.  
  3955.  
  3956.  
  3957. }
  3958.  
  3959. function loadPlayers() {
  3960. let mapBounds;
  3961. playerLoaded = true;
  3962. injectContainer();
  3963.  
  3964. getSeed().then((data) => {
  3965. // console.log(data)
  3966. let map_name = "Default"
  3967. if (typeof data.isRated !== 'undefined')
  3968. {
  3969. rtded = data.isRated;
  3970. }
  3971. if (typeof data.options !== 'undefined')
  3972. {
  3973. if (typeof data.options.isRated !== 'undefined')
  3974. {
  3975. rtded = data.options.isRated;
  3976. }
  3977. }
  3978. if (rtded)
  3979. {
  3980. map_name = "Public Game";
  3981. }
  3982. else
  3983. {
  3984. if (!isBattleRoyale)
  3985. {
  3986. mapBounds = [data.bounds.max.lat, data.bounds.max.lng, data.bounds.min.lat, data.bounds.min.lng];
  3987. map_name = data.mapName;
  3988. }
  3989. else
  3990. {
  3991. if (isBullseye)
  3992. {
  3993. mapBounds = [data.boundingBox.max.lat, data.boundingBox.max.lng, data.boundingBox.min.lat, data.boundingBox.min.lng];
  3994. map_name = data.mapName;
  3995. }
  3996. else if (isDuel)
  3997. {
  3998. mapBounds = [data.mapBounds.max.lat, data.mapBounds.max.lng, data.mapBounds.min.lat, data.mapBounds.min.lng];
  3999. map_name = data.options.map.name;
  4000. }
  4001. else if (isLiveChallenge)
  4002. {
  4003. mapBounds = [data.rounds[0].question.panoramaQuestionPayload.mapBounds.max.lat, data.rounds[0].question.panoramaQuestionPayload.mapBounds.max.lng,
  4004. data.rounds[0].question.panoramaQuestionPayload.mapBounds.min.lat, data.rounds[0].question.panoramaQuestionPayload.mapBounds.min.lng];
  4005. map_name = data.rounds[0].question.panoramaQuestionPayload.mapName;
  4006. }
  4007. else
  4008. {
  4009. map_name = "Unity Test";
  4010. }
  4011. }
  4012. }
  4013. if (mapBounds)
  4014. {
  4015. ms_radius = magic_formula(mapBounds);
  4016. // console.log(ms_radius / 1000)
  4017. }
  4018. loaderChecker(map_name)
  4019.  
  4020. }).catch((error) => {
  4021. console.log(error);
  4022. });
  4023.  
  4024. }
  4025.  
  4026. function guaranteeUI()
  4027. {
  4028. // console.log("UI")
  4029. if (document.getElementById("GH-ui") !== null)
  4030. {
  4031. document.getElementById("GH-ui").style.display = "block";
  4032. }
  4033. else
  4034. {
  4035. setTimeout(guaranteeUI, 500);
  4036. }
  4037. }
  4038.  
  4039. /**
  4040. * Handles Return to start and undo
  4041. */
  4042.  
  4043. function handleReturnToStart() {
  4044. let rtsButton = document.querySelector("button[data-qa='return-to-start']");
  4045. // console.log("Handle Return to start");
  4046. rtsButton.addEventListener("click", (e) => {
  4047. if (nextPlayer !== "Baidu")
  4048. {
  4049. goToLocation(true);
  4050. }
  4051. else
  4052. {
  4053. document.getElementById("i_container").src = "https://map.baidu.com/?panotype=street&pid=" + global_BDID + "&panoid=" + global_BDID + "&from=api";
  4054. }
  4055. const elementClicked = e.target;
  4056. elementClicked.setAttribute('listener', 'true');
  4057. console.log("Return to start");
  4058. });
  4059. guessButtonCallback();
  4060. // setTimeout(function () {goToLocation();}, 1000);
  4061. }
  4062.  
  4063. function handleUndo() {
  4064. let undoButton = document.querySelector("button[data-qa='undo-move']");
  4065. // console.log("Handle undo");
  4066. undoButton.addEventListener("click", (e) => {
  4067. if (locHistory.length > 0) {
  4068. goToUndoMove();
  4069. console.log("Undo Move");
  4070. }
  4071. })
  4072. }
  4073.  
  4074. /**
  4075. * Load game information
  4076. */
  4077.  
  4078. function satCallback()
  4079. {
  4080. if (typeof MapboxPlayer.flyTo !== typeof undefined)
  4081. {
  4082. goToLocation(false);
  4083. }
  4084. else
  4085. {
  4086. setTimeout(satCallback, 250);
  4087. }
  4088. }
  4089.  
  4090. function kakaoCallback()
  4091. {
  4092. console.log("Kakao callback")
  4093. if (typeof kakao.maps !== typeof undefined)
  4094. {
  4095. goToLocation(true);
  4096. setTimeout(function () {goToLocation(true);}, 3000);
  4097. }
  4098. else
  4099. {
  4100. setTimeout(kakaoCallback, 250);
  4101. }
  4102. }
  4103.  
  4104.  
  4105. function modularget(data)
  4106. {
  4107. if (data)
  4108. {
  4109. locationCheck(data);
  4110. if (nextPlayer == "Kakao")
  4111. {
  4112. kakaoCallback();
  4113. }
  4114. else
  4115. {
  4116. goToLocation(true);
  4117. }
  4118. // handleMinimapCallback();
  4119. handleButtons();
  4120. }
  4121. }
  4122.  
  4123. function getMapData() {
  4124. // myHighlight("Seed data");
  4125.  
  4126. getSeed().then((data) => {
  4127. let switchCovergeButton = document.getElementById("switch");
  4128. let mainMenuBtn = document.getElementById("Show Buttons")
  4129. if (isBattleRoyale) {
  4130. if (data.status == "Finished" || typeof data.gameId == typeof undefined) {
  4131. // console.log("Battle Royale Lobby");
  4132. }
  4133. else
  4134. {
  4135. let origin = false;
  4136. if (!CURRENT_ROUND_DATA) {
  4137. CURRENT_ROUND_DATA = data
  4138. origin = true;
  4139. }
  4140.  
  4141. if (origin || !(data.currentRoundNumber === CURRENT_ROUND_DATA.currentRoundNumber)) {
  4142. // myHighlight("Battle Royale New round");
  4143. switchCovergeButton.init = true;
  4144. // NEW_ROUND_LOADED = true;
  4145. COMPASS = null;
  4146. locHistory = [];
  4147. one_reset = false;
  4148. setHidden(false);
  4149. if (!origin) {
  4150. CURRENT_ROUND_DATA = data;
  4151. }
  4152. modularget(data);
  4153. }
  4154. }
  4155. }
  4156. else {
  4157. if (!cn_tips)
  4158. {
  4159. setHidden(false);
  4160. }
  4161. else
  4162. {
  4163. mainMenuBtn.style.visibility = "hidden";
  4164. AdjustBtnPos("14em", "0em", true);
  4165. }
  4166. modularget(data);
  4167. }
  4168.  
  4169. }).catch((error) => {
  4170. console.log(error);
  4171. });
  4172. }
  4173.  
  4174. function handleMinimapCallback()
  4175. {
  4176. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  4177. let MinimapBtn = document.getElementById("Minimap Button");
  4178. if (MinimapBtn)
  4179. {
  4180. let cur = MinimapBtn.current;
  4181. // console.log(cur)
  4182. for (let mapDiv of document.getElementsByClassName("preset-minimap")){
  4183. if (cur == mapDiv.id)
  4184. {
  4185. setTimeout(function () {mapDiv.click();}, 500);
  4186. setTimeout(function () {mapDiv.click();}, 1000);
  4187. setTimeout(function () {mapDiv.click();}, 3000);
  4188. }
  4189. }
  4190. }
  4191. else
  4192. {
  4193. setTimeout(handleMinimapCallback, 1000);
  4194. }
  4195. }
  4196.  
  4197. /**
  4198. * Hide unnecessary buttons for non-Google coverages
  4199. */
  4200.  
  4201. function handleButtons() {
  4202. let CHECKPOINT = document.querySelector("button[data-qa='set-checkpoint']");
  4203. let ZOOM_IN = document.querySelector("button[data-qa='pano-zoom-in']");
  4204. let ZOOM_OUT = document.querySelector("button[data-qa='pano-zoom-out']");
  4205. let UNDO_MOVE = document.querySelector("button[data-qa='undo-move']");
  4206. let DEFAULT_COMPASS = document.querySelector(".compass");
  4207. let NEW_COMPASS = document.querySelector(".panorama-compass_compassContainer__MEnh0");
  4208. let RETURN_TO_START = document.querySelector("button[data-qa='return-to-start']");
  4209.  
  4210. let C1 = (CHECKPOINT !== null);
  4211. let C2 = (ZOOM_IN !== null);
  4212. let C3 = (ZOOM_OUT !== null);
  4213. let C4 = (UNDO_MOVE !== null);
  4214. let C5 = (DEFAULT_COMPASS !== null);
  4215. let C6 = (NEW_COMPASS !== null);
  4216. let C7 = (RETURN_TO_START !== null);
  4217.  
  4218. let waitCond = C5 || C6;
  4219. let cpCond = true;
  4220. let comCond = true;
  4221. if (!NM)
  4222. {
  4223. cpCond = C1 && C4 && C7;
  4224. }
  4225. if (!NZ)
  4226. {
  4227. comCond = C2 && C3;
  4228. }
  4229.  
  4230. function moduleButtons(cond)
  4231. {
  4232.  
  4233. if (!NM)
  4234. {
  4235. CHECKPOINT.style.visibility = cond;
  4236. UNDO_MOVE.style.visibility = cond;
  4237. }
  4238. if (!NZ)
  4239. {
  4240. ZOOM_IN.style.visibility = cond;
  4241. ZOOM_OUT.style.visibility = cond;
  4242. }
  4243. if (C5)
  4244. {
  4245. DEFAULT_COMPASS.style.visibility = cond;
  4246. }
  4247. if (C6)
  4248. {
  4249. NEW_COMPASS.style.visibility = cond;
  4250. }
  4251. }
  4252.  
  4253. if (waitCond && cpCond && comCond)
  4254. {
  4255. // console.log("Handle Buttons");
  4256. if (nextPlayer === "Google" || nextPlayer === "Wikipedia") {
  4257. moduleButtons("");
  4258. }
  4259. else if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image" || nextPlayer === "Mapbox Satellite" || nextPlayer === "Minecraft" || nextPlayer === "Planets")
  4260. {
  4261. moduleButtons("hidden");
  4262. }
  4263. else if (nextPlayer === "Yandex" || nextPlayer === "Kakao" || nextPlayer === "Mapillary" || nextPlayer === "Bing Streetside")
  4264. {
  4265. moduleButtons("hidden");
  4266. if (nextPlayer === "Yandex" || nextPlayer === "Kakao" || nextPlayer === "Wikipedia")
  4267. {
  4268. if (C5)
  4269. {
  4270. DEFAULT_COMPASS.style.visibility = "";
  4271. }
  4272. if (C6)
  4273. {
  4274. NEW_COMPASS.style.visibility = "";
  4275. }
  4276. }
  4277. if (!NM)
  4278. {
  4279. UNDO_MOVE.style.visibility = "";
  4280. handleUndo();
  4281. }
  4282. }
  4283. if (!NM)
  4284. {
  4285. handleReturnToStart();
  4286. }
  4287. }
  4288. else
  4289. {
  4290. setTimeout(handleButtons, 250);
  4291. }
  4292. }
  4293.  
  4294. /**
  4295. * Check which player to use for the next location
  4296. */
  4297.  
  4298. function locationCheck(data) {
  4299. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  4300. let round;
  4301. let switchCovergeButton = document.getElementById("switch");
  4302. let satelliteSwitchButton = document.getElementById("Satellite Switch");
  4303. // console.log(data)
  4304.  
  4305. if (isBattleRoyale) {
  4306. if (isDuel || isBullseye)
  4307. {
  4308. round = data.rounds[data.currentRoundNumber - 1].panorama;
  4309. global_cc = round.countryCode;
  4310. }
  4311. else if (isLiveChallenge)
  4312. {
  4313. round = data.rounds[data.currentRoundNumber - 1].question.panoramaQuestionPayload.panorama;
  4314. global_cc = round.countryCode;
  4315. }
  4316. else
  4317. {
  4318. round = data.rounds[data.currentRoundNumber - 1];
  4319. global_cc = "us"; // No field available
  4320. }
  4321.  
  4322. }
  4323. else {
  4324. round = data.rounds[data.round - 1];
  4325. global_cc = round.streakLocationCode;
  4326. }
  4327.  
  4328. global_lat = round.lat;
  4329. global_lng = round.lng;
  4330. global_panoID = round.panoId;
  4331.  
  4332. global_heading = round.heading;
  4333. global_pitch = round.pitch;
  4334.  
  4335. // console.log(data);
  4336.  
  4337. // console.log(global_panoID);
  4338.  
  4339. nextPlayer = "Google";
  4340.  
  4341. // if (ms_sat_map)
  4342. // {
  4343. // nextPlayer = "Mapbox Satellite";
  4344. // }
  4345.  
  4346. if (global_panoID) {
  4347. let locInfo;
  4348. if (isBullseye)
  4349. {
  4350. locInfo = global_panoID;
  4351. }
  4352. else
  4353. {
  4354. locInfo = hex2a(global_panoID);
  4355. }
  4356. // console.log(locInfo)
  4357. if (locInfo.substring(0, 3) == "YTB")
  4358. {
  4359. nextPlayer = "Youtube";
  4360. let lengths = [3, 11, 4, 4];
  4361. let toPiece = lengths.map((p => i => locInfo.slice(p, p += i))(0));
  4362. let fullID = locInfo.substring(3).split('START');
  4363. yId = toPiece[1];
  4364. yTime = Number(toPiece[2]);
  4365. yEnd = Number(toPiece[3]);
  4366. }
  4367. else
  4368. {
  4369. let mapType = locInfo.substring(0, 5);
  4370.  
  4371. // panoId unchanged
  4372.  
  4373. if (mapType === "YDMAP" ) {
  4374. nextPlayer = "Yandex";
  4375. }
  4376. else if (mapType === "KKMAP" ) {
  4377. nextPlayer = "Kakao";
  4378. }
  4379.  
  4380. // New panoId formats
  4381.  
  4382. else if (mapType === "BAIDU" ) {
  4383. nextPlayer = "Baidu";
  4384. let lengths = [5, 7, 7, 3];
  4385. let toPiece = lengths.map((p => i => locInfo.slice(p, p += i))(0));
  4386. let panoId1 = base62.decode(toPiece[1]).toString().substring(1);
  4387. let panoId2 = base62.decode(toPiece[2]).toString().substring(1);
  4388. global_BDID = panoId1 + panoId2 + toPiece[3]
  4389. }
  4390. else if (mapType === "MAPIL")
  4391. {
  4392. nextPlayer = "Mapillary";
  4393. mmKey = locInfo.substring(5).replace(/\D/g,'');
  4394. }
  4395. else if (mapType === "IMAGE")
  4396. {
  4397. nextPlayer = "Image";
  4398. let lengths = [5, 4, 4, 7, 2];
  4399. let toPiece = lengths.map((p => i => locInfo.slice(p, p += i))(0));
  4400. iId = "https://i.ibb.co/" + toPiece[3] + "/" + toPiece[1] + "." + toPiece[2].replace(/[^0-9a-z]/gi, '')
  4401. }
  4402. else if (mapType.includes("BING")) {
  4403. if (mapType === "BINGM")
  4404. {
  4405. nextPlayer = "Bing Streetside";
  4406. }
  4407. else
  4408. {
  4409. nextPlayer = "Planets";
  4410. let num = mapType.slice(-1).charCodeAt(0) - 65;
  4411. planetType = spaceList[num];
  4412.  
  4413. ms_radius = parseInt(locInfo.substring(5).replace(/\D/g,'')) * 1000;
  4414. }
  4415. }
  4416. else if (mapType === "SATEL" ) {
  4417. nextPlayer = "Mapbox Satellite";
  4418. ms_radius = parseInt(locInfo.substring(5).replace(/\D/g,'')) * 1000;
  4419. }
  4420. else if (mapType === "MINEC" ) {
  4421. nextPlayer = "Minecraft";
  4422. }
  4423. else if (mapType === "WIKIP" ) {
  4424. nextPlayer = "Wikipedia";
  4425. }
  4426. else if (Kakao_map)
  4427. {
  4428. nextPlayer = "Kakao";
  4429. }
  4430. else if (yandex_map)
  4431. {
  4432. nextPlayer = "Yandex";
  4433. }
  4434. else if (Wikipedia_map)
  4435. {
  4436. nextPlayer = "Wikipedia";
  4437. }
  4438. else if (Minecraft_map)
  4439. {
  4440. nextPlayer = "Minecraft";
  4441. }
  4442. else if (bing_map)
  4443. {
  4444. nextPlayer = "Planets";
  4445. }
  4446. else
  4447. {
  4448. nextPlayer = "Google";
  4449. // GooglePlayer.setPano(locInfo);
  4450. }
  4451. }
  4452. }
  4453. else
  4454. {
  4455. if (Kakao_map)
  4456. {
  4457. nextPlayer = "Kakao";
  4458. }
  4459. else if (yandex_map)
  4460. {
  4461. nextPlayer = "Yandex";
  4462. }
  4463. else if (Wikipedia_map)
  4464. {
  4465. nextPlayer = "Wikipedia";
  4466. }
  4467. else if (Minecraft_map)
  4468. {
  4469. nextPlayer = "Minecraft";
  4470. }
  4471. else if (bing_map)
  4472. {
  4473. nextPlayer = "Planets";
  4474. }
  4475. else
  4476. {
  4477. nextPlayer = "Google";
  4478. }
  4479. }
  4480.  
  4481.  
  4482. // if ( krCoordinates[0] > global_lat && krCoordinates[2] < global_lat && krCoordinates[1] < global_lng && krCoordinates[3] > global_lng)
  4483. // {
  4484. // nextSecondaryPlayer = "Kakao";
  4485. // }
  4486. // else if (nextPlayer = "Mapillary")
  4487. // {
  4488. // nextSecondaryPlayer = "Google";
  4489. // }
  4490. // else
  4491. // {
  4492. // nextSecondaryPlayer = "Mapillary";
  4493. // }
  4494.  
  4495. // Disable buttons if NM, NMPZ
  4496.  
  4497. if(!isBattleRoyale)
  4498. {
  4499. NM = data.forbidMoving;
  4500. NP = data.forbidRotating;
  4501. NZ = data.forbidZooming;
  4502. }
  4503. else
  4504. {
  4505. // console.log(data)
  4506. if (isBullseye || isLiveChallenge)
  4507. {
  4508. NM = data.options.movementOptions.forbidMoving;
  4509. NP = data.options.movementOptions.forbidRotating;
  4510. NZ = data.options.movementOptions.forbidZooming;
  4511. }
  4512. else
  4513. {
  4514. NM = data.movementOptions.forbidMoving;
  4515. NP = data.movementOptions.forbidRotating;
  4516. NZ = data.movementOptions.forbidZooming;
  4517. }
  4518. }
  4519. if (NM || NP || NZ)
  4520. {
  4521. setDisable("NMPZ");
  4522. }
  4523. else
  4524. {
  4525. setDisable(nextPlayer);
  4526. }
  4527.  
  4528. if (nextPlayer == "Google")
  4529. {
  4530. switchCovergeButton.innerHTML = "Switch to Mapillary";
  4531. }
  4532. else
  4533. {
  4534. switchCovergeButton.innerHTML = "Switch to Google Streetview";
  4535. }
  4536. nextPlayer_save = nextPlayer;
  4537.  
  4538.  
  4539. // console.log("??")
  4540. // console.log(sessionStorage.getItem('Satellite') == "T")
  4541. // console.log(ms_sat_map)
  4542. if (ms_sat_map || (sat_choice && nextPlayer !== "Baidu" && !rtded))
  4543. {
  4544. nextPlayer = "Mapbox Satellite";
  4545. }
  4546.  
  4547. if (nextPlayer == "Mapbox Satellite")
  4548. {
  4549. let di3 = formatDist();
  4550. satelliteSwitchButton.innerHTML = `Satellite (${di3})`;
  4551. }
  4552. else
  4553. {
  4554. satelliteSwitchButton.innerHTML = "Streetview mode";
  4555. }
  4556. console.log(nextPlayer_save + "," + nextPlayer);
  4557. if (!rtded)
  4558. {
  4559. injectCanvas();
  4560. }
  4561. else
  4562. {
  4563. console.log("rated game, no canvas injection");
  4564. }
  4565. }
  4566.  
  4567.  
  4568. /**
  4569. * setID for canvas
  4570. */
  4571.  
  4572. function initializeCanvas() {
  4573. GAME_CANVAS = "";
  4574. DUEL_CANVAS = "";
  4575. //console.log("Is duels");
  4576. //console.log(duels);
  4577.  
  4578. if (isBattleRoyale) {
  4579. if (isDuel) {
  4580. GAME_CANVAS = document.querySelector(DUELS_CANVAS);
  4581. DUEL_CANVAS = document.querySelector(DUELS_CANVAS2);
  4582. }
  4583. else if (isBullseye) {
  4584. GAME_CANVAS = document.querySelector(BULLSEYE_CANVAS);
  4585. DUEL_CANVAS = "dummy";
  4586. }
  4587. else if (isLiveChallenge)
  4588. {
  4589. GAME_CANVAS = document.querySelector(LIVE_CANVAS);
  4590. DUEL_CANVAS = "dummy";
  4591. }
  4592. else
  4593. {
  4594. GAME_CANVAS = document.querySelector(BR_WRAPPER);
  4595. DUEL_CANVAS = "dummy";
  4596. }
  4597. }
  4598. else {
  4599. GAME_CANVAS = document.querySelector(GENERAL_LAYOUT);
  4600. DUEL_CANVAS = "dummy";
  4601. }
  4602. if (GAME_CANVAS && DUEL_CANVAS)
  4603. {
  4604. console.log("Canvas injected");
  4605. GAME_CANVAS.id = "player";
  4606.  
  4607.  
  4608.  
  4609. if (isDuel) {
  4610. DUEL_CANVAS.id = "default_player";
  4611. }
  4612.  
  4613. let mosaicBtn = document.getElementById("Mosaic Enable");
  4614. if (mosaicBtn)
  4615. {
  4616. loadGridBtn(mosaicBtn.grid);
  4617. }
  4618.  
  4619. partialCreateMapillary = (typeof mapillary !== typeof undefined)
  4620. partialCreateYandex = (typeof ymaps !== typeof undefined)
  4621. partialCreateKakao = (typeof kakao !== typeof undefined)
  4622. partialCreateMS = (typeof Microsoft !== typeof undefined);
  4623. partialCreateMapbox = (typeof mapboxgl !== typeof undefined);
  4624. loadPlayers();
  4625.  
  4626.  
  4627. }
  4628. else
  4629. {
  4630. setTimeout(initializeCanvas, 250);
  4631. }
  4632.  
  4633. }
  4634.  
  4635. /**
  4636. * Hide or show players based on where the next location is
  4637. */
  4638.  
  4639. function injectCanvas() {
  4640. if (isDuel)
  4641. {
  4642. if (!rtded)
  4643. {
  4644. canvasSwitch();
  4645. }
  4646. }
  4647. else
  4648. {
  4649. Google();
  4650. Baidu();
  4651. if (BR_LOAD_KAKAO)
  4652. {
  4653. Kakao();
  4654. }
  4655. if (BR_LOAD_YANDEX)
  4656. {
  4657. Yandex();
  4658. }
  4659. if (BR_LOAD_MS)
  4660. {
  4661. // console.log("Yes")
  4662. Bing();
  4663. }
  4664. if (BR_LOAD_MP)
  4665. {
  4666. // console.log("Yes")
  4667. Mapbox();
  4668. }
  4669. if (BR_LOAD_MAPILLARY)
  4670. {
  4671. Mapillary();
  4672. }
  4673. }
  4674.  
  4675. }
  4676.  
  4677. // for duels (class ID change)
  4678.  
  4679. function canvasSwitch()
  4680. {
  4681.  
  4682. // console.log("canvas switch")
  4683. // let cond = true;
  4684. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  4685. let teleportMenu = document.getElementById("Teleport Button");
  4686. let switchCovergeButton = document.getElementById("switch");
  4687.  
  4688. let GOOGLE_MAPS_CANVAS = document.querySelector(DUELS_CANVAS);
  4689. let BAIDU_MAPS_CANVAS = document.getElementById("i_container");
  4690. let KAKAO_MAPS_CANVAS = document.getElementById("roadview");
  4691. let YANDEX_MAPS_CANVAS = document.querySelector(".ymaps-2-1-79-panorama-screen");
  4692. let BING_MAPS_CANVAS = document.getElementById("ms-player");
  4693. let MAPILLARY_MAPS_CANVAS = document.getElementById("mapillary-player");
  4694. let MAPBOX_MAPS_CANVAS = document.getElementById("mapbox-player");
  4695. // console.log([GOOGLE_MAPS_CANVAS, BAIDU_MAPS_CANVAS, MAPILLARY_MAPS_CANVAS, BR_LOAD_KAKAO, KAKAO_MAPS_CANVAS, BR_LOAD_MS, BING_MAPS_CANVAS, BR_LOAD_YANDEX, YANDEX_MAPS_CANVAS])
  4696.  
  4697. if (GOOGLE_MAPS_CANVAS && BAIDU_MAPS_CANVAS && (!BR_LOAD_MAPILLARY || MAPILLARY_MAPS_CANVAS) && (!BR_LOAD_KAKAO || KAKAO_MAPS_CANVAS) &&
  4698. (!BR_LOAD_MS || BING_MAPS_CANVAS) && (!BR_LOAD_YANDEX || YANDEX_MAPS_CANVAS) && (!BR_LOAD_MP || MAPBOX_MAPS_CANVAS))
  4699. {
  4700. document.getElementById("default_player").style.position = "absolute";
  4701. document.getElementById("default_player").className = "inactive";
  4702. BAIDU_MAPS_CANVAS.style.position = "absolute";
  4703. BAIDU_MAPS_CANVAS.className = "inactive";
  4704. BAIDU_MAPS_CANVAS.visibility = "hidden";
  4705.  
  4706. if (BR_LOAD_MAPILLARY)
  4707. {
  4708. MAPILLARY_MAPS_CANVAS.style.visibility = "hidden";
  4709. MAPILLARY_MAPS_CANVAS.style.position = "absolute";
  4710. MAPILLARY_MAPS_CANVAS.className = "inactive";
  4711. }
  4712.  
  4713. if (BR_LOAD_KAKAO)
  4714. {
  4715. KAKAO_MAPS_CANVAS.style.visibility = "hidden";
  4716. KAKAO_MAPS_CANVAS.style.position = "absolute";
  4717. KAKAO_MAPS_CANVAS.className = "inactive";
  4718. }
  4719. if (BR_LOAD_YANDEX)
  4720. {
  4721. YANDEX_MAPS_CANVAS.style.visibility = "hidden";
  4722. YANDEX_MAPS_CANVAS.style.position = "absolute";
  4723. }
  4724. if (BR_LOAD_MS)
  4725. {
  4726. BING_MAPS_CANVAS.style.visibility = "hidden";
  4727. BING_MAPS_CANVAS.style.position = "absolute";
  4728. BING_MAPS_CANVAS.className = "inactive";
  4729. }
  4730.  
  4731. if (BR_LOAD_MP)
  4732. {
  4733. MAPBOX_MAPS_CANVAS.style.visibility = "hidden";
  4734. MAPBOX_MAPS_CANVAS.style.position = "absolute";
  4735. MAPBOX_MAPS_CANVAS.classList.remove("game-panorama_panorama__rdhFg")
  4736. MAPBOX_MAPS_CANVAS.classList.add("inactive");
  4737. }
  4738.  
  4739. teleportMenu.google = false;
  4740. switchCovergeButton.useGoogle = false;
  4741.  
  4742. if (nextPlayer === "Google") {
  4743. document.getElementById("default_player").className = "game-panorama_panoramaCanvas__PNKve";
  4744. if (BR_LOAD_KAKAO)
  4745. {
  4746. //console.log("doing")
  4747. window.dispatchEvent(new Event('resize'));
  4748. }
  4749. document.getElementById("default_player").visibility = "";
  4750. teleportMenu.google = true;
  4751. switchCovergeButton.useGoogle = true;
  4752. console.log("Google Duel Canvas loaded");
  4753. }
  4754. else if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image" || nextPlayer === "Wikipedia" || nextPlayer === "Minecraft")
  4755. {
  4756. BAIDU_MAPS_CANVAS.visibility = "";
  4757. BAIDU_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  4758. console.log("Container Duel Canvas loaded");
  4759. }
  4760. else if (nextPlayer === "Kakao")
  4761. {
  4762. if (BR_LOAD_KAKAO)
  4763. {
  4764. KAKAO_MAPS_CANVAS.style.visibility = "";
  4765. KAKAO_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  4766. }
  4767. console.log("Kakao Duel Canvas loaded");
  4768. }
  4769. else if (nextPlayer === "Yandex")
  4770. {
  4771. if (BR_LOAD_YANDEX)
  4772. {
  4773. YANDEX_MAPS_CANVAS.style.visibility = "";
  4774. }
  4775. console.log("Yandex Duel Canvas loaded");
  4776. }
  4777. else if (nextPlayer === "Mapillary")
  4778. {
  4779. if (BR_LOAD_MAPILLARY)
  4780. {
  4781. MAPILLARY_MAPS_CANVAS.style.visibility = "";
  4782. MAPILLARY_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  4783. MapillaryPlayer.resize();
  4784. }
  4785. //
  4786. console.log("Mapillary Duel Canvas loaded");
  4787. }
  4788. else if (nextPlayer === "Bing Streetside" || nextPlayer === "Planets")
  4789. {
  4790. if (BR_LOAD_MS)
  4791. {
  4792. BING_MAPS_CANVAS.style.visibility = "";
  4793. BING_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  4794. }
  4795. console.log("MS Duel Canvas loaded");
  4796. }
  4797. else if (nextPlayer === "Mapbox Satellite")
  4798. {
  4799. if (BR_LOAD_MP)
  4800. {
  4801. MAPBOX_MAPS_CANVAS.style.visibility = "";
  4802. MAPBOX_MAPS_CANVAS.classList.remove("inactive");
  4803. MAPBOX_MAPS_CANVAS.classList.add("game-panorama_panorama__rdhFg");
  4804. try
  4805. {
  4806. MapboxPlayer.resize();
  4807. }
  4808. catch (e)
  4809. {
  4810. console.error("MapboxPlayer resize failed", e);
  4811. }
  4812. }
  4813. console.log("Mapbox Satellite Duel Canvas loaded");
  4814. }
  4815. }
  4816. else
  4817. {
  4818. setTimeout(canvasSwitch(), 1000);
  4819. }
  4820. }
  4821.  
  4822. // for Battle Royale and classic (change visibility)
  4823.  
  4824. function gCanvas()
  4825. {
  4826. let GOOGLE_MAPS_CANVAS = ""
  4827. if (isBattleRoyale) {
  4828. if (isBullseye)
  4829. {
  4830. GOOGLE_MAPS_CANVAS = document.querySelector(BULLSEYE_CANVAS2);
  4831. }
  4832. else if (isLiveChallenge)
  4833. {
  4834. GOOGLE_MAPS_CANVAS = document.querySelector(LIVE_CANVAS2);
  4835. }
  4836. else
  4837. {
  4838. GOOGLE_MAPS_CANVAS = document.querySelector(BR_CANVAS);
  4839. }
  4840. }
  4841. else {
  4842. GOOGLE_MAPS_CANVAS = document.querySelector(GENERAL_CANVAS);
  4843. }
  4844. return GOOGLE_MAPS_CANVAS;
  4845. }
  4846.  
  4847. function Google() {
  4848. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  4849. let teleportMenu = document.getElementById("Teleport Button");
  4850. let switchCovergeButton = document.getElementById("switch");
  4851.  
  4852. let GOOGLE_MAPS_CANVAS = gCanvas();
  4853.  
  4854. if (GOOGLE_MAPS_CANVAS !== null)
  4855. {
  4856. if (nextPlayer === "Google") {
  4857. GOOGLE_MAPS_CANVAS.style.visibility = "";
  4858. teleportMenu.google = true;
  4859. switchCovergeButton.useGoogle = true;
  4860. }
  4861. else {
  4862. GOOGLE_MAPS_CANVAS.style.visibility = "hidden";
  4863. teleportMenu.google = false;
  4864. }
  4865. }
  4866. else
  4867. {
  4868. setTimeout(Google, 250);
  4869. }
  4870. }
  4871.  
  4872. function Baidu() {
  4873. let BAIDU_MAPS_CANVAS = document.getElementById("i_container");
  4874. let switchCovergeButton = document.getElementById("switch");
  4875. // console.log("Baidu canvas");
  4876. if (BAIDU_MAPS_CANVAS !== null)
  4877. {
  4878. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  4879. BAIDU_MAPS_CANVAS.style.position = "absolute";
  4880. if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image" || nextPlayer === "Wikipedia" || nextPlayer === "Minecraft") {
  4881. BAIDU_MAPS_CANVAS.style.visibility = "";
  4882. switchCovergeButton.useGoogle = false;
  4883. console.log("Container Canvas loaded");
  4884. }
  4885. else {
  4886. BAIDU_MAPS_CANVAS.style.visibility = "hidden";
  4887. // console.log("Container Canvas hidden");
  4888. }
  4889. }
  4890. else
  4891. {
  4892. setTimeout(Baidu, 250);
  4893. }
  4894.  
  4895. }
  4896.  
  4897. function Kakao() {
  4898. let KAKAO_MAPS_CANVAS = document.getElementById("roadview");
  4899. let switchCovergeButton = document.getElementById("switch");
  4900. // console.log("Kakao canvas");
  4901. if (KAKAO_MAPS_CANVAS != null)
  4902. {
  4903. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  4904. KAKAO_MAPS_CANVAS.style.position = "absolute";
  4905. if (nextPlayer === "Kakao") {
  4906. KAKAO_MAPS_CANVAS.style.visibility = "";
  4907. switchCovergeButton.useGoogle = false;
  4908. console.log("Kakao Canvas loaded");
  4909. }
  4910. else {
  4911. KAKAO_MAPS_CANVAS.style.visibility = "hidden";
  4912. // console.log("Kakao Canvas hidden");
  4913. }
  4914. }
  4915. else
  4916. {
  4917. setTimeout(Kakao, 250);
  4918. }
  4919.  
  4920. }
  4921.  
  4922. function Yandex() {
  4923. let YANDEX_MAPS_CANVAS = document.querySelector(".ymaps-2-1-79-panorama-screen");
  4924. let switchCovergeButton = document.getElementById("switch");
  4925. if (YANDEX_MAPS_CANVAS != null)
  4926. {
  4927. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  4928. if (isBullseye)
  4929. {
  4930. let div = document.getElementById("player");
  4931. YANDEX_MAPS_CANVAS.classList.add("game-panorama_panorama__ncMwh");
  4932. div.prepend(YANDEX_MAPS_CANVAS);
  4933. }
  4934. if (isLiveChallenge)
  4935. {
  4936. let div = document.getElementById("player");
  4937. YANDEX_MAPS_CANVAS.classList.add("game-panorama_panorama__Qpsxl");
  4938. div.prepend(YANDEX_MAPS_CANVAS);
  4939. }
  4940. // console.log("Yandex canvas");
  4941. document.querySelector(".ymaps-2-1-79-panorama-screen").style.position = "absolute";
  4942. // console.log("Yandex canvas");
  4943. /* console.log(YANDEX_MAPS_CANVAS); */
  4944. if (nextPlayer === "Yandex") {
  4945. YANDEX_MAPS_CANVAS.style.visibility = "";
  4946. switchCovergeButton.useGoogle = false;
  4947. console.log("Yandex Canvas loaded");
  4948. }
  4949. else {
  4950. YANDEX_MAPS_CANVAS.style.visibility = "hidden";
  4951. console.log("Yandex Canvas hidden");
  4952. }
  4953. }
  4954. else
  4955. {
  4956. setTimeout(Yandex, 250);
  4957. }
  4958.  
  4959. }
  4960.  
  4961. function Mapillary()
  4962. {
  4963. let MAPILLARY_MAPS_CANVAS = document.getElementById("mapillary-player");
  4964. let switchCovergeButton = document.getElementById("switch");
  4965. if (MAPILLARY_MAPS_CANVAS != null)
  4966. {
  4967. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  4968. // console.log("Mapillary canvas");
  4969. MAPILLARY_MAPS_CANVAS.style.position = "absolute";
  4970. if (nextPlayer === "Mapillary") {
  4971. MAPILLARY_MAPS_CANVAS.style.visibility = "";
  4972. switchCovergeButton.useGoogle = false;
  4973. console.log("Mapillary Canvas loaded");
  4974.  
  4975. }
  4976. else {
  4977. MAPILLARY_MAPS_CANVAS.style.visibility = "hidden";
  4978. // console.log("Mapillary Canvas hidden");
  4979. }
  4980. }
  4981. else
  4982. {
  4983. setTimeout(Mapillary, 250);
  4984. }
  4985.  
  4986. }
  4987.  
  4988. function Bing() {
  4989. let BING_MAPS_CANVAS = document.getElementById("ms-player");
  4990. let switchCovergeButton = document.getElementById("switch");
  4991. // console.log("stuck")
  4992. if (BING_MAPS_CANVAS != null)
  4993. {
  4994. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  4995. // console.log("Mapillary canvas");
  4996. BING_MAPS_CANVAS.style.position = "absolute";
  4997. if (nextPlayer === "Bing Streetside" || nextPlayer === "Planets") {
  4998. BING_MAPS_CANVAS.style.visibility = "";
  4999. switchCovergeButton.useGoogle = false;
  5000. console.log("Bing Canvas loaded");
  5001. }
  5002. else {
  5003. BING_MAPS_CANVAS.style.visibility = "hidden";
  5004. console.log("Bing Canvas hidden");
  5005. }
  5006. }
  5007. else
  5008. {
  5009. setTimeout(Bing, 500)
  5010. }
  5011. }
  5012.  
  5013. function Mapbox()
  5014. {
  5015. let MAPBOX_CANVAS = document.getElementById("mapbox-player");
  5016. let switchCovergeButton = document.getElementById("switch");
  5017. if (MAPBOX_CANVAS != null)
  5018. {
  5019. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  5020. // console.log("Mapillary canvas");
  5021. MAPBOX_CANVAS.style.position = "absolute";
  5022. if (nextPlayer === "Mapbox Satellite") {
  5023. MAPBOX_CANVAS.style.visibility = "";
  5024. switchCovergeButton.useGoogle = false;
  5025. console.log("Mapbox Satellite Canvas loaded");
  5026.  
  5027. }
  5028. else {
  5029. MAPBOX_CANVAS.style.visibility = "hidden";
  5030. // console.log("Mapillary Canvas hidden");
  5031. }
  5032. }
  5033. else
  5034. {
  5035. setTimeout(Mapbox, 250);
  5036. }
  5037.  
  5038. }
  5039.  
  5040.  
  5041. /**
  5042. * Adjust button placement
  5043. */
  5044.  
  5045. function ZoomControls() {
  5046. let style = `
  5047. .ymaps-2-1-79-panorama-gotoymaps {display: none !important;}
  5048. .ymaps-2-1-79-panorama-control__zoom {top: 2rem !important; left: 2rem !important; z-Index: 0}
  5049. .mapillary-bearing-indicator-container {top: 2rem !important; left: 2rem !important;}
  5050. .mapillary-zoom-container {top: 6rem !important; left: 2.20rem !important;}
  5051. .NavBar_MapTypeButtonContainerWrapper {visibility: hidden !important;}
  5052. .bm_LocateMeControl {visibility: hidden !important;}
  5053. .NavBar_Container {top: -6rem !important; left: 2rem !important;}
  5054. .streetsideToolPanel {top: 4rem !important; left: 2rem !important;}
  5055. .NavBarButton_Container {visibility: hidden !important;}
  5056. .mapboxgl-ctrl-top-left {z-Index: 999}
  5057. `;
  5058.  
  5059. // let nav = document.querySelector('.NavBar_MapTypeButtonContainerWrapper');
  5060. // let locate = document.getElementById("LocateMeButton");
  5061. // let navAll = document.getElementById("MicrosoftNav");
  5062. // if (nav)
  5063. // {
  5064. // nav.style.visibility = "hidden";
  5065. // }
  5066. // if (locate)
  5067. // {
  5068. // locate.style.visibility = "hidden";
  5069. // }
  5070. // if (navAll)
  5071. // {
  5072. // navAll.style.top = "15em"
  5073. // }
  5074.  
  5075. let style_element = document.createElement("style");
  5076. style_element.innerHTML = style;
  5077. document.body.appendChild(style_element);
  5078. // document.getElementById("mapillary-bearing-indicator-container").style.top = "20em"
  5079. }
  5080.  
  5081. /**
  5082. * Updates the compass to match Yandex Panorama facing
  5083. */
  5084. function updateCompass() {
  5085. if (!COMPASS) {
  5086. let compass = document.querySelector("img.compass__indicator");
  5087. if (compass != null) {
  5088. COMPASS = compass;
  5089. let direction = YandexPlayer.getDirection()[0] * -1;
  5090. COMPASS.setAttribute("style", `transform: rotate(${direction}deg);`);
  5091. }
  5092. }
  5093. else {
  5094. let direction = YandexPlayer.getDirection()[0] * -1;
  5095. COMPASS.setAttribute("style", `transform: rotate(${direction}deg);`);
  5096. }
  5097. }
  5098.  
  5099. /**
  5100. * Open next location in streetview player given next player and next coordinate
  5101. */
  5102.  
  5103. function wiki(cc, iframe, teleportMenu)
  5104. {
  5105. let url = `https://${cc}.wikipedia.org/w/api.php`;
  5106. let widthRight = 325;
  5107. // console.log(cc);
  5108. // if (cc == "fr")
  5109. // {
  5110. // widthRight = 1200;
  5111. // }
  5112.  
  5113. let params = {
  5114. action: "query",
  5115. list: "geosearch",
  5116. gscoord: `${global_lat}|${global_lng}`,
  5117. gsradius: "10000",
  5118. gslimit: "1",
  5119. format: "json"
  5120. };
  5121.  
  5122. url = url + "?origin=*";
  5123. Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];});
  5124. let GOOGLE_MAPS_CANVAS = gCanvas();
  5125.  
  5126. fetch(url)
  5127. .then(function(response){return response.json();})
  5128. .then(function(response) {
  5129. // console.log(response)
  5130. var pages = response.query.geosearch;
  5131. if (pages.length !== 0)
  5132. {
  5133. GOOGLE_MAPS_CANVAS.style.visibility = "hidden";
  5134. let pageId = pages[0].pageid;
  5135. iframe.src = `https://${cc}.wikipedia.org/?curid=${pageId}`;
  5136. wikiUrl = `https://${cc}.wikipedia.org/?curid=${pageId}`;
  5137. iframe.style.visibility = "";
  5138. iframe.style.right = `-${widthRight}px`;
  5139. iframe.style.width = (window.innerWidth + widthRight) + 'px';
  5140.  
  5141. // console.log(iframe.style.width);
  5142. // iframe.style.visibility = "";
  5143. }
  5144. else
  5145. {
  5146. GOOGLE_MAPS_CANVAS.style.visibility = "";
  5147. teleportMenu.google = true;
  5148. iframe.style.right = '0px';
  5149. iframe.style.width = window.innerWidth + 'px';
  5150. }
  5151. }).catch(function(error){console.log(error);});
  5152. }
  5153.  
  5154.  
  5155.  
  5156. function goToLocation(cond) {
  5157. let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  5158. console.log("Going to location");
  5159. console.log(nextPlayer);
  5160.  
  5161. let mosaicBtn = document.getElementById("Mosaic Enable");
  5162. if (mosaicBtn)
  5163. {
  5164. if (mosaicBtn.grid !== 0)
  5165. {
  5166. document.getElementById("Mosaic Menu").click();
  5167. }
  5168. loadGridBtn(mosaicBtn.grid);
  5169. }
  5170.  
  5171. let OverlayBtn = document.getElementById("Overlay Button");
  5172. if (nextPlayer !== "Planets" && (spaceList.some(className => OverlayBtn.current.includes(className))))
  5173. {
  5174. document.getElementById("Earth").click();
  5175. }
  5176.  
  5177. if (nextPlayer === "Yandex") {
  5178. let options = {};
  5179. YandexPlayer.moveTo([global_lat, global_lng], options);
  5180. YandexPlayer.setDirection([0, 16]);
  5181. YandexPlayer.setSpan([10, 67]);
  5182. }
  5183. else if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image" || nextPlayer === "Wikipedia" || nextPlayer === "Minecraft") {
  5184. if (document.getElementById("i_container") !== null)
  5185. {
  5186. let iframe = document.getElementById("i_container");
  5187.  
  5188. if (nextPlayer === "Baidu")
  5189. {
  5190. if (!isFirefox)
  5191. {
  5192. iframe.style.top = '-60px';
  5193. iframe.style.height = (window.innerHeight + 200) + 'px';
  5194. }
  5195. else
  5196. {
  5197. iframe.style.top = '-60px';
  5198. iframe.style.height = (window.innerHeight + 219) + 'px';
  5199. }
  5200.  
  5201. if (!isFirefox)
  5202. {
  5203. iframe.style.right = '-55px';
  5204. iframe.style.width = (window.innerWidth + 55) + 'px';
  5205. }
  5206. else
  5207. {
  5208. iframe.style.right = '-15px';
  5209. iframe.style.width = (window.innerWidth + 15) + 'px';
  5210. }
  5211. let urlStr2 = "https://map.baidu.com/?panotype=street&pid=" + global_BDID + "&panoid=" + global_BDID + "&from=api";
  5212. let urlStr = "https://map.baidu.com/@" + global_BDAh + "," + global_BDBh + "#panoid=" + global_BDID + "&panotype=street&l=12&tn=B_NORMAL_MAP&sc=0&newmap=1&shareurl=1&pid=" + global_BDID;
  5213. // console.log(urlStr)
  5214. if (global_BDAh != null)
  5215. {
  5216. iframe.src = urlStr;
  5217. }
  5218. else
  5219. {
  5220. iframe.src = urlStr2;
  5221. }
  5222. iframe.style.visibility = "";
  5223. }
  5224. else if (nextPlayer === "Youtube")
  5225. {
  5226. document.getElementById("Youtube Button").style.visibility = "";
  5227. document.getElementById("Youtube Button").innerHTML = "Play video";
  5228. iframe.allow = "autoplay";
  5229. iframe.style.visibility = "hidden";
  5230. iframe.style.top = '-60px';
  5231. iframe.style.height = (window.innerHeight + 235) + 'px';
  5232. iframe.style.right = '0px';
  5233. iframe.style.width = window.innerWidth + 'px';
  5234. mainMenuBtn.innerHTML = "<font size=2>Unity<br><font size=1>v6.3.0</font>";
  5235. mainMenuBtn.style.width = "3em"
  5236. mainMenuBtn.style.backgroundPosition = "";
  5237. mainMenuBtn.backgroundColor = ""
  5238. }
  5239. else if (nextPlayer === "Image")
  5240. {
  5241. iframe.style.top = '0px';
  5242. iframe.style.height = (window.innerHeight) + 'px';
  5243. iframe.style.right = '0px';
  5244. iframe.style.width = window.innerWidth + 'px';
  5245. iframe.style.visibility = "";
  5246. iframe.src = iId;
  5247. }
  5248. else if (nextPlayer === "Wikipedia")
  5249. {
  5250. if (!document.getElementById("mapbox-player"))
  5251. {
  5252. switchCovergeButton.style.visibility = "";
  5253. }
  5254. switchCovergeButton.disabled = false;
  5255. let wikiLocalLang = document.getElementById("local language")
  5256. wikiLocalLang.style.visibility = "";
  5257. switchCovergeButton.style.backgroundColor = "#ba55d3";
  5258. iframe.style.top = '0px';
  5259. iframe.style.height = (window.innerHeight) + 'px';
  5260. let fi = "en";
  5261. if (!wikiLocalLang.state && global_cc)
  5262. {
  5263. let cc = langDict[global_cc];
  5264. if (typeof cc !== typeof undefined)
  5265. {
  5266. fi = cc[Math.floor(Math.random() * cc.length)];
  5267. }
  5268. }
  5269. wiki(fi, iframe, teleportMenu);
  5270. }
  5271. else if (nextPlayer === "Minecraft")
  5272. {
  5273. iframe.style.top = '0px';
  5274. iframe.style.height = (window.innerHeight) + 'px';
  5275. iframe.style.right = '0px';
  5276. iframe.style.width = window.innerWidth + 'px';
  5277. iframe.style.visibility = "";
  5278. iframe.src = "https://classic.minecraft.net/?size=huge";
  5279. }
  5280. }
  5281.  
  5282. else
  5283. {
  5284. setTimeout(goToLocation(true), 250);
  5285. }
  5286. // let a = new BMap.Point(global_lng, global_lat);
  5287. // BaiduPlayer.setPov({ heading: -40, pitch: 6 });
  5288. // BaiduPlayer.setPosition(a);
  5289. }
  5290. else if (nextPlayer === "Kakao") {
  5291. var roadviewClient = new kakao.maps.RoadviewClient();
  5292. var position = new kakao.maps.LatLng(global_lat, global_lng);
  5293. roadviewClient.getNearestPanoId(position, 500, function (panoId) {
  5294. KakaoPlayer.setPanoId(panoId, position);
  5295. KakaoPlayer.setViewpoint({ pan: global_heading, tilt: global_pitch, zoom: -3 })
  5296. });
  5297. }
  5298. else if (nextPlayer === "Mapillary") {
  5299. MapillaryPlayer.resize()
  5300. MapillaryPlayer.moveTo(mmKey).then(
  5301. image => { //console.log(image);
  5302. },
  5303. error => { console.log(error); });
  5304. }
  5305. else if (nextPlayer === "Google" && !rtded) {
  5306. if (!bullseyeMapillary)
  5307. {
  5308. handleMapillary({lat: global_lat, lng: global_lng}, {meters: 500, limit: 500});
  5309. }
  5310. }
  5311. else if (nextPlayer === "Bing Streetside") {
  5312. let mTId = MSStreetPlayer.getMapTypeId();
  5313. if (mTId !== Microsoft.Maps.MapTypeId.streetside && mTId !== Microsoft.Maps.MapTypeId.road)
  5314. {
  5315. console.log("Reset Bing map type to Streetside")
  5316. MSStreetPlayer = new Microsoft.Maps.Map(document.getElementById('ms-player'),{disableStreetsideAutoCoverage: true, allowHidingLabelsOfRoad: true});
  5317. }
  5318. MSStreetPlayer.setOptions({disableStreetside: false});
  5319. MSStreetPlayer.setView({mapTypeId: Microsoft.Maps.MapTypeId.streetside,
  5320. zoom: 18,
  5321. streetsideOptions: {
  5322. overviewMapMode: Microsoft.Maps.OverviewMapMode.hidden,
  5323. showCurrentAddress: false,
  5324. showProblemReporting: false,
  5325. showExitButton: false,
  5326. },
  5327. center: new Microsoft.Maps.Location(global_lat, global_lng),
  5328. heading: 90,
  5329. pitch: -30});
  5330. }
  5331. else if (nextPlayer === "Planets") {
  5332. // console.log("Bing Satellite Player")
  5333.  
  5334. if (randomPlanets)
  5335. {
  5336. let tempSL = spaceList.slice(0, -1);
  5337. planetType = tempSL[Math.floor(Math.random() * tempSL.length)];
  5338. setMapstylePlanet(planetType);
  5339. }
  5340.  
  5341. let mTId = MSStreetPlayer.getMapTypeId();
  5342. if (mTId !== Microsoft.Maps.MapTypeId.aerial && mTId !== Microsoft.Maps.MapTypeId.road)
  5343. {
  5344. console.log("Reset Bing map type to Satellite")
  5345. MSStreetPlayer = new Microsoft.Maps.Map(document.getElementById('ms-player'),{disableStreetsideAutoCoverage: true, allowHidingLabelsOfRoad: true});
  5346. }
  5347. // MSStreetPlayer = new Microsoft.Maps.Map(document.getElementById('ms-player'),{disableStreetsideAutoCoverage: true, allowHidingLabelsOfRoad: true});
  5348. let ctr = new Microsoft.Maps.Location(global_lat, global_lng)
  5349. let loc_centre = {lat: global_lat, lng: global_lng};
  5350. for (var i = MSStreetPlayer.entities.getLength() - 1; i >= 0; i--) {
  5351. var pushpin = MSStreetPlayer.entities.get(i);
  5352. if (pushpin instanceof Microsoft.Maps.Pushpin) {
  5353. MSStreetPlayer.entities.removeAt(i);
  5354. }
  5355. }
  5356. // console.log("Satellite radius: " + (ms_radius / 1000).toString() + "km");
  5357.  
  5358. let maxZoomNum = 20;
  5359. if (planetType == "Mars")
  5360. {
  5361. maxZoomNum = 5;
  5362. }
  5363. else if (planetType == "Moon")
  5364. {
  5365. maxZoomNum = 6;
  5366. }
  5367.  
  5368. if (ms_radius < 1500000)
  5369. {
  5370. ms_radius = 1500000;
  5371. }
  5372.  
  5373. if (ms_radius > 6000000)
  5374. {
  5375. ms_radius = 6000000;
  5376. }
  5377.  
  5378. // console.log(ms_radius);
  5379.  
  5380. let latlngBounds = getBBox2(loc_centre, ms_radius);
  5381. // console.log(latlngBounds)
  5382. let bounds = Microsoft.Maps.LocationRect.fromLocations(new Microsoft.Maps.Location(latlngBounds[0], latlngBounds[1]), new Microsoft.Maps.Location(latlngBounds[2], latlngBounds[3]));
  5383.  
  5384. MSStreetPlayer.setOptions({maxBounds: bounds, maxZoom: maxZoomNum})
  5385.  
  5386. MSStreetPlayer.setOptions({disableStreetside: true});
  5387. MSStreetPlayer.setView({mapTypeId: Microsoft.Maps.MapTypeId.mercator,
  5388. labelOverlay: Microsoft.Maps.LabelOverlay.hidden,
  5389. center: ctr,
  5390. zoom: 1,
  5391. })
  5392. var weatherTileSource = new Microsoft.Maps.TileSource({
  5393. uriConstructor: getTMSTilePath
  5394. });
  5395. var weatherTileLayer = new Microsoft.Maps.TileLayer({
  5396. mercator: weatherTileSource,
  5397. });
  5398. if (planetType == "Moon")
  5399. {
  5400. document.getElementById("Moon (Labels)").click();
  5401. }
  5402. else if (planetType == "Mars")
  5403. {
  5404. document.getElementById("Mars (Labels)").click();
  5405. }
  5406. else
  5407. {
  5408. // console.log(planetType);
  5409. // console.log(document.getElementById(planetType));
  5410. document.getElementById(planetType).click();
  5411. }
  5412. MSStreetPlayer.layers.insert(weatherTileLayer);
  5413.  
  5414. var pin = new Microsoft.Maps.Pushpin(ctr, {});
  5415. MSStreetPlayer.entities.push(pin);
  5416.  
  5417. // FixLink(); // DOM BASED SOLUTION
  5418. }
  5419. else if (nextPlayer === "Mapbox Satellite") {
  5420. // MapboxPlayer.resize();
  5421. let satelliteStyleBtn = document.getElementById("Satellite Style Button");
  5422. let satelliteTypeBtn = document.getElementById("Satellite Type Button");
  5423. function waitSky()
  5424. {
  5425. try
  5426. {
  5427. let l = [];
  5428. for (let element of MapboxPlayer.getStyle().layers)
  5429. {
  5430. l.push(element.id);
  5431. }
  5432. if (l.includes('sky'))
  5433. {
  5434. styleMapboxAll(satelliteTypeBtn.currentId, satelliteTypeBtn.currentDim, satelliteStyleBtn.current, satelliteTypeBtn.currentId, satelliteTypeBtn.currentDim, satelliteStyleBtn.current, true);
  5435. }
  5436. else
  5437. {
  5438. setTimeout(waitSky, 250);
  5439. }
  5440. }
  5441. catch(error)
  5442. {
  5443. console.log(error)
  5444. setTimeout(waitSky, 250);
  5445. }
  5446. }
  5447. waitSky();
  5448. }
  5449. if (nextPlayer === "Google" && fire1)
  5450. {
  5451. window.dispatchEvent(new Event('resize'));
  5452. if (rtded)
  5453. {
  5454. document.getElementById("Clear").click();
  5455. }
  5456. fire1 = false;
  5457. }
  5458.  
  5459. if (cond)
  5460. {
  5461. switchCovergeButton.lat = global_lat;
  5462. switchCovergeButton.lng = global_lng;
  5463. RestrictBoundsBtn.lat = global_lat;
  5464. RestrictBoundsBtn.lng = global_lng;
  5465. }
  5466.  
  5467. }
  5468.  
  5469.  
  5470. /**
  5471. * Handle undo using the location history of the current round
  5472. */
  5473.  
  5474. function goToUndoMove(data) {
  5475. /* console.log(global_lat);
  5476. console.log(global_lng); */
  5477. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  5478. let teleportMenu = document.getElementById("Teleport Button");
  5479. let switchCovergeButton = document.getElementById("switch");
  5480. let options = {};
  5481. let prevStep = null;
  5482. if (locHistory.length === 1) {
  5483. prevStep = locHistory[0];
  5484. }
  5485. else {
  5486. prevStep = locHistory.pop();
  5487. }
  5488. // console.log(prevStep);
  5489. // console.log(locHistory)
  5490. if (nextPlayer === "Yandex") {
  5491. defaultPanoIdChange = false;
  5492. YandexPlayer.moveTo([prevStep[0], prevStep[1]], options);
  5493. YandexPlayer.setDirection([prevStep[2], prevStep[3]]);
  5494. YandexPlayer.setSpan([10, 67]);
  5495. switchCovergeButton.lat = prevStep[0];
  5496. switchCovergeButton.lng = prevStep[1];
  5497. }
  5498. else if (nextPlayer === "Kakao") {
  5499. let btn = document.querySelector("button[data-qa='undo-move']");
  5500. btn.disabled = false;
  5501. btn.classList.remove('styles_disabled__2YdHD');
  5502. defaultPanoIdChange = false;
  5503. let position = new kakao.maps.LatLng(prevStep[0], prevStep[1]);
  5504. KakaoPlayer.setPanoId(prevStep[2], position);
  5505. switchCovergeButton.lat = prevStep[0];
  5506. switchCovergeButton.lng = prevStep[1];
  5507. switchCovergeButton.useGoogle = false;
  5508. teleportMenu.google = false;
  5509. // console.log("Undo 1 step");
  5510. // console.log(locHistory);
  5511. }
  5512. else if (nextPlayer === "Mapillary" ) {
  5513. // console.log(prevStep[1]);
  5514.  
  5515. MapillaryPlayer.moveTo(prevStep[2]).then(
  5516. image => {
  5517. //console.log(image);
  5518. switchCovergeButton.lat = prevStep[1];
  5519. switchCovergeButton.lng = prevStep[0];
  5520. },
  5521. error => { console.log(error); });
  5522. }
  5523. else if (nextPlayer === "Bing Streetside") {
  5524. defaultPanoIdChange = false;
  5525. // console.log(locHistory);
  5526. MSStreetPlayer.setView({center: new Microsoft.Maps.Location(prevStep[0], prevStep[1]),});
  5527. switchCovergeButton.lat = prevStep[0];
  5528. switchCovergeButton.lng = prevStep[1];
  5529. switchCovergeButton.heading = prevStep[2];
  5530. }
  5531.  
  5532. }
  5533.  
  5534. function handleTeleport()
  5535. {
  5536. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  5537. let teleportMenu = document.getElementById("Teleport Button");
  5538. let switchCovergeButton = document.getElementById("switch");
  5539. if (teleportMenu)
  5540. {
  5541. function tpt(direction)
  5542. {
  5543. if (!teleportMenu.google)
  5544. {
  5545. // console.log("non-Google Teleport");
  5546. function forwardReverse(heading)
  5547. {
  5548. if (direction)
  5549. {
  5550. return heading;
  5551. }
  5552. else
  5553. {
  5554. return (heading + 180) % 360;
  5555. }
  5556. }
  5557.  
  5558. let prevStep = null;
  5559. if (locHistory.length === 1) {
  5560. prevStep = locHistory[0];
  5561. }
  5562. else {
  5563. prevStep = locHistory[locHistory.length - 1];
  5564. }
  5565. // console.log(locHistory);
  5566.  
  5567. let options = {};
  5568. let place, position, pID;
  5569. if (nextPlayer === "Yandex") {
  5570.  
  5571. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(forwardReverse(prevStep[2])), teleportMenu.distance * 0.001);
  5572. YandexPlayer.setDirection([prevStep[2], prevStep[3]]);
  5573. YandexPlayer.moveTo([place.lat, place.lng], options);
  5574. YandexPlayer.setSpan([10, 67]);
  5575. switchCovergeButton.lat = place.lat;
  5576. switchCovergeButton.lng = place.lng;
  5577. }
  5578. else if (nextPlayer === "Kakao") {
  5579. var roadviewClient = new kakao.maps.RoadviewClient();
  5580. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(forwardReverse(prevStep[3])), teleportMenu.distance * 0.001);
  5581. position = new kakao.maps.LatLng(place.lat, place.lng);
  5582. roadviewClient.getNearestPanoId(position, 500, function (panoId) {
  5583. KakaoPlayer.setPanoId(panoId, position);
  5584. });
  5585. switchCovergeButton.lat = place.lat;
  5586. switchCovergeButton.lng = place.lng;
  5587. }
  5588. else if (nextPlayer === "Mapillary" || nextPlayer === "Google") {
  5589. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(forwardReverse(prevStep[2])), teleportMenu.distance * 0.001);
  5590. handleMapillary(place, {meters: 500, limit: 500});
  5591. switchCovergeButton.lat = place.lat;
  5592. switchCovergeButton.lng = place.lng;
  5593. // locHistory.push([place.lat, place.lng, prevStep[2], prevStep[3]]);
  5594. }
  5595. else if (nextPlayer === "Bing Streetside") {
  5596. // console.log("teleport")
  5597. // console.log(prevStep);
  5598. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(forwardReverse(prevStep[2])), teleportMenu.distance * 0.001);
  5599. let bounds = new Microsoft.Maps.LocationRect(new Microsoft.Maps.Location(place.lat, place.lng), 1, 1);
  5600. Microsoft.Maps.Map.getClosestPanorama(bounds, onSuccess, onMissingCoverage);
  5601. function onSuccess(panoramaInfo) {
  5602. // console.log("Coverage")
  5603. // console.log([panoramaInfo.la, panoramaInfo.lo])
  5604. MSStreetPlayer.setView({center: new Microsoft.Maps.Location(panoramaInfo.la, panoramaInfo.lo),
  5605. });
  5606. }
  5607. function onMissingCoverage() {
  5608. console.log("No Coverage")
  5609. }
  5610. }
  5611.  
  5612. if (teleportMenu.distance > 150)
  5613. {
  5614. teleportMenu.distance = 100;
  5615. teleportMenu.innerHTML = "Teleport: " + teleportMain.distance + " m";
  5616. }
  5617. }
  5618. }
  5619. document.getElementById("Teleport Forward").addEventListener("click", () => {
  5620. tpt(true);
  5621.  
  5622. });
  5623. document.getElementById("Teleport Reverse").addEventListener("click", () => {
  5624. tpt(false);
  5625.  
  5626. });
  5627. }
  5628. }
  5629.  
  5630. function SyncListener()
  5631. {
  5632. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  5633. let switchCovergeButton = document.getElementById("switch");
  5634. switchCovergeButton.addEventListener("click", () => {
  5635. if (switchCovergeButton.useGoogle == false) {
  5636. // switchCovergeButton.useGoogle = true;
  5637. console.log(nextPlayer)
  5638. if (nextPlayer === "Yandex") {
  5639. let options = {};
  5640. YandexPlayer.moveTo([switchCovergeButton.lat, switchCovergeButton.lng], options);
  5641. YandexPlayer.setDirection([switchCovergeButton.heading, 0]);
  5642.  
  5643. // nextPlayer = "Yandex";
  5644. }
  5645. else if (nextPlayer === "Kakao") {
  5646. let roadviewClient = new kakao.maps.RoadviewClient();
  5647. // console.log(switchCovergeButton.lat);
  5648. let position = new kakao.maps.LatLng(switchCovergeButton.lat, switchCovergeButton.lng);
  5649. roadviewClient.getNearestPanoId(position, 500, function (panoId) {
  5650. KakaoPlayer.setPanoId(panoId, position);
  5651. });
  5652. KakaoPlayer.setViewpoint({
  5653. pan: switchCovergeButton.heading,
  5654. tilt: 0,
  5655. zoom: -3
  5656. });
  5657. // nextPlayer = "Kakao";
  5658. }
  5659. else if (nextPlayer === "Mapillary" || nextPlayer === "Google") {
  5660. // nextPlayer = "Kakao";
  5661. handleMapillary({lat: switchCovergeButton.lat, lng: switchCovergeButton.lng}, {meters: 100, limit: 100});
  5662. }
  5663. else if (nextPlayer === "Bing Streetside") {
  5664. let bounds = new Microsoft.Maps.LocationRect(new Microsoft.Maps.Location(switchCovergeButton.lat, switchCovergeButton.lng), 0.01, 0.01);
  5665. Microsoft.Maps.Map.getClosestPanorama(bounds, onSuccess, onMissingCoverage);
  5666. function onSuccess(panoramaInfo) {
  5667. MSStreetPlayer.setView({center: new Microsoft.Maps.Location(panoramaInfo.la, panoramaInfo.lo),
  5668. heading: switchCovergeButton.heading
  5669. });
  5670. }
  5671. function onMissingCoverage() {
  5672. console.log("No Coverage")
  5673. }
  5674. }
  5675. }
  5676. });
  5677.  
  5678. }
  5679.  
  5680. /**
  5681. * Gets the seed data for the current game
  5682. *
  5683. * @returns Promise with seed data as object
  5684. */
  5685. function getSeed() {
  5686. console.log("get seed");
  5687. // myHighlight("Get Seed");
  5688. return new Promise((resolve, reject) => {
  5689. let token = getToken();
  5690. let URL;
  5691. let cred = ""
  5692.  
  5693. const PATHNAME = window.location.pathname;
  5694.  
  5695. if (PATHNAME.startsWith("/game/")) {
  5696. URL = `https://www.geoguessr.com/api/v3/games/${token}`;
  5697. }
  5698. else if (PATHNAME.startsWith("/challenge/")) {
  5699. URL = `https://www.geoguessr.com/api/v3/challenges/${token}/game`;
  5700. }
  5701. else if (PATHNAME.startsWith("/battle-royale/")) {
  5702. URL = `https://game-server.geoguessr.com/api/battle-royale/${token}`;
  5703. }
  5704. else if (PATHNAME.startsWith("/duels/") || PATHNAME.startsWith("/team-duels/")) {
  5705. URL = `https://game-server.geoguessr.com/api/duels/${token}`;
  5706. }
  5707. else if (PATHNAME.startsWith("/bullseye/")) {
  5708. URL = `https://game-server.geoguessr.com/api/bullseye/${token}`;
  5709. }
  5710. else if (PATHNAME.startsWith("/live-challenge/")) {
  5711. URL = `https://game-server.geoguessr.com/api/live-challenge/${token}`;
  5712. }
  5713. if (isBattleRoyale) {
  5714. fetch(URL, {
  5715. // Include credentials to GET from the endpoint
  5716. credentials: 'include'
  5717. })
  5718. .then((response) => response.json())
  5719. .then((data) => {
  5720. resolve(data);
  5721. })
  5722. .catch((error) => {
  5723. reject(error);
  5724. });
  5725. }
  5726. else {
  5727. fetch(URL)
  5728. .then((response) => response.json())
  5729. .then((data) => {
  5730. resolve(data);
  5731. })
  5732. .catch((error) => {
  5733. reject(error);
  5734. });
  5735. }
  5736. });
  5737. }
  5738.  
  5739. /**
  5740. * Gets the token from the current URL
  5741. *
  5742. * @returns token
  5743. */
  5744. function getToken() {
  5745. const PATHNAME = window.location.pathname;
  5746. if (PATHNAME.startsWith("/game/")) {
  5747. return PATHNAME.replace("/game/", "");
  5748. }
  5749. else if (PATHNAME.startsWith("/challenge/")) {
  5750. return PATHNAME.replace("/challenge/", "");
  5751. }
  5752. else if (PATHNAME.startsWith("/battle-royale/")) {
  5753. return PATHNAME.replace("/battle-royale/", "");
  5754. }
  5755. else if (PATHNAME.startsWith("/duels/")) {
  5756. return PATHNAME.replace("/duels/", "");
  5757. }
  5758. else if (PATHNAME.startsWith("/team-duels/")) {
  5759. return PATHNAME.replace("/team-duels/", "");
  5760. }
  5761. else if (PATHNAME.startsWith("/bullseye/")) {
  5762. return PATHNAME.replace("/bullseye/", "");
  5763. }
  5764. else if (PATHNAME.startsWith("/live-challenge/")) {
  5765. return PATHNAME.replace("/live-challenge/", "");
  5766. }
  5767. }
  5768.  
  5769. /**
  5770. * Gets the round number from the ongoing game from the page itself
  5771. *
  5772. * @returns Round number
  5773. */
  5774. function getRoundFromPage() {
  5775. const roundData = document.querySelector("div[data-qa='round-number']");
  5776. if (roundData) {
  5777. let roundElement = roundData.querySelector("div:last-child");
  5778. if (roundElement) {
  5779. let round = parseInt(roundElement.innerText.charAt(0));
  5780. if (!isNaN(round) && round >= 1 && round <= 5) {
  5781. return round;
  5782. }
  5783. }
  5784. }
  5785. else {
  5786. return ROUND;
  5787. }
  5788. }
  5789.  
  5790.  
  5791. /**
  5792. * Injects Yandex Script
  5793. */
  5794. function injectYandexScript() {
  5795. return new Promise((resolve, reject) => {
  5796. if (!YANDEX_INJECTED) {
  5797. if (YANDEX_API_KEY === "") {
  5798. console.log("No Yandex Key")
  5799. reject();
  5800. }
  5801. else {
  5802. if (!partialCreateYandex)
  5803. {
  5804. const SCRIPT = document.createElement("script");
  5805. SCRIPT.type = "text/javascript";
  5806. SCRIPT.async = true;
  5807. SCRIPT.src = `https://api-maps.yandex.ru/2.1/?lang=en_US&apikey=${YANDEX_API_KEY}`;
  5808. document.body.appendChild(SCRIPT);
  5809. SCRIPT.onload = () => {
  5810. ymaps.ready(() => {
  5811. YANDEX_INJECTED = true;
  5812. myHighlight("Yandex API Loaded");
  5813. resolve();
  5814. });
  5815. }
  5816. }
  5817. else
  5818. {
  5819. YANDEX_INJECTED = true;
  5820. resolve();
  5821. }
  5822. }
  5823. }
  5824. else {
  5825. resolve();
  5826. }
  5827. });
  5828. }
  5829.  
  5830. /**
  5831. * Injects Yandex Player and calls handleReturnToStart
  5832. */
  5833. function injectYandexPlayer() {
  5834. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  5835. let switchCovergeButton = document.getElementById("switch");
  5836. let lat = 41.321861;
  5837. let lng = 69.212920;
  5838.  
  5839. let options = {
  5840. "direction": [0, 16],
  5841. "span": [10, 67],
  5842. "controls": ["zoomControl"]
  5843. };
  5844. ymaps.panorama.createPlayer("player", [lat, lng], options)
  5845. .done((player) => {
  5846. YandexPlayer = player;
  5847. YandexPlayer.events.add("directionchange", (e) => {
  5848. updateCompass();
  5849. let pov = YandexPlayer.getDirection();
  5850. if (locHistory.length > 0 && nextPlayer == "Yandex") {
  5851. switchCovergeButton.heading = pov[0];
  5852. locHistory[locHistory.length - 1][2] = pov[0];
  5853. locHistory[locHistory.length - 1][3] = pov[1];
  5854. }
  5855. });
  5856. YandexPlayer.events.add("panoramachange", (e) => {
  5857. if (defaultPanoIdChange) {
  5858. let num = YandexPlayer.getPanorama().getPosition();
  5859. let pov = YandexPlayer.getDirection();
  5860. // console.log(num);
  5861. // console.log(pov);
  5862. if (nextPlayer == "Yandex")
  5863. {
  5864. locHistory.push([num[0], num[1], pov[0], pov[1]]);
  5865. switchCovergeButton.lat = num[0];
  5866. switchCovergeButton.lng = num[1];
  5867. }
  5868. let btn = document.querySelector("button[data-qa='undo-move']");
  5869. if (locHistory.length > 1) {
  5870. btn.disabled = false;
  5871. btn.classList.remove('styles_disabled__2YdHD');
  5872. }
  5873. // console.log(locHistory);
  5874. }
  5875. defaultPanoIdChange = true;
  5876.  
  5877. });
  5878. console.log("Yandex Player injected");
  5879. });
  5880.  
  5881. }
  5882.  
  5883.  
  5884. /**
  5885. * Injects Baidu script
  5886. */
  5887.  
  5888. function reportWindowSize() {
  5889. // console.log("report window size");
  5890. let iframeC = document.getElementById("i_container");
  5891. if (iframeC)
  5892. {
  5893. if (nextPlayer == "Baidu")
  5894. {
  5895. iframeC.style.top = '-60px';
  5896. iframeC.style.height = (window.innerHeight + 200) + 'px';
  5897. // TODO
  5898. iframeC.style.right = '-55px';
  5899. iframeC.style.width = (window.innerWidth + 55) + 'px';
  5900. }
  5901. else if (nextPlayer == "Youtube")
  5902. {
  5903. iframeC.style.top = '-60px';
  5904. iframeC.style.height = (window.innerHeight + 235) + 'px';
  5905. iframeC.style.right = '0px';
  5906. iframeC.style.width = (window.innerWidth) + 'px';
  5907. }
  5908. else if (nextPlayer == "Image" || nextPlayer === "Minecraft")
  5909. {
  5910. iframeC.style.top = '0px';
  5911. iframeC.style.height = (window.innerHeight) + 'px';
  5912. iframeC.style.right = '0px';
  5913. iframeC.style.width = (window.innerWidth) + 'px';
  5914. }
  5915. else if (nextPlayer === "Wikipedia")
  5916. {
  5917. iframeC.style.top = '0px';
  5918. iframeC.style.height = (window.innerHeight) + 'px';
  5919. iframeC.style.right = '-325px';
  5920. iframeC.style.width = (window.innerWidth + 325) + 'px';
  5921. }
  5922.  
  5923. }
  5924. }
  5925.  
  5926. window.onresize = reportWindowSize;
  5927.  
  5928.  
  5929.  
  5930. function injectContainer() {
  5931. myHighlight("iframe container loaded")
  5932. const iframe = document.createElement('iframe');
  5933. iframe.frameBorder = 0;
  5934. iframe.style.position = "absolute";
  5935. iframe.id = "i_container";
  5936. if (isBattleRoyale) {
  5937. if (isDuel)
  5938. {
  5939. iframe.className = "inactive";
  5940. }
  5941. else if (isBullseye)
  5942. {
  5943. iframe.className = "game-panorama_panorama__ncMwh";
  5944. }
  5945. else if (isLiveChallenge)
  5946. {
  5947. iframe.className = "game-panorama_panorama__Qpsxl";
  5948. }
  5949. else
  5950. {
  5951. iframe.className = "br-game-layout__panorama";
  5952. }
  5953. }
  5954. else {
  5955. iframe.className = "game-layout__panorama";
  5956. }
  5957. var div = document.getElementById("player");
  5958. if (div)
  5959. {
  5960. div.style.overflow = "hidden";
  5961. if (isBullseye || isLiveChallenge)
  5962. {
  5963. div.prepend(iframe);
  5964. }
  5965. else
  5966. {
  5967. div.appendChild(iframe);
  5968. }
  5969. }
  5970.  
  5971. }
  5972.  
  5973. /**
  5974. * Injects Kakao script
  5975. */
  5976.  
  5977. function injectKakaoScript() {
  5978. return new Promise((resolve, reject) => {
  5979. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  5980. let switchCovergeButton = document.getElementById("switch");
  5981. if (!KAKAO_INJECTED) {
  5982. if (KAKAO_API_KEY === "") {
  5983. console.log("No Kakao Key")
  5984. }
  5985. else {
  5986.  
  5987. let canvas = document.createElement("kmap");
  5988. if (isBattleRoyale) {
  5989. if (isDuel)
  5990. {
  5991. canvas.innerHTML = `
  5992. <div id="roadview" class="inactive" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  5993. `;
  5994. }
  5995. else if (isBullseye)
  5996. {
  5997. canvas.innerHTML = `
  5998. <div id="roadview" class="game-panorama_panorama__ncMwh" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  5999. `;
  6000. }
  6001. else if (isLiveChallenge)
  6002. {
  6003. canvas.innerHTML = `
  6004. <div id="roadview" class="game-panorama_panorama__Qpsxl" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  6005. `;
  6006. }
  6007. else
  6008. {
  6009. canvas.innerHTML = `
  6010. <div id="roadview" class="br-game-layout__panorama" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  6011. `;
  6012. }
  6013. }
  6014. else {
  6015. canvas.innerHTML = `
  6016. <div id="roadview" class="game-layout__panorama" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  6017. `;
  6018. }
  6019.  
  6020.  
  6021. var div = document.getElementById("player");
  6022. if (isBullseye || isLiveChallenge)
  6023. {
  6024. div.prepend(canvas);
  6025. }
  6026. else
  6027. {
  6028. div.appendChild(canvas);
  6029. }
  6030.  
  6031. let SCRIPT;
  6032. if (!partialCreateKakao)
  6033. {
  6034. SCRIPT = document.createElement("script");
  6035. SCRIPT.async = true;
  6036. // SCRIPT.type = "text/javascript";
  6037. SCRIPT.src = `//dapi.kakao.com/v2/maps/sdk.js?appkey=${KAKAO_API_KEY}&autoload=false`;
  6038. document.body.appendChild(SCRIPT);
  6039. }
  6040.  
  6041. function drawmapKakao()
  6042. {
  6043. kakao.maps.load(function () {
  6044. var position = new kakao.maps.LatLng(33.450701, 126.560667);
  6045. let roadviewContainer = document.getElementById('roadview');
  6046. KakaoPlayer = new kakao.maps.Roadview(roadviewContainer);
  6047. var panoId = 1023434522;
  6048. KakaoPlayer.setPanoId(panoId, position);
  6049. KAKAO_INJECTED = true;
  6050. // Remove the compass from Kakao
  6051. kakao.maps.event.addListener(KakaoPlayer, 'init', () => {
  6052. const compassContainer = roadviewContainer.querySelector('div[id*="_box_util_"]');
  6053. if (compassContainer) compassContainer.style.display = 'none';
  6054. });
  6055. kakao.maps.event.addListener(KakaoPlayer, 'panoid_changed', function() {
  6056. if (defaultPanoIdChange && KakaoPlayer) {
  6057. let latlng = KakaoPlayer.getPosition();
  6058. let lat = latlng.getLat();
  6059. let lng = latlng.getLng();
  6060. let pID = KakaoPlayer.getViewpointWithPanoId();
  6061. if (nextPlayer == "Kakao" && lat != 33.45047613915499)
  6062. {
  6063. // console.log("push");
  6064. locHistory.push([lat, lng, pID.panoId, pID.pan]);
  6065. switchCovergeButton.lat = lat;
  6066. switchCovergeButton.lng = lng;
  6067. switchCovergeButton.heading = pID.pan;
  6068. }
  6069. let btn = document.querySelector("button[data-qa='undo-move']");
  6070. if (locHistory.length > 1 && (btn != null)) {
  6071. btn.disabled = false;
  6072. btn.classList.remove('styles_disabled__2YdHD');
  6073. }
  6074. // console.log(locHistory);
  6075. }
  6076. defaultPanoIdChange = true;
  6077. });
  6078. kakao.maps.event.addListener(KakaoPlayer, 'viewpoint_changed', function() {
  6079. // console.log("pov_listener attached");
  6080. let pID = KakaoPlayer.getViewpointWithPanoId();
  6081. if (locHistory.length > 0 && nextPlayer == "Kakao") {
  6082. switchCovergeButton.heading = pID.pan;
  6083. locHistory[locHistory.length - 1][3] = pID.pan;
  6084. }
  6085. if (GooglePlayer) {
  6086. const { heading, pitch } = GooglePlayer.getPov()
  6087. if ((!almostEqual(pID.pan, heading) || !almostEqual(pID.tilt, pitch)) && nextPlayer == "Kakao") {
  6088. // Updating the google street view POV will update the compass
  6089. GooglePlayer.setPov({ heading: pID.pan, pitch: pID.tilt })
  6090. }
  6091. }
  6092. // console.log(locHistory);
  6093. })
  6094. });
  6095. }
  6096.  
  6097. if (partialCreateKakao)
  6098. {
  6099. drawmapKakao();
  6100. }
  6101. else
  6102. {
  6103. SCRIPT.onload = () => {
  6104. drawmapKakao();
  6105. myHighlight("Kakao API Loaded");
  6106. resolve();
  6107. };
  6108. }
  6109.  
  6110. }
  6111. }
  6112. else {
  6113. resolve();
  6114. }
  6115. });
  6116. }
  6117.  
  6118. function getTMSTilePath(tile) {
  6119. var yN = Math.pow(2, tile.zoom) - tile.y - 1;
  6120. // console.log([tile.zoom,tile.x,yN]);
  6121. if (planetType == "Moon")
  6122. {
  6123. // document.getElementById("Moon (Labels)").click();
  6124. return "https://s3.amazonaws.com/opmbuilder/301_moon/tiles/w/hillshaded-albedo/" + tile.zoom + "/" + tile.x + "/" + yN + ".png";
  6125. }
  6126. else if (planetType == "Mars")
  6127. {
  6128. // document.getElementById("Mars (Labels)").click();
  6129. return "http://s3-eu-west-1.amazonaws.com/whereonmars.cartodb.net/celestia_mars-shaded-16k_global/" + tile.zoom + "/" + tile.x + "/" + yN + ".png";
  6130. }
  6131. else
  6132. {
  6133. return handleSpURL(document.getElementById(planetType).url, tile.x, tile.y, tile.zoom);
  6134. }
  6135. // else if (planetType == "GTAV")
  6136. // {
  6137. // return "https://tiles.mapgenie.io/games/gta5/los-santos/satellite/" + tile.zoom + "/" + tile.x + "/" + yN + ".png";
  6138. // // https://tiles.mapgenie.io/games/gta5/los-santos/road/4/2/5.png
  6139. // }
  6140. // else if (planetType == "GTASA")
  6141. // {
  6142. // return "https://tiles.mapgenie.io/games/grand-theft-auto-san-andreas/san-andreas/satellite-v1/" + tile.zoom + "/" + tile.x + "/" + yN + ".png";
  6143. // // "https://tiles.mapgenie.io/games/grand-theft-auto-san-andreas/san-andreas/atlas-v1/" + tile.zoom + "/" + tile.x + "/" + yN + ".png";
  6144. // }
  6145. }
  6146.  
  6147. function injectMSPlayer() {
  6148. return new Promise((resolve, reject) => {
  6149. if (!MS_INJECTED) {
  6150. if (MS_API_KEY === "") {
  6151. let canvas = document.getElementById("player");
  6152. console.log("No MS Key")
  6153. }
  6154. else {
  6155.  
  6156. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  6157. let switchCovergeButton = document.getElementById("switch");
  6158. let SCRIPT;
  6159. if (!partialCreateMS)
  6160. {
  6161. SCRIPT = document.createElement("script");
  6162. SCRIPT.type = "text/javascript";
  6163. SCRIPT.async = true;
  6164. SCRIPT.src = `https://www.bing.com/api/maps/mapcontrol?key=${MS_API_KEY}`;
  6165. document.body.appendChild(SCRIPT);
  6166. }
  6167. let canvas = document.createElement("msmap");
  6168. if (isBattleRoyale) {
  6169. if (isDuel)
  6170. {
  6171. canvas.innerHTML = `<div id="ms-player" class="inactive" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  6172. }
  6173. else if (isBullseye)
  6174. {
  6175. canvas.innerHTML = `<div id="ms-player" class="game-panorama_panorama__ncMwh" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  6176. }
  6177. else if (isLiveChallenge)
  6178. {
  6179. canvas.innerHTML = `<div id="ms-player" class="game-panorama_panorama__Qpsxl" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  6180. }
  6181. else
  6182. {
  6183. canvas.innerHTML = `<div id="ms-player" class="br-game-layout__panorama" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  6184. }
  6185. }
  6186. else {
  6187. canvas.innerHTML = `<div id="ms-player" class="game-layout__panorama" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  6188. }
  6189.  
  6190. var div = document.getElementById("player");
  6191. if (isBullseye || isLiveChallenge)
  6192. {
  6193. div.prepend(canvas);
  6194. }
  6195. else
  6196. {
  6197. div.appendChild(canvas);
  6198. }
  6199. function drawmapMS()
  6200. {
  6201. try
  6202. {
  6203. MSStreetPlayer = new Microsoft.Maps.Map(document.getElementById('ms-player'),{disableStreetsideAutoCoverage: true, allowHidingLabelsOfRoad: true});
  6204. MS_INJECTED = true;
  6205. // MSStreetPlayer.setOptions({
  6206. // minZoom: 13
  6207. // });
  6208. Microsoft.Maps.Events.addHandler(MSStreetPlayer, 'viewchangeend', function () { updateView(MSStreetPlayer); });
  6209. function updateView(map) {
  6210. let ctrm = map.getCenter();
  6211. if (nextPlayer == "Bing Streetside" && (switchCovergeButton.lat !== ctrm.latitude && switchCovergeButton.lng !== ctrm.longitude))
  6212. {
  6213. let heading2 = bearing(switchCovergeButton.lat, switchCovergeButton.lng, ctrm.latitude, ctrm.longitude)
  6214. // console.log("moved");
  6215. // console.log([switchCovergeButton.lat, switchCovergeButton.lng, ctrm.latitude, ctrm.longitude])
  6216. // console.log(heading2);
  6217. locHistory.push([ctrm.latitude, ctrm.longitude, heading2]);
  6218. switchCovergeButton.lat = ctrm.latitude;
  6219. switchCovergeButton.lng = ctrm.longitude;
  6220. switchCovergeButton.heading = heading2;
  6221. let btn = document.querySelector("button[data-qa='undo-move']");
  6222. if (locHistory.length > 1 && (btn != null)) {
  6223. btn.disabled = false;
  6224. btn.classList.remove('styles_disabled__2YdHD');
  6225. }
  6226. }
  6227. }
  6228. }
  6229. catch(error)
  6230. {
  6231. console.log(error);
  6232. // console.log("Retry MS");
  6233. // setTimeout(drawmapMS(), 1000);
  6234. }
  6235.  
  6236. }
  6237.  
  6238. if (partialCreateMS)
  6239. {
  6240. // drawmapMS();
  6241. if (isBullseye)
  6242. {
  6243. setTimeout(drawmapMS(), 1000);
  6244. }
  6245. else
  6246. {
  6247. drawmapMS();
  6248. }
  6249. resolve();
  6250. }
  6251. else
  6252. {
  6253. SCRIPT.addEventListener('load', () => {
  6254. myHighlight("Bing Maps API loaded");
  6255. let timeout = 0;
  6256. let interval = setInterval(() => {
  6257. // console.log(timeout);
  6258. if (timeout >= 40) {
  6259. reject();
  6260. clearInterval(interval);
  6261. }
  6262. if (document.getElementById('ms-player') !== null && Microsoft.Maps.Map !== typeof undefined) {
  6263. drawmapMS();
  6264. resolve();
  6265. clearInterval(interval);
  6266. }
  6267. timeout += 1;
  6268. }, 1000);
  6269. })
  6270. }
  6271. }
  6272. }
  6273. else {
  6274. resolve();
  6275. }
  6276. });
  6277. }
  6278.  
  6279.  
  6280.  
  6281. function injectMapillaryPlayer() {
  6282. return new Promise((resolve, reject) => {
  6283. if (!MAPILLARY_INJECTED) {
  6284. if (MAPILLARY_API_KEY === "") {
  6285. let canvas = document.getElementById("player");
  6286. console.log("No Mapillary Key")
  6287. }
  6288. else {
  6289. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  6290. let switchCovergeButton = document.getElementById("switch");
  6291. let SCRIPT;
  6292. if (!partialCreateMapillary)
  6293. {
  6294. SCRIPT = document.createElement("script");
  6295. SCRIPT.type = "text/javascript";
  6296. SCRIPT.async = true;
  6297. SCRIPT.src = `https://unpkg.com/mapillary-js@4.0.0/dist/mapillary.js`;
  6298. document.body.appendChild(SCRIPT);
  6299. document.querySelector('head').innerHTML += '<link href="https://unpkg.com/mapillary-js@4.0.0/dist/mapillary.css" rel="stylesheet"/>';
  6300. }
  6301. let canvas = document.createElement("mmap");
  6302. if (isBattleRoyale) {
  6303. if (isDuel)
  6304. {
  6305.  
  6306. canvas.innerHTML = `<div id="mapillary-player" class="inactive" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  6307. }
  6308. else if (isBullseye)
  6309. {
  6310. canvas.innerHTML = `<div id="mapillary-player" class="game-panorama_panorama__ncMwh" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  6311. }
  6312. else if (isLiveChallenge)
  6313. {
  6314. canvas.innerHTML = `<div id="mapillary-player" class="game-panorama_panorama__Qpsxl" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  6315. }
  6316. else
  6317. {
  6318. canvas.innerHTML = `<div id="mapillary-player" class="br-game-layout__panorama" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  6319. }
  6320. }
  6321. else {
  6322. canvas.innerHTML = `<div id="mapillary-player" class="game-layout__panorama" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  6323. }
  6324.  
  6325. var div = document.getElementById("player");
  6326. if (isBullseye || isLiveChallenge)
  6327. {
  6328. div.prepend(canvas);
  6329. // setTimeout(drawmapMS(), 1000);
  6330. }
  6331. else
  6332. {
  6333. div.appendChild(canvas);
  6334. }
  6335.  
  6336. function drawMapML()
  6337. {
  6338. var {Viewer} = mapillary;
  6339.  
  6340. MapillaryPlayer = new Viewer({
  6341. accessToken: MAPILLARY_API_KEY,
  6342. container: 'mapillary-player', // the ID of our container defined in the HTML body
  6343. });
  6344.  
  6345. MapillaryPlayer.on('image', async (event) => {
  6346. // cnt = cnt + 1;
  6347. // console.log(cnt);
  6348. let image = event.image;
  6349. let pos = image.originalLngLat;
  6350. let cond = true;
  6351. for (const element of locHistory) {
  6352. if (element[2] == image.id)
  6353. {
  6354. cond = false;
  6355. }
  6356. }
  6357. if (cond)
  6358. {
  6359. switchCovergeButton.lat = pos.lat;
  6360. switchCovergeButton.lng = pos.lng;
  6361. switchCovergeButton.heading = image.compassAngle;
  6362. // console.log(pos);
  6363. locHistory.push([pos.lat, pos.lng, image.id, image.compassAngle]);
  6364. }
  6365. let btn = document.querySelector("button[data-qa='undo-move']");
  6366. if (btn !== null && locHistory.length > 1)
  6367. {
  6368. btn.disabled = false;
  6369. btn.classList.remove('styles_disabled__2YdHD');
  6370. }
  6371. });
  6372.  
  6373. MAPILLARY_INJECTED = true;
  6374. }
  6375. if (partialCreateMapillary)
  6376. {
  6377. drawMapML();
  6378. }
  6379. else
  6380. {
  6381.  
  6382. SCRIPT.addEventListener('load', () => {
  6383. myHighlight("Mapillary API Loaded");
  6384. // resolve(BMap);
  6385. drawMapML();
  6386. resolve();
  6387. })
  6388. }
  6389. }
  6390. }
  6391. else {
  6392. resolve();
  6393. }
  6394. });
  6395. }
  6396.  
  6397. function changeInnerHTML(canvas1, init)
  6398. {
  6399. canvas1.style.display = "";
  6400. var div = document.getElementById("player");
  6401. if (isBullseye || isLiveChallenge)
  6402. {
  6403. div.prepend(canvas1);
  6404. }
  6405. else
  6406. {
  6407. div.appendChild(canvas1);
  6408. }
  6409.  
  6410. let canvas;
  6411. if (init)
  6412. {
  6413. canvas = document.createElement("div");
  6414. canvas.id = "mapbox-player";
  6415. canvas.style = `zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'`;
  6416. canvas1.appendChild(canvas);
  6417. }
  6418. else
  6419. {
  6420. document.getElementById("mapbox-player").classList.remove("inactive", "game-panorama_panorama__ncMwh", "game-panorama_panorama__Qpsxl", "br-game-layout__panorama", "game-layout__panorama", "game-panorama_panorama__rdhFg");
  6421. }
  6422. canvas = document.getElementById("mapbox-player");
  6423. if (isBattleRoyale) {
  6424. if (isDuel)
  6425. {
  6426. canvas.classList.add("inactive");
  6427. }
  6428. else if (isBullseye)
  6429. {
  6430. canvas.classList.add("game-panorama_panorama__ncMwh");
  6431. }
  6432. else if (isLiveChallenge)
  6433. {
  6434. canvas.classList.add("game-panorama_panorama__Qpsxl");
  6435. }
  6436. else
  6437. {
  6438. canvas.classList.add("br-game-layout__panorama");
  6439. }
  6440. }
  6441. else {
  6442. canvas.classList.add("game-layout__panorama");
  6443. }
  6444. if (rainLayer)
  6445. {
  6446. MapboxPlayer.resize();
  6447. }
  6448. // console.log(canvas);
  6449.  
  6450. }
  6451.  
  6452. function updateSunPosition(sunPos) {
  6453. MapboxPlayer.setPaintProperty('sky', 'sky-atmosphere-sun', sunPos);
  6454. }
  6455.  
  6456. function getSunPosition(date) {
  6457. const center = MapboxPlayer.getCenter();
  6458. const sunPos = SunCalc.getPosition(
  6459. date || Date.now(),
  6460. center.lat,
  6461. center.lng
  6462. );
  6463. const sunAzimuth = 180 + (sunPos.azimuth * 180) / Math.PI;
  6464. const sunAltitude = 90 - (sunPos.altitude * 180) / Math.PI;
  6465. return [sunAzimuth, sunAltitude];
  6466. }
  6467.  
  6468. // function handleRainLayer()
  6469. // {
  6470. // if (typeof RainLayer !== typeof undefined)
  6471. // {
  6472.  
  6473. // MapboxPlayer.addLayer(rainLayer);
  6474.  
  6475. // console.log("Rain Layer loaded");
  6476. // }
  6477. // else
  6478. // {
  6479. // setTimeout(handleRainLayer, 1000);
  6480. // }
  6481. // }
  6482.  
  6483. function skyLayer(reset, time, style)
  6484. {
  6485. try
  6486. {
  6487. if (reset == "reset")
  6488. {
  6489. let tm = [360, 30];
  6490.  
  6491. MapboxPlayer.addLayer({
  6492. 'id': 'sky',
  6493. 'type': 'sky',
  6494. 'paint': {
  6495. 'sky-opacity': [
  6496. 'interpolate',
  6497. ['linear'],
  6498. ['zoom'],
  6499. 0,
  6500. 0,
  6501. 5,
  6502. 0.3,
  6503. 8,
  6504. 1
  6505. ],
  6506. // set up the sky layer for atmospheric scattering
  6507. 'sky-type': 'atmosphere',
  6508. // explicitly set the position of the sun rather than allowing the sun to be attached to the main light source
  6509. 'sky-atmosphere-sun': tm,
  6510. // set the intensity of the sun as a light source (0-100 with higher values corresponding to brighter skies)
  6511. 'sky-atmosphere-sun-intensity': 5
  6512. }
  6513. });
  6514. time = tm;
  6515. MapboxPlayer.addLayer(rainLayer)
  6516. // handleRainLayer();
  6517.  
  6518.  
  6519. // Reset Fog
  6520. }
  6521. let percentage;
  6522. // console.log(time);
  6523.  
  6524. if (time[1] <= 75)
  6525. {
  6526. percentage = 0;
  6527. }
  6528. else if (time[1] > 75 && time[1] <= 90)
  6529. {
  6530. percentage = (90 - time[1]) / 20;
  6531. }
  6532. else
  6533. {
  6534. percentage = 1;
  6535. }
  6536.  
  6537. // console.log(MapboxPlayer.getStyle());
  6538.  
  6539. if (style == "Satellite")
  6540. {
  6541. MapboxPlayer.setPaintProperty(
  6542. 'heatmap',
  6543. 'heatmap-opacity',
  6544. percentage * 0.35
  6545. );
  6546. MapboxPlayer.setPaintProperty(
  6547. 'satellite',
  6548. 'raster-brightness-max',
  6549. 0.25 + (1 - percentage) * 0.75
  6550. );
  6551. MapboxPlayer.setPaintProperty(
  6552. 'road-simple',
  6553. 'line-opacity',
  6554. percentage * 0.25
  6555. );
  6556. MapboxPlayer.setPaintProperty(
  6557. 'bridge-case-simple',
  6558. 'line-opacity',
  6559. percentage * 0.25
  6560. );
  6561. MapboxPlayer.setPaintProperty(
  6562. 'bridge-simple',
  6563. 'line-opacity',
  6564. percentage * 0.25
  6565. );
  6566. }
  6567. let fogVal = 100 - percentage * 100;
  6568. // console.log(`rgba(${parseInt(fogVal)}, ${parseInt(fogVal)}, ${parseInt(fogVal)}, 1.0)`)
  6569. let val = [0, 5, 0.1];
  6570. if (ms_radius < 10000)
  6571. {
  6572. val[1] = ms_radius / 10000 * 4 + 1;
  6573. }
  6574. MapboxPlayer.setFog({ 'color': `hsl(0, 0, ${fogVal}%)` , 'range': [val[0], val[1]],'horizon-blend': val[2]});
  6575. // console.log(MapboxPlayer.getStyle());
  6576. }
  6577. catch (error) {
  6578. console.error(error);
  6579. // expected output: ReferenceError: nonExistentFunction is not defined
  6580. // Note - error messages will vary depending on browser
  6581. }
  6582. }
  6583.  
  6584.  
  6585. // function fetchTime(lat, lng)
  6586. // {
  6587. // return new Promise((resolve, reject) => {
  6588. // fetch(`https://api.timezonedb.com/v2.1/get-time-zone?key=D95ISGQ041BQ&format=json&by=position&lat=${lat}&lng=${lng}`)
  6589. // .then((response) => {resolve(response.json())})
  6590. // .catch((error) => {console.log(error);});
  6591. // });
  6592. // }
  6593. // fetchTime(global_lat, global_lng).then((data) => {
  6594.  
  6595. function styleMapboxAll(initId, initDim, initStyle, endId, endDim, endStyle, resetDist)
  6596. {
  6597. let rtVal = false;
  6598. const sunPositions = SunCalc.getTimes(
  6599. Date.now(),
  6600. global_lat,
  6601. global_lng
  6602. );
  6603.  
  6604. if (resetDist)
  6605. {
  6606. let tempRadius;
  6607. if (endDim == "3D" || endDim == "2.5D")
  6608. {
  6609. tempRadius = ms_radius * 0.5;
  6610. }
  6611. else
  6612. {
  6613. tempRadius = ms_radius;
  6614. }
  6615. let loc_centre = {lat: global_lat, lng: global_lng};
  6616. let latlngBounds = getBBox2(loc_centre, tempRadius);
  6617. // console.log([latlngBounds[0], latlngBounds[1]], [latlngBounds[2], latlngBounds[3]])
  6618. let mpBounds = [
  6619. [latlngBounds[1], latlngBounds[2]], // Southwest coordinates
  6620. [latlngBounds[3], latlngBounds[0]] // Northeast coordinates
  6621. ];
  6622. MapboxPlayer.flyTo({center: [global_lng, global_lat], zoom: 9});
  6623. MapboxMarker.setLngLat([global_lng, global_lat]);
  6624. MapboxPlayer.setMaxBounds(mpBounds);
  6625.  
  6626. }
  6627. let sunPos = getSunPosition(sunPositions[endStyle]);
  6628. updateSunPosition(sunPos);
  6629.  
  6630. if (initId !== endId)
  6631. {
  6632. if (endId == "Satellite")
  6633. {
  6634. MapboxPlayer.setStyle("mapbox://styles/jupaoqq/cl0xjs63k003a15ml3essawbk");
  6635. }
  6636. else
  6637. {
  6638. MapboxPlayer.setStyle("mapbox://styles/jupaoqq/cl0ro0tm0001l14nyi17a91rs");
  6639. }
  6640. setTimeout(() => {
  6641. skyLayer("reset", sunPos, endId);
  6642. dimChange();
  6643. }, 1000);
  6644. rtVal = true;
  6645. }
  6646. else
  6647. {
  6648. skyLayer(endId, sunPos, endId);
  6649. dimChange();
  6650. }
  6651.  
  6652. function dimChange()
  6653. {
  6654. if (initDim !== endDim || initId !== endId)
  6655. {
  6656. if (endDim.includes("2D"))
  6657. {
  6658. MapboxPlayer.setPitch(0);
  6659. MapboxPlayer.dragRotate.disable();
  6660. MapboxPlayer.touchZoomRotate.disableRotation();
  6661. MapboxPlayer.setPaintProperty(
  6662. 'building-extrusion',
  6663. 'fill-extrusion-opacity',
  6664. 0
  6665. );
  6666. rainLayer.setMeshOpacity(0);
  6667. rainLayer.setRainColor("rgba(204, 204, 255, 0)");
  6668. }
  6669. else
  6670. {
  6671. MapboxPlayer.dragRotate.enable();
  6672. MapboxPlayer.touchZoomRotate.enableRotation();
  6673. if (endDim.includes("2.5D"))
  6674. {
  6675. MapboxPlayer.setPaintProperty(
  6676. 'building-extrusion',
  6677. 'fill-extrusion-opacity',
  6678. 0
  6679. );
  6680. }
  6681. else
  6682. {
  6683. MapboxPlayer.setPaintProperty(
  6684. 'building-extrusion',
  6685. 'fill-extrusion-opacity',
  6686. 0.8
  6687. );
  6688. }
  6689. rainLayer.setMeshOpacity(0.1);
  6690. rainLayer.setRainColor("rgba(204, 204, 255, 1)");
  6691. }
  6692. if (!MapboxPlayer.getSource('mapbox-dem')) {
  6693. MapboxPlayer.addSource('mapbox-dem', {
  6694. 'type': 'raster-dem',
  6695. 'url': 'mapbox://mapbox.mapbox-terrain-dem-v1',
  6696. 'tileSize': 512,
  6697. 'maxzoom': 14
  6698. });
  6699. // add the DEM source as a terrain layer with exaggerated height
  6700. MapboxPlayer.setTerrain({ 'source': 'mapbox-dem', 'exaggeration': 1.5 });
  6701. }
  6702.  
  6703. }
  6704. }
  6705.  
  6706. return rtVal;
  6707.  
  6708. }
  6709.  
  6710. function injectMapboxPlayer() {
  6711. return new Promise((resolve, reject) => {
  6712. if (!MAPBOX_INJECTED) {
  6713. if (MAPBOX_API_KEY === "") {
  6714. let canvas = document.getElementById("player");
  6715. console.log("No Mapbox Key")
  6716. }
  6717. else {
  6718. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  6719. let switchCovergeButton = document.getElementById("switch");
  6720.  
  6721. let canvas = document.createElement("sat-map");
  6722. canvas.id = "sat_map";
  6723. canvas.classList.add("sat_map");
  6724. changeInnerHTML(canvas, true);
  6725.  
  6726.  
  6727. // mapbox://styles/jupaoqq/cl0rnlwp9001914mz2vpinynt
  6728. // mapbox://styles/jupaoqq/cl0ro0tm0001l14nyi17a91rs
  6729.  
  6730. let SCRIPT;
  6731. if (!partialCreateMapbox)
  6732. {
  6733. const SCRIPT2 = document.createElement("script");
  6734. SCRIPT2.type = "text/javascript";
  6735. SCRIPT2.async = true;
  6736. SCRIPT2.src = `https://cdnjs.cloudflare.com/ajax/libs/suncalc/1.8.0/suncalc.min.js`;
  6737. document.body.appendChild(SCRIPT2);
  6738.  
  6739. SCRIPT = document.createElement("script");
  6740. SCRIPT.type = "text/javascript";
  6741. SCRIPT.async = true;
  6742. SCRIPT.src = `https://api.mapbox.com/mapbox-gl-js/v2.7.0/mapbox-gl.js`;
  6743. document.body.appendChild(SCRIPT);
  6744. document.querySelector('head').innerHTML += '<link href="https://api.mapbox.com/mapbox-gl-js/v2.7.0/mapbox-gl.css" rel="stylesheet"/>';
  6745. SCRIPT.addEventListener('load', () => {
  6746. const SCRIPT3 = document.createElement("script");
  6747. SCRIPT3.type = "text/javascript";
  6748. SCRIPT3.async = true;
  6749. SCRIPT3.src = `https://cdn.jsdelivr.net/npm/mapbox-gl-rain-layer@latest/dist/mapbox-gl-rain-layer.min.js`;
  6750. document.body.appendChild(SCRIPT3);
  6751. SCRIPT3.addEventListener('load', () => {
  6752. myHighlight("Mapbox API and Rainlayer Loaded");
  6753. // resolve(BMap);
  6754. mapboxgl.accessToken = MAPBOX_API_KEY;
  6755. MapboxPlayer = new mapboxgl.Map({
  6756. container: 'mapbox-player', // container ID
  6757. style: 'mapbox://styles/jupaoqq/cl0xjs63k003a15ml3essawbk', // style URL
  6758. center: [0, 0], // starting position [lng, lat]
  6759. zoom: 15, // starting zoom
  6760. pitch: 0
  6761. });
  6762. console.log("New Mapbox API Call");
  6763. MapboxMarker = new mapboxgl.Marker()
  6764. .setLngLat([0, 0])
  6765. .addTo(MapboxPlayer);
  6766. MapboxPlayer.addControl(new mapboxgl.NavigationControl(), 'top-left');
  6767. MapboxPlayer.addControl(new mapboxgl.ScaleControl({}));
  6768. MapboxPlayer.on('load', () => {
  6769. MapboxPlayer.addSource('mapbox-dem', {
  6770. 'type': 'raster-dem',
  6771. 'url': 'mapbox://mapbox.mapbox-terrain-dem-v1',
  6772. 'tileSize': 512,
  6773. 'maxzoom': 14
  6774. });
  6775. // add the DEM source as a terrain layer with exaggerated height
  6776. MapboxPlayer.setTerrain({ 'source': 'mapbox-dem', 'exaggeration': 1.5 });
  6777. rainLayer = new RainLayer({
  6778. id: 'rain',
  6779. source: 'rainviewer',
  6780. scale: 'noaa'
  6781. });
  6782. // TODO
  6783. // MapboxPlayer.setFog({'range': [-1, 1.5], 'color': `rgba(255, 255, 255, 1.0)`,'horizon-blend': 0.1});
  6784. skyLayer("reset", "", "Satellite");
  6785.  
  6786.  
  6787. });
  6788.  
  6789. });
  6790. });
  6791.  
  6792.  
  6793. MAPBOX_INJECTED = true;
  6794. resolve();
  6795.  
  6796. }
  6797. else
  6798. {
  6799. resolve();
  6800. }
  6801. }
  6802. }
  6803. else {
  6804. resolve();
  6805. }
  6806. });
  6807. }
  6808.  
  6809.  
  6810.  
  6811. function handleMapillary(latlng, options)
  6812. {
  6813. console.log("handleMapillary")
  6814. handleMapillaryHelper(latlng, options).then((data) => {
  6815. //console.log(data.data)
  6816. let idToSet = 0;
  6817. let curDist = 100000000;
  6818. for (const element of data.data) {
  6819. // console.log(element)
  6820. if (element.hasOwnProperty("computed_geometry"))
  6821. {
  6822. try {
  6823. let rCord = element.computed_geometry["coordinates"];
  6824. let dist = distance(latlng.lat,latlng.lng,rCord[1],rCord[0])
  6825. if (dist < curDist)
  6826. {
  6827. idToSet = element.id;
  6828. curDist = dist
  6829. }
  6830. } catch (e) {
  6831. console.log("Error")
  6832. }
  6833. }
  6834. }
  6835. if (idToSet !== 0)
  6836. {
  6837. MapillaryPlayer.moveTo(idToSet).then(
  6838. image => { //console.log(image);
  6839. },
  6840. error => { console.log(error); });
  6841. }}).catch((error) => {
  6842. console.log(error);
  6843. });
  6844. }
  6845.  
  6846. function handleMapillaryHelper(latlng, options)
  6847. {
  6848. return new Promise((resolve, reject) => {
  6849. // console.log("1")
  6850. let bbox = getBBox(latlng, options.meters);
  6851. let URL = "https://graph.mapillary.com/images?access_token={0}&fields=id,computed_geometry&bbox={1}&limit={2}".replace('{0}', MAPILLARY_API_KEY).replace('{1}', bbox).replace('{2}', options.limit)
  6852. // console.log(URL)
  6853. fetch(URL)
  6854. .then((response) => {resolve(response.json())})
  6855. .catch((error) => {console.log(error);});
  6856. });
  6857. }
  6858.  
  6859.  
  6860. /**
  6861. * Minimap presets
  6862. */
  6863.  
  6864. let water_name_only =
  6865. [
  6866. {
  6867. "elementType": "geometry",
  6868. "stylers": [
  6869. {
  6870. "visibility": "off"
  6871. }
  6872. ]
  6873. },
  6874. {
  6875. "featureType": "administrative",
  6876. "stylers": [
  6877. {
  6878. "visibility": "off"
  6879. }
  6880. ]
  6881. },
  6882. {
  6883. "featureType": "landscape",
  6884. "stylers": [
  6885. {
  6886. "visibility": "off"
  6887. }
  6888. ]
  6889. },
  6890. {
  6891. "featureType": "poi",
  6892. "stylers": [
  6893. {
  6894. "visibility": "off"
  6895. }
  6896. ]
  6897. },
  6898. {
  6899. "featureType": "road",
  6900. "stylers": [
  6901. {
  6902. "visibility": "off"
  6903. }
  6904. ]
  6905. },
  6906. {
  6907. "featureType": "transit",
  6908. "stylers": [
  6909. {
  6910. "visibility": "off"
  6911. }
  6912. ]
  6913. }
  6914. ]
  6915. let country_name_only =
  6916. [
  6917. {
  6918. "elementType": "geometry",
  6919. "stylers": [
  6920. {
  6921. "visibility": "off"
  6922. }
  6923. ]
  6924. },
  6925. {
  6926. "featureType": "administrative",
  6927. "stylers": [
  6928. {
  6929. "visibility": "off"
  6930. }
  6931. ]
  6932. },
  6933. {
  6934. "featureType": "administrative.country",
  6935. "elementType": "labels",
  6936. "stylers": [
  6937. {
  6938. "visibility": "on"
  6939. }
  6940. ]
  6941. },
  6942. {
  6943. "featureType": "landscape",
  6944. "stylers": [
  6945. {
  6946. "visibility": "off"
  6947. }
  6948. ]
  6949. },
  6950. {
  6951. "featureType": "poi",
  6952. "stylers": [
  6953. {
  6954. "visibility": "off"
  6955. }
  6956. ]
  6957. },
  6958. {
  6959. "featureType": "road",
  6960. "stylers": [
  6961. {
  6962. "visibility": "off"
  6963. }
  6964. ]
  6965. },
  6966. {
  6967. "featureType": "transit",
  6968. "stylers": [
  6969. {
  6970. "visibility": "off"
  6971. }
  6972. ]
  6973. },
  6974. {
  6975. "featureType": "water",
  6976. "stylers": [
  6977. {
  6978. "visibility": "off"
  6979. }
  6980. ]
  6981. }
  6982. ]
  6983.  
  6984. let no_label_or_terrain =
  6985. [
  6986. {
  6987. "elementType": "geometry",
  6988. "stylers": [
  6989. {
  6990. "visibility": "off"
  6991. }
  6992. ]
  6993. },
  6994. {
  6995. "featureType": "administrative",
  6996. "stylers": [
  6997. {
  6998. "visibility": "off"
  6999. }
  7000. ]
  7001. },
  7002. {
  7003. "featureType": "landscape",
  7004. "stylers": [
  7005. {
  7006. "visibility": "off"
  7007. }
  7008. ]
  7009. },
  7010. {
  7011. "featureType": "poi",
  7012. "stylers": [
  7013. {
  7014. "visibility": "off"
  7015. }
  7016. ]
  7017. },
  7018. {
  7019. "featureType": "road",
  7020. "stylers": [
  7021. {
  7022. "visibility": "off"
  7023. }
  7024. ]
  7025. },
  7026. {
  7027. "featureType": "transit",
  7028. "stylers": [
  7029. {
  7030. "visibility": "off"
  7031. }
  7032. ]
  7033. },
  7034. {
  7035. "featureType": "water",
  7036. "stylers": [
  7037. {
  7038. "visibility": "on"
  7039. }
  7040. ]
  7041. },
  7042. {
  7043. "featureType": "water",
  7044. "elementType": "labels",
  7045. "stylers": [
  7046. {
  7047. "visibility": "off"
  7048. }
  7049. ]
  7050. }
  7051. ]
  7052.  
  7053. let no_label =
  7054. [
  7055. {
  7056. "elementType": "labels",
  7057. "stylers": [
  7058. {
  7059. "visibility": "off"
  7060. }
  7061. ]
  7062. },
  7063. {
  7064. "featureType": "administrative",
  7065. "stylers": [
  7066. {
  7067. "visibility": "off"
  7068. }
  7069. ]
  7070. }
  7071. ]
  7072.  
  7073. let blank =
  7074.  
  7075. [
  7076. {
  7077. "stylers": [
  7078. {
  7079. "visibility": "off"
  7080. }
  7081. ]
  7082. }
  7083. ]
  7084.  
  7085. let thick_border =
  7086.  
  7087. [
  7088. {
  7089. "featureType": "administrative.country",
  7090. "elementType": "geometry.stroke",
  7091. "stylers": [
  7092. {
  7093. "weight": 1.5
  7094. }
  7095. ]
  7096. },
  7097. {
  7098. "featureType": "administrative.province",
  7099. "elementType": "geometry.stroke",
  7100. "stylers": [
  7101. {
  7102. "weight": 3.5
  7103. }
  7104. ]
  7105. }
  7106. ]
  7107.  
  7108. let Indonesia =
  7109. [
  7110. {
  7111. "featureType": "administrative",
  7112. "stylers": [
  7113. {
  7114. "visibility": "off"
  7115. }
  7116. ]
  7117. },
  7118. {
  7119. "featureType": "landscape",
  7120. "elementType": "labels",
  7121. "stylers": [
  7122. {
  7123. "visibility": "off"
  7124. }
  7125. ]
  7126. },
  7127. {
  7128. "featureType": "poi.park",
  7129. "elementType": "labels",
  7130. "stylers": [
  7131. {
  7132. "visibility": "off"
  7133. }
  7134. ]
  7135. },
  7136. {
  7137. "featureType": "road",
  7138. "elementType": "labels",
  7139. "stylers": [
  7140. {
  7141. "visibility": "off"
  7142. }
  7143. ]
  7144. },
  7145. {
  7146. "featureType": "transit",
  7147. "elementType": "labels",
  7148. "stylers": [
  7149. {
  7150. "visibility": "off"
  7151. }
  7152. ]
  7153. },
  7154. {
  7155. "featureType": "water",
  7156. "elementType": "labels",
  7157. "stylers": [
  7158. {
  7159. "visibility": "off"
  7160. }
  7161. ]
  7162. }
  7163. ]
  7164.  
  7165. let dark = [
  7166. {
  7167. "elementType": "geometry",
  7168. "stylers": [
  7169. {
  7170. "color": "#212121"
  7171. }
  7172. ]
  7173. },
  7174. {
  7175. "elementType": "labels.icon",
  7176. "stylers": [
  7177. {
  7178. "visibility": "off"
  7179. }
  7180. ]
  7181. },
  7182. {
  7183. "elementType": "labels.text.fill",
  7184. "stylers": [
  7185. {
  7186. "color": "#757575"
  7187. }
  7188. ]
  7189. },
  7190. {
  7191. "elementType": "labels.text.stroke",
  7192. "stylers": [
  7193. {
  7194. "color": "#212121"
  7195. }
  7196. ]
  7197. },
  7198. {
  7199. "featureType": "administrative",
  7200. "elementType": "geometry",
  7201. "stylers": [
  7202. {
  7203. "color": "#757575"
  7204. }
  7205. ]
  7206. },
  7207. {
  7208. "featureType": "administrative.country",
  7209. "elementType": "labels.text.fill",
  7210. "stylers": [
  7211. {
  7212. "color": "#9e9e9e"
  7213. }
  7214. ]
  7215. },
  7216. {
  7217. "featureType": "administrative.land_parcel",
  7218. "stylers": [
  7219. {
  7220. "visibility": "off"
  7221. }
  7222. ]
  7223. },
  7224. {
  7225. "featureType": "administrative.locality",
  7226. "elementType": "labels.text.fill",
  7227. "stylers": [
  7228. {
  7229. "color": "#bdbdbd"
  7230. }
  7231. ]
  7232. },
  7233. {
  7234. "featureType": "poi",
  7235. "elementType": "labels.text.fill",
  7236. "stylers": [
  7237. {
  7238. "color": "#757575"
  7239. }
  7240. ]
  7241. },
  7242. {
  7243. "featureType": "poi.park",
  7244. "elementType": "geometry",
  7245. "stylers": [
  7246. {
  7247. "color": "#181818"
  7248. }
  7249. ]
  7250. },
  7251. {
  7252. "featureType": "poi.park",
  7253. "elementType": "labels.text.fill",
  7254. "stylers": [
  7255. {
  7256. "color": "#616161"
  7257. }
  7258. ]
  7259. },
  7260. {
  7261. "featureType": "poi.park",
  7262. "elementType": "labels.text.stroke",
  7263. "stylers": [
  7264. {
  7265. "color": "#1b1b1b"
  7266. }
  7267. ]
  7268. },
  7269. {
  7270. "featureType": "road",
  7271. "elementType": "geometry.fill",
  7272. "stylers": [
  7273. {
  7274. "color": "#2c2c2c"
  7275. }
  7276. ]
  7277. },
  7278. {
  7279. "featureType": "road",
  7280. "elementType": "labels.text.fill",
  7281. "stylers": [
  7282. {
  7283. "color": "#8a8a8a"
  7284. }
  7285. ]
  7286. },
  7287. {
  7288. "featureType": "road.arterial",
  7289. "elementType": "geometry",
  7290. "stylers": [
  7291. {
  7292. "color": "#373737"
  7293. }
  7294. ]
  7295. },
  7296. {
  7297. "featureType": "road.highway",
  7298. "elementType": "geometry",
  7299. "stylers": [
  7300. {
  7301. "color": "#3c3c3c"
  7302. }
  7303. ]
  7304. },
  7305. {
  7306. "featureType": "road.highway.controlled_access",
  7307. "elementType": "geometry",
  7308. "stylers": [
  7309. {
  7310. "color": "#4e4e4e"
  7311. }
  7312. ]
  7313. },
  7314. {
  7315. "featureType": "road.local",
  7316. "elementType": "labels.text.fill",
  7317. "stylers": [
  7318. {
  7319. "color": "#616161"
  7320. }
  7321. ]
  7322. },
  7323. {
  7324. "featureType": "transit",
  7325. "elementType": "labels.text.fill",
  7326. "stylers": [
  7327. {
  7328. "color": "#757575"
  7329. }
  7330. ]
  7331. },
  7332. {
  7333. "featureType": "water",
  7334. "elementType": "geometry",
  7335. "stylers": [
  7336. {
  7337. "color": "#000000"
  7338. }
  7339. ]
  7340. },
  7341. {
  7342. "featureType": "water",
  7343. "elementType": "labels.text.fill",
  7344. "stylers": [
  7345. {
  7346. "color": "#3d3d3d"
  7347. }
  7348. ]
  7349. }
  7350. ]
  7351.  
  7352. let default_preset = []
  7353.  
  7354. let presetMinimap = [[default_preset, "Default"],
  7355. [blank, "Blank"],
  7356. [water_name_only, "Oceanman"],
  7357. [country_name_only, "Impossible"],
  7358. [no_label_or_terrain, "Streaks"],
  7359. [no_label, "Easy 5K"],
  7360. [Indonesia, "POI only"],
  7361. [dark, "Dark Mode"],
  7362. [thick_border, "Borders"],
  7363. [default_preset, "Satellite"],
  7364. [default_preset, "Terrain"],
  7365. [default_preset, "Hybrid"],
  7366. [custom, "Custom", customMode]]
  7367.  
  7368. let GEOJSON_INVISIBLE =
  7369. {
  7370. strokeOpacity: 0,
  7371. fillOpacity: 0,
  7372. clickable: false,
  7373. }
  7374.  
  7375. let presetOverlay = [["Clear",""],
  7376. ["Coverage",""],
  7377. ["Official",""],
  7378. ["OSM",""],
  7379. ["City Lights",""],
  7380. ["Watercolor",""],
  7381. ["Toner",""],
  7382. ["Fire",""],
  7383. ["Longitude", "https://raw.githubusercontent.com/Jupaoqq/Jupaoqq.github.io/main/lonl.json"],
  7384. ["Latitude", "https://raw.githubusercontent.com/Jupaoqq/Jupaoqq.github.io/main/latl.json"],
  7385. ["US County","https://raw.githubusercontent.com/CodeForCary/CountyDataUSA5m/master/cb_2017_us_county_5m.json"],
  7386. ["France","https://raw.githubusercontent.com/gregoiredavid/france-geojson/master/departements.geojson"],
  7387. ["Time Zone", "https://raw.githubusercontent.com/treyerl/timezones/master/timezones_wVVG8.geojson"],
  7388. ["UK Parliament", "https://raw.githubusercontent.com/martinjc/UK-GeoJSON/master/json/electoral/gb/wpc.json"],
  7389. ["Custom", YOUR_URL]]
  7390.  
  7391. let satType = [["Satellite","2.5D"],
  7392. ["Satellite","3D"],
  7393. ["Satellite","2D"],
  7394. ["Road", "3D"],
  7395. ["Road", "2D"]]
  7396.  
  7397. let satStyle = [["solarNoon","Noon"],
  7398. ["sunriseEnd","Sunrise"],
  7399. ["goldenHourEnd","Morning"],
  7400. ["goldenHour","Evening"],
  7401. ["sunsetStart","Sunset"],
  7402. ["nadir","Midnight"],
  7403. ["getlocal","Local Time"],
  7404. ];
  7405.  
  7406. let spaceMinimap = [["Earth",""],
  7407. ["Moon", "https://s3.amazonaws.com/opmbuilder/301_moon/tiles/w/hillshaded-albedo/"],
  7408. ["Moon (Labels)", "https://cartocdn-gusc.global.ssl.fastly.net/opmbuilder/api/v1/map/named/opm-moon-basemap-v0-1/all/"],
  7409. ["Mars", "http://s3-eu-west-1.amazonaws.com/whereonmars.cartodb.net/celestia_mars-shaded-16k_global/"],
  7410. ["Mars (Labels)", "https://cartocdn-gusc.global.ssl.fastly.net/opmbuilder/api/v1/map/named/opm-mars-basemap-v0-2/all/"],
  7411. ["Mars-Viking", "http://s3-eu-west-1.amazonaws.com/whereonmars.cartodb.net/viking_mdim21_global/"],
  7412. ]
  7413.  
  7414. let spaceMinimap2 = [["Mercury", "mercury/mercury_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=MESSENGER_May2013"],
  7415. ["Venus", "venus/venus_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=MAGELLAN_color"],
  7416. ["Phobos", "mars/phobos_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=VIKING"],
  7417. ["Deimos", "mars/deimos_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=VIKING"],
  7418. ["Ceres", "asteroid_belt/ceres_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=Ceres_FC_global"],
  7419. ["Vesta", "asteroid_belt/vesta_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=Dawn_HAMO_global"],
  7420. ["Jupiter", "jupiter/jupiter_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=CASSINI"],
  7421. ["Callisto", "jupiter/callisto_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=GALILEO_VOYAGER"],
  7422. ["Europa", "jupiter/europa_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=GALILEO_VOYAGER"],
  7423. ["Ganymede", "jupiter/ganymede_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=GALILEO_VOYAGER"],
  7424. ["Io", "jupiter/io_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=SSI_VGR_color"]
  7425. ]
  7426.  
  7427. let spaceMinimap3 = [["Saturn", "saturn/saturn_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=CASSINI"],
  7428. ["Dione", "saturn/dione_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=CASSINI_VOYAGER"],
  7429. ["Enceladus", "saturn/enceladus_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=CASSINI"],
  7430. ["Iapetus", "saturn/iapetus_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=CASSINI_VOYAGER"],
  7431. ["Mimas", "saturn/mimas_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=CASSINI_MIMAS_MOSAIC"],
  7432. ["Rhea", "saturn/rhea_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=CASSINI_VOYAGER"],
  7433. ["Tethys", "saturn/tethys_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=CASSINI"],
  7434. ["Titan", "saturn/titan_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=CASSINI"],
  7435. ["Uranus", "uranus/uranus_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=JHT_VOYAGER_HST"],
  7436. ["Neptune", "neptune/neptune_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=JHT_VOYAGER"],
  7437. ["Pluto", "pluto/pluto_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=NEWHORIZONS_PLUTO_MOSAIC"],
  7438. ]
  7439.  
  7440. let spaceList = ["Moon", "Mars", "Mercury", "Venus", "Phobos", "Deimos", "Ceres", "Vesta", "Jupiter", "Callisto", "Europa", "Ganymede", "Io",
  7441. "Saturn", "Dione", "Enceladus", "Iapetus", "Mimas", "Rhea", "Tethys", "Titan", "Uranus", "Neptune", "Pluto", "Solar System"];
  7442.  
  7443. function handleSpURL(url, x1, y1, z1)
  7444. {
  7445. function tile2long(x,z) {
  7446. return (x/Math.pow(2,z)*360-180);
  7447. }
  7448. function tile2lat(y,z) {
  7449. var n=Math.PI-2*Math.PI*y/Math.pow(2,z);
  7450. return (180/Math.PI*Math.atan(0.5*(Math.exp(n)-Math.exp(-n))));
  7451. }
  7452.  
  7453. let NWlon = tile2long(x1,z1)
  7454. let NWlat = tile2lat(y1,z1)
  7455. let SElon = tile2long(x1 + 1,z1)
  7456. let SElat = tile2lat(y1 + 1,z1)
  7457. return "https://planetarymaps.usgs.gov/cgi-bin/mapserv?map=/maps/" + url + "&WIDTH=256&HEIGHT=256&CRS=EPSG%3A4326&STYLES=&BBOX=" + `${SElat}%2C${NWlon}%2C${NWlat}%2C${SElon}`;
  7458. }
  7459.  
  7460. // return `https://tiles.mapgenie.io/games/gta5/los-santos/satellite/${z}/${x}/${y}.png`
  7461. // return `https://mapsv0.bdimg.com/tile/?udt=20200825&qt=tile&styles=pl&x=${x}&y=${y}&z=${z+2}`
  7462.  
  7463. let langDict = {
  7464. "sn": ["fr"],
  7465. "za": ["af"],
  7466. "mg": ["mg", "fr"],
  7467. "tn": ["ar"],
  7468. "bd": ["bn"],
  7469. "kh": ["km"],
  7470. "in": ["hi"],
  7471. "cn": ["zh"],
  7472. "hk": ["zh"],
  7473. "id": ["id"],
  7474. "ir": ["fa"],
  7475. "il": ["he"],
  7476. "jp": ["ja"],
  7477. "jo": ["ar"],
  7478. "ky": ["ru", "ky"],
  7479. "la": ["lo"],
  7480. "my": ["ms"],
  7481. "mn": ["mn"],
  7482. "np": ["ne"],
  7483. "ru": ["ru"],
  7484. "sg": ["zh"],
  7485. "kr": ["ko"],
  7486. "lk": ["ta"],
  7487. "tw": ["zh"],
  7488. "th": ["th"],
  7489. "ae": ["ar"],
  7490. "vn": ["vi"],
  7491. "al": ["sq"],
  7492. "ad": ["es", "fr"],
  7493. "at": ["de"],
  7494. "be": ["nl", "fr"],
  7495. "bg": ["bg"],
  7496. "hr": ["hr"],
  7497. "cy": ["el"],
  7498. "cz": ["cs"],
  7499. "dk": ["da"],
  7500. "ee": ["et"],
  7501. "fo": ["fo"],
  7502. "fi": ["fi"],
  7503. "fr": ["fr"],
  7504. "de": ["de"],
  7505. "gr": ["el"],
  7506. "hu": ["hu"],
  7507. "is": ["is"],
  7508. "ie": ["ga"],
  7509. "it": ["it"],
  7510. "lv": ["lv"],
  7511. "lt": ["lt"],
  7512. "lu": ["lb", "fr", "de"],
  7513. "mc": ["fr"],
  7514. "nl": ["nl"],
  7515. "mk": ["mk"],
  7516. "no": ["no"],
  7517. "pl": ["pl"],
  7518. "pt": ["pt"],
  7519. "ro": ["ro"],
  7520. "sm": ["it"],
  7521. "rs": ["sr"],
  7522. "sk": ["sk"],
  7523. "si": ["sl"],
  7524. "es": ["es"],
  7525. "se": ["sv"],
  7526. "ch": ["de", "fr"],
  7527. "tr": ["tr"],
  7528. "ua": ["uk"],
  7529. "cw": ["nl"],
  7530. "do": ["es"],
  7531. "gt": ["es"],
  7532. "mx": ["es"],
  7533. "pr": ["es"],
  7534. "ar": ["es"],
  7535. "bo": ["es"],
  7536. "br": ["pt"],
  7537. "cl": ["es"],
  7538. "ec": ["es"],
  7539. "pe": ["es"],
  7540. "uy": ["es"]
  7541. };
  7542.  
  7543. // ch, lu, be, ad