GeoGuessr Custom Maps

playing with modified maps in geoguessr games

当前为 2025-03-25 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name GeoGuessr Custom Maps
  3. // @description playing with modified maps in geoguessr games
  4. // @version 1.1.8
  5. // @match *://www.geoguessr.com/*
  6. // @author KaKa
  7. // @license BSD
  8. // @require https://update.gf.qytechs.cn/scripts/502813/1423193/Geoguessr%20Tag.js
  9. // @icon https://www.svgrepo.com/show/392367/interaction-interface-layer-layers-location-map.svg
  10. // @namespace https://gf.qytechs.cn/users/1179204
  11. // ==/UserScript==
  12.  
  13. (function() {
  14.  
  15. /*=========================================================================Modifiy your guess map here==================================================================================*/
  16.  
  17. let customOptions={
  18.  
  19. Language:'en', //en,zh,ja,fr,de,es
  20.  
  21. Google_StreetView_Layer_Lines_Style:'Default', // More styles see below
  22.  
  23. Google_StreetView_Layer_Shortcut:'V',
  24.  
  25. Google_Labels_Layer_Shortcut:'G',
  26.  
  27. Google_Terrain_Layer_Shortcut:'T',
  28.  
  29. Google_Satellite_Layer_Shortcut:'B',
  30.  
  31. Apple_StreetView_Layer_Shortcut:'P',
  32.  
  33. Yandex_StreetView_Layer_Shortcut:'Y',
  34.  
  35. OpenWeather_Shortcut:'Q',
  36.  
  37. OpenWeather_Style:'radar', //'radar': Global Precipitation; 'CL':Cloud; 'APM':Pressure; 'TA2'Temperature; 'WS10':Wind Speed;
  38.  
  39. OpenWeather_Date:'now', // foramt:yyyy-mm-dd, less than one week ago
  40.  
  41. Bing_Maps_Style:'r', // 'a':satellite(without labels); 'h':hybrid; 'r':roadmap,'sre':terrain
  42.  
  43. Map_Tiler_Style:'basic', //basic,satellite,bright,landscape,ocean,outdoor,topo,streets,dataviz
  44.  
  45. Carto_Style:'light_all', //light_all,dark_all
  46.  
  47. Thunderforest_Style:'spinal-map'} //spinal-map,landscape,outdoors,atlas,transport,
  48.  
  49.  
  50. let tileServices=["Google_Maps","OpenStreetMap","Bing_Maps","Map_Tiler","Thunderforest","Carto","Yandex_Maps","Petal_Maps"]
  51.  
  52. let colorOptions={
  53.  
  54. Default:['1098ad','99e9f2'],
  55.  
  56. Crimson:['f03e3e','ffc9c9'],
  57.  
  58. Deep_Pink:['d6336c','fcc2d7'],
  59.  
  60. Blue_Violet:['ae3ec9','eebefa'],
  61.  
  62. Slate_Blue:['7048e8','d0bfff'],
  63.  
  64. Royal_Blue:['4263eb','bac8ff'],
  65.  
  66. Dodger_Blue: ['1c7ed6','a5d8ff'],
  67.  
  68. Sea_Green:['0ca678','96f2d7'],
  69.  
  70. Lime_Green:['37b24d','b2f2bb'],
  71.  
  72. OliveDrab:['74b816','d8f5a2'],
  73.  
  74. Orange:['f59f00','ffec99'],
  75.  
  76. Dark_Orange:['f76707','ffd8a8'],
  77.  
  78. Brown:['bd5f1b','f7ca9e'],
  79. }
  80.  
  81. /*======================================================================================================================================================================================*/
  82.  
  83. let map,google,customMapType,initLayer=tag
  84. let currentLayers=JSON.parse(localStorage.getItem('custom_layers'));
  85. if(!currentLayers){
  86. currentLayers=["Google_Maps","Google_Labels"]
  87. localStorage.setItem('custom_layers', JSON.stringify(currentLayers));
  88. }
  89.  
  90. const openWeatherBaseURL = "https://g.sat.owm.io/vane/2.0/weather";
  91. const radarURL = `https://b.sat.owm.io/maps/2.0/radar/{z}/{x}/{y}?appid=9de243494c0b295cca9337e1e96b00e2&day=${getNow(customOptions.OpenWeather_Date)}`;
  92.  
  93. const openWeatherURL = (customOptions.OpenWeather_Style === 'radar')
  94. ? radarURL
  95. : `${openWeatherBaseURL}/${customOptions.OpenWeather_Style}/{z}/{x}/{y}?appid=9de243494c0b295cca9337e1e96b00e2&&date=${getTimestamp(customOptions.OpenWeather_Date)}&fill_bound=true`;
  96.  
  97. let tileUrls = {
  98. Petal_Maps: `https://maprastertile-drcn.dbankcdn.cn/display-service/v1/online-render/getTile/24.12.10.10/{z}/{x}/{y}/?language=${customOptions.Language}&p=46&scale=2&mapType=ROADMAP&presetStyleId=standard&pattern=JPG&key=DAEDANitav6P7Q0lWzCzKkLErbrJG4kS1u%2FCpEe5ZyxW5u0nSkb40bJ%2BYAugRN03fhf0BszLS1rCrzAogRHDZkxaMrloaHPQGO6LNg==`,
  99. OpenStreetMap: "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
  100. Map_Tiler:`https://api.maptiler.com/maps/${customOptions.Map_Tiler_Style}-v2/256/{z}/{x}/{y}.png?key=0epLOAjD7fw17tghcyee`,
  101. Thunderforest:`https://b.tile.thunderforest.com/${customOptions.Thunderforest_Style}/{z}/{x}/{y}@2x.png?apikey=6a53e8b25d114a5e9216df5bf9b5e9c8`,
  102. Carto:`https://cartodb-basemaps-3.global.ssl.fastly.net/${customOptions.Carto_Style}/{z}/{x}/{y}.png`,
  103. Google_Maps:`https://mapsresources-pa.googleapis.com/v1/tiles?map_id=61449c20e7fc278b&version=15797339025669136861&pb=!1m5!1m4!1i{z}!2i{x}!3i{y}!4i256!2m3!1e0!2sm!3i725483392!3m12!2s${customOptions.Language}!3sUS!5e18!12m4!1e68!2m2!1sset!2sRoadmap!12m3!1e37!2m1!1ssmartmaps!12m4!1e26!2m2!1sstyles!2ss.e:l|p.w:off,s.t:0.8|s.e:g.s|p.v:off!5m1!5f1.5`,
  104. Google_Terrain:`https://mapsresources-pa.googleapis.com/v1/tiles?map_id=61449c20e7fc278b&version=15797339025669136861&pb=!1m5!1m4!1i{z}!2i{x}!3i{y}!4i256!2m3!1e4!2st!3i725!2m3!1e0!2sr!3i725483392!3m12!2s${customOptions.Language}!3sUS!5e18!12m4!1e68!2m2!1sset!2sTerrain!12m3!1e37!2m1!1ssmartmaps!4e0!5m2!1e3!5f2!23i56565656!26m2!1e2!1e3`,
  105. Google_Satellite:`https://mts1.googleapis.com/vt?hl=${customOptions.Language}-US&lyrs=s&x={x}&y={y}&z={z}`,
  106. Google_StreetView:`https://maps.googleapis.com/maps/vt?pb=%211m5%211m4%211i{z}%212i{x}%213i{y}%214i256%212m8%211e2%212ssvv%214m2%211scc%212s*211m3*211e2*212b1*213e2*212b1*214b1%214m2%211ssvl%212s*212b1%213m17%212sen%213sUS%215e18%2112m4%211e68%212m2%211sset%212sRoadmap%2112m3%211e37%212m1%211ssmartmaps%2112m4%211e26%212m2%211sstyles%212ss.e%3Ag.f%7Cp.c%3A%23${colorOptions[customOptions.Google_StreetView_Layer_Lines_Style][0]}%7Cp.w%3A1%2Cs.e%3Ag.s%7Cp.c%3A%23${colorOptions[customOptions.Google_StreetView_Layer_Lines_Style][1]}%7Cp.w%3A3%215m1%215f1.35`,
  107. Google_Satellite_Road:`https://maps.googleapis.com/maps/vt?pb=!1m5!1m4!1i{z}!2i{x}!3i{y}!4i256!2m2!1e0!2sm!3m14!2s${customOptions.Language}!3sUS!5e18!12m4!1e68!2m2!1sset!2sRoadmapSatellite!12m3!1e37!2m1!1ssmartmaps!12m1!1e3!5m1!5f1.35`,
  108. Google_Labels:`https://maps.googleapis.com/maps/vt?pb=!1m5!1m4!1i{z}!2i{x}!3i{y}!4i256!2m2!1e0!2sm!3m17!2s${customOptions.Language}!3sUS!5e1105!12m4!1e68!2m2!1sset!2sRoadmap!12m3!1e37!2m1!1ssmartmaps!12m4!1e26!2m2!1sstyles!2ss.t:18|s.e:g.s|p.w:3,s.e:g|p.v:off,s.t:1|s.e:g.s|p.v:off,s.e:l|p.v:on!4i0!5m2!1e0!5f2`,
  109. Apple_StreetView:`https://lookmap.eu.pythonanywhere.com/bluelines_raster_2x/{z}/{x}/{y}.png`,
  110. Yandex_StreetView:`https://vec04.core-stv-renderer.maps.yandex.net/2.x/tiles?l=stv&x={x}&y={y}&z={z}&scale=1&v=2024.12.07.15.37-1_24.12.06-1-22840`,
  111. Yandex_Maps:`https://core-renderer-tiles.maps.yandex.net/tiles?l=map&v=24.09.06-3-b240906182700&x={x}&y={y}&z={z}&scale=1&lang=${customOptions.Language}_US`,
  112. OpenWeather: openWeatherURL
  113. }
  114.  
  115. function getMap(){
  116. let element = document.getElementsByClassName("guess-map_canvas__cvpqv")[0]
  117. if(!element) element=document.getElementsByClassName("run-game-guess-map-contents_canvas__XQRwC")[0]
  118. if(!element) return
  119. try{
  120. //if (!element) element=document.getElementsByClassName("coordinate-result-map_map__Yh2Il")[0]
  121. const keys = Object.keys(element)
  122.  
  123. const key = keys.find(key => key.startsWith("__reactFiber$"))
  124. const props = element[key]
  125. map=props.return.return.memoizedProps.map
  126. if(!map) map=props.return.memoizedState.memoizedState.current.instance
  127. google=unsafeWindow.google
  128. customMapType=setMapType()
  129. const layers =new customMapType(currentLayers.map(layerName => setTileLayer(layerName)));
  130. map.mapTypes.set("roadmap",layers)
  131. }
  132. catch(error){
  133. console.error('Failed to get map')
  134. }
  135. }
  136.  
  137. function OC(controlDiv, layer) {
  138. controlDiv.style.margin='10px'
  139. controlDiv.style.backgroundColor = '#fff';
  140. controlDiv.style.height = '30px';
  141. controlDiv.style.boxShadow = 'rgba(0, 0, 0, 0.3) 0px 1px 4px -1px';
  142. controlDiv.style.borderRadius = '5px';
  143.  
  144. var opacitySlider = document.createElement('input');
  145.  
  146. opacitySlider.setAttribute('type', 'range');
  147. opacitySlider.setAttribute('min', '0');
  148. opacitySlider.setAttribute('max', '100');
  149. opacitySlider.setAttribute('value', '100');
  150. opacitySlider.setAttribute('step', '1');
  151. opacitySlider.style.width = '100px';
  152. opacitySlider.style.height='20px'
  153. opacitySlider.style.marginTop='5px'
  154. opacitySlider.addEventListener('input', function() {
  155. var opacity = opacitySlider.value / 100
  156. layer.set('opacity',opacity)
  157. });
  158.  
  159. controlDiv.appendChild(opacitySlider);
  160. }
  161.  
  162. function addOpacityControl(m, layer) {
  163. var opacityControlDiv = document.createElement('div');
  164. new OC(opacityControlDiv, layer);
  165. opacityControlDiv.id=layer.name
  166. opacityControlDiv.index = 1;
  167. m.controls[google.maps.ControlPosition.TOP_RIGHT].push(opacityControlDiv);
  168. }
  169.  
  170. function removeOpacityControl(id) {
  171. var controls = map.controls[google.maps.ControlPosition.TOP_RIGHT];
  172. if(controls&&controls.getLength()>0){
  173. if(!id) controls.removeAt(0)
  174. else{
  175. for (var i = 0; i < controls.getLength(); i++) {
  176. var control = controls.getAt(i);
  177. if (control.id === id) {
  178. controls.removeAt(i);
  179. break;
  180. }
  181. }
  182. }
  183. }
  184. }
  185.  
  186. function MR(e, t) {
  187. return new Promise(n => {
  188. google.maps.event.addListenerOnce(e, t, n);
  189. });
  190. }
  191.  
  192. function getNow(date) {
  193. if(date!='now'){
  194. return date
  195. }
  196. const now = new Date();
  197. now.setHours(now.getHours() - 1);
  198. return now.toISOString().slice(0, 14)+'00';
  199. }
  200.  
  201. function getTimestamp(date){
  202. var parsedDate
  203. if (date=== 'now') {
  204. parsedDate= new Date()
  205. return Math.floor(parsedDate.getTime() / 1000)
  206. }
  207. parsedDate = new Date(date);
  208.  
  209. if (isNaN(parsedDate.getTime())) {
  210. throw new Error('Invalid date format');
  211. }
  212. return Math.floor(parsedDate.getTime() / 1000);
  213.  
  214. }
  215.  
  216. function extractTileCoordinates(url) {
  217. const regex = /!1i(\d+)!2i(\d+)!3i(\d+)!4i(\d+)/;
  218. const matches = url.match(regex);
  219.  
  220. if (matches && matches.length === 5) {
  221. const z = matches[1];
  222. const x = matches[2];
  223. const y = matches[3];
  224. return { z, x, y };
  225. } else {
  226. return null;
  227. }
  228. }
  229.  
  230. function BaiduProjection() {
  231. var R = 6378206;
  232. var R_MINOR = 6356584.314245179;
  233. var bounds = new google.maps.LatLngBounds(
  234. new google.maps.LatLng(-19994619.55417086, -20037725.11268234),
  235. new google.maps.LatLng(19994619.55417086, 20037725.11268234)
  236. );
  237.  
  238. this.fromLatLngToPoint = function(latLng) {
  239.  
  240. var lat = latLng.lat() * Math.PI / 180;
  241. var lng = latLng.lng() * Math.PI / 180;
  242.  
  243. var x = lng * R;
  244. var y = Math.log(Math.tan(Math.PI / 4 + lat / 2)) * R;
  245.  
  246. var scale = 1 / Math.pow(2, 18);
  247. var origin = new google.maps.Point(bounds.getSouthWest().lng(), bounds.getNorthEast().lat());
  248. return new google.maps.Point(
  249. (x - origin.x) * scale,
  250. (origin.y - y) * scale
  251. );
  252. };
  253.  
  254. this.fromPointToLatLng = function(point) {
  255. var scale = 1 / Math.pow(2, 18);
  256. var origin = new google.maps.Point(bounds.getSouthWest().lng(), bounds.getNorthEast().lat());
  257.  
  258. var x = point.x / scale + origin.x;
  259. var y = origin.y - point.y / scale;
  260.  
  261. var lng = x / R * 180 / Math.PI;
  262. var lat = (2 * Math.atan(Math.exp(y / R)) - Math.PI / 2) * 180 / Math.PI;
  263.  
  264. return new google.maps.LatLng(lat, lng);
  265. };
  266.  
  267. return this;
  268. }
  269.  
  270. function getBingTiles(tileX, tileY, zoom, type) {
  271. var quadKey = tileXYToQuadKey(tileX, tileY, zoom);
  272. if(type==='cn'){
  273. const subdomains = ['r1', 'r2', 'r0', 'r3'];
  274. const subdomain = subdomains[(tileX + tileY) % subdomains.length];
  275. const baseUrl=`https://t.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/${quadKey}?mkt=zh-CN&ur=cn&it=G,LC,L&jp=1&og=2618&sv=9.33&n=t&dre=1&o=webp,95&cstl=s23&st=bld|v:0`
  276. return baseUrl
  277. }
  278. else{
  279.  
  280. const subdomains = ['ecn.t0', 'ecn.t1', 'ecn.t2', 'ecn.t3'];
  281.  
  282. const subdomain = subdomains[(tileX + tileY) % subdomains.length];
  283. const baseUrl = `https://${subdomain}.tiles.virtualearth.net/tiles/`;
  284.  
  285. return baseUrl + type + quadKey + '.jpeg?g=14792';}
  286. }
  287.  
  288. function tileXYToQuadKey(tileX, tileY, zoom) {
  289. var quadKey = '';
  290. for (var i = zoom; i > 0; i--) {
  291. var digit = 0;
  292. var mask = 1 << (i - 1);
  293. if ((tileX & mask) !== 0) {
  294. digit += 1;
  295. }
  296. if ((tileY & mask) !== 0) {
  297. digit += 2;
  298. }
  299. quadKey += digit.toString();
  300. }
  301. return quadKey;
  302. }
  303.  
  304. function setMapType(){
  305. class customMapType extends google.maps.ImageMapType {
  306. constructor(layers, options = null) {
  307. const defaultOptions = {
  308. getTileUrl: function(coord, zoom) {
  309. return null;
  310. },
  311. tileSize: new google.maps.Size(256, 256),
  312. maxZoom: 20,
  313. name: 'CustomMapType',
  314. };
  315.  
  316.  
  317. super({...defaultOptions, ...options});
  318. this.layers = layers;
  319. }
  320.  
  321. getTile(t, n, r) {
  322. const o = this.layers.map(i => {
  323. if (typeof i.getTile !== 'function') {
  324. console.error('getTile method is missing in layer:', i);
  325. }
  326. return i.getTile(t, n, r);
  327. });
  328. const s = document.createElement("div");
  329. s.append(...o);
  330.  
  331. Promise.all(o.map(i => MR(i, "load"))).then(() => {
  332. google.maps.event.trigger(s, "load");
  333. });
  334.  
  335. return s;
  336. }
  337.  
  338.  
  339. releaseTile(tile) {
  340. let index = 0;
  341. for (const child of tile.children) {
  342. if (child instanceof HTMLElement) {
  343. this.layers[index]?.releaseTile(child);
  344. index += 1;
  345. }
  346. }
  347. }
  348. }
  349. return customMapType
  350. }
  351.  
  352. function setTileLayer(layerName){
  353.  
  354. var tileLayer
  355. const tileUrl = tileUrls[layerName];
  356. if (layerName==='Bing_Maps'){
  357. tileLayer = new google.maps.ImageMapType({
  358. getTileUrl: function(coord, zoom) {
  359. return getBingTiles(coord.x,coord.y,zoom,customOptions.Bing_Maps_Style)
  360. .replace('{z}', zoom)
  361. .replace('{x}', coord.x)
  362. .replace('{y}', coord.y);
  363. },
  364. tileSize: new google.maps.Size(256, 256),
  365. name: layerName,
  366. maxZoom:20
  367. });}
  368. else if(layerName==='Bing_Terrain'){
  369. tileLayer = new google.maps.ImageMapType({
  370. getTileUrl: function(coord, zoom) {
  371. if(zoom>15) return ``
  372. return getBingTiles(coord.x,coord.y,zoom,'sre')
  373. .replace('{z}', zoom)
  374. .replace('{x}', coord.x)
  375. .replace('{y}', coord.y);
  376. },
  377. tileSize: new google.maps.Size(256, 256),
  378. name: layerName,
  379. maxZoom:15
  380. });}
  381. else if(layerName==='Bing_Maps_CN'){
  382. tileLayer = new google.maps.ImageMapType({
  383. getTileUrl: function(coord, zoom) {
  384. return getBingTiles(coord.x,coord.y,zoom,'cn')
  385. .replace('{z}', zoom)
  386. .replace('{x}', coord.x)
  387. .replace('{y}', coord.y);
  388. },
  389. tileSize: new google.maps.Size(256, 256),
  390. name: layerName,
  391. maxZoom:20
  392. });}
  393. else{
  394. tileLayer = new google.maps.ImageMapType({
  395. getTileUrl: function(coord, zoom) {
  396. return tileUrl
  397. .replace('{z}', zoom)
  398. .replace('{x}', coord.x)
  399. .replace('{y}', coord.y);
  400. },
  401. tileSize: new google.maps.Size(256, 256),
  402. name:layerName,
  403. maxZoom:20,
  404. })}
  405. if (layerName.includes('StreetView') || layerName.includes('Weather')) {
  406. if (!document.getElementById(layerName)) addOpacityControl(map, tileLayer);
  407. }
  408. return tileLayer
  409. }
  410.  
  411. let onKeyDown = (e) => {
  412. if ( e.target.tagName === 'TEXTAREA' || e.target.isContentEditable) return
  413. if(e.key!=customOptions.Google_Satellite_Layer_Shortcut ||e.key!=customOptions.Google_Satellite_Layer_Shortcut.toLowerCase())currentLayers = currentLayers.filter(layer => layer !== 'Google_Satellite_Road')
  414. if (e.key >= '1' && e.key <= '7') {
  415. e.stopImmediatePropagation();
  416. if(!map) getMap()
  417. const tileIndex=parseInt(e.key)
  418. const layerName=tileServices[tileIndex]
  419. if(!currentLayers.includes(layerName)){
  420. initLayer(`layer:${layerName}`)
  421. currentLayers[0]=layerName
  422. currentLayers = currentLayers.filter(layer => layer !== 'Google_Labels')
  423. const layers =new customMapType(currentLayers.map(layerName => setTileLayer(layerName)));
  424. map.mapTypes.set("roadmap",layers)
  425. }
  426.  
  427. else {
  428. currentLayers[0]='Google_Maps'
  429. if(!currentLayers.includes('Google_Labels'))currentLayers.push('Google_Labels')
  430. const layers =new customMapType(currentLayers.map(layerName => setTileLayer(layerName)));
  431. map.mapTypes.set("roadmap",layers)
  432. }
  433. }
  434.  
  435. else if (e.key === '0') {
  436. e.stopImmediatePropagation();
  437. if(!map) getMap()
  438. currentLayers[0]='Google_Maps'
  439. initLayer('layer:Classic Style')
  440. if(!currentLayers.includes('Google_Labels'))currentLayers.push('Google_Labels')
  441. const layers =new customMapType(currentLayers.map(layerName => setTileLayer(layerName)));
  442. map.mapTypes.set("roadmap",layers)
  443. }
  444.  
  445. else if (e.key === customOptions.Google_StreetView_Layer_Shortcut.toLowerCase()|| e.key === customOptions.Google_StreetView_Layer_Shortcut) {
  446. e.stopImmediatePropagation();
  447. if(!map) getMap()
  448. initLayer(`layer:Google_StreetView`)
  449. if(!currentLayers.includes('Google_StreetView')){
  450. currentLayers.splice(1, 0, 'Google_StreetView');
  451. const layers =new customMapType(currentLayers.map(layerName => setTileLayer(layerName)));
  452. map.mapTypes.set("roadmap",layers)
  453. }
  454. else{currentLayers = currentLayers.filter(layer => layer !== 'Google_StreetView')
  455. removeOpacityControl('Google_StreetView')
  456. const layers =new customMapType(currentLayers.map(layerName => setTileLayer(layerName)));
  457. map.mapTypes.set("roadmap",layers)}
  458. }
  459.  
  460. else if (e.key === customOptions.Apple_StreetView_Layer_Shortcut.toLowerCase()|| e.key === customOptions.Apple_StreetView_Layer_Shortcut) {
  461. e.stopImmediatePropagation();
  462. if(!map) getMap()
  463. if(!currentLayers.includes('Apple_StreetView')){
  464. initLayer(`layer:Apple_StreetView`)
  465. currentLayers.splice(1, 0, 'Apple_StreetView');
  466. const layers =new customMapType(currentLayers.map(layerName => setTileLayer(layerName)));
  467. map.mapTypes.set("roadmap",layers)
  468. }
  469. else{currentLayers = currentLayers.filter(layer => layer !== 'Apple_StreetView')
  470. removeOpacityControl('Apple_StreetView')
  471. const layers =new customMapType(currentLayers.map(layerName => setTileLayer(layerName)));
  472. map.mapTypes.set("roadmap",layers)}
  473. }
  474.  
  475. else if (e.key === customOptions.Yandex_StreetView_Layer_Shortcut.toLowerCase()|| e.key === customOptions.Yandex_StreetView_Layer_Shortcut) {
  476. e.stopImmediatePropagation();
  477. if(!map) getMap()
  478. initLayer(`layer:Yandex_StreetView`)
  479. if(!currentLayers.includes('Yandex_StreetView')){
  480. currentLayers.splice(1, 0, 'Yandex_StreetView');
  481. const layers =new customMapType(currentLayers.map(layerName => setTileLayer(layerName)));
  482. map.mapTypes.set("roadmap",layers)
  483. }
  484. else{currentLayers = currentLayers.filter(layer => layer !== 'Yandex_StreetView')
  485. removeOpacityControl('Yandex_StreetView')
  486. const layers =new customMapType(currentLayers.map(layerName => setTileLayer(layerName)));
  487. map.mapTypes.set("roadmap",layers)}
  488. }
  489.  
  490. else if (e.key === customOptions.Google_Labels_Layer_Shortcut.toLowerCase()|| e.key === customOptions.Google_Labels_Layer_Shortcut) {
  491. e.stopImmediatePropagation();
  492. if(!map) getMap()
  493. initLayer(`layer:Google_Labels`)
  494. if(!currentLayers.includes('Google_Labels')){
  495. currentLayers.push('Google_Labels');
  496. const layers =new customMapType(currentLayers.map(layerName => setTileLayer(layerName)))
  497. map.mapTypes.set("roadmap",layers)}
  498.  
  499. else{currentLayers = currentLayers.filter(layer => layer !== 'Google_Labels')
  500. const layers =new customMapType(currentLayers.map(layerName => setTileLayer(layerName)))
  501. map.mapTypes.set("roadmap",layers)}
  502. }
  503.  
  504. else if (e.key === customOptions.Google_Terrain_Layer_Shortcut.toLowerCase()|| e.key === customOptions.Google_Terrain_Layer_Shortcut) {
  505. e.stopImmediatePropagation();
  506. if(!map) getMap()
  507. initLayer(`layer:Google_Terrain`)
  508. if(!currentLayers.includes('Google_Terrain')){
  509. currentLayers[0]='Google_Terrain'
  510. if(!currentLayers.includes('Google_Labels'))currentLayers.push('Google_Labels')
  511. const layers =new customMapType(currentLayers.map(layerName => setTileLayer(layerName)));
  512. map.mapTypes.set("roadmap",layers)}
  513. else {
  514. currentLayers[0]='Google_Maps'
  515. if(!currentLayers.includes('Google_Labels'))currentLayers.push('Google_Labels')
  516. const layers =new customMapType(currentLayers.map(layerName => setTileLayer(layerName)));
  517. map.mapTypes.set("roadmap",layers)
  518. }
  519. }
  520.  
  521. else if (e.key === customOptions.Google_Satellite_Layer_Shortcut.toLowerCase()|| e.key === customOptions.Google_Satellite_Layer_Shortcut) {
  522. e.stopImmediatePropagation();
  523. if(!map) getMap()
  524. initLayer(`layer:Google_Satellite`)
  525. if(!currentLayers.includes('Google_Satellite')){
  526. currentLayers[0]='Google_Satellite'
  527. currentLayers.splice(1, 0, 'Google_Satellite_Road');
  528. if(!currentLayers.includes('Google_Labels'))currentLayers.push('Google_Labels')
  529. const layers =new customMapType(currentLayers.map(layerName => setTileLayer(layerName)));
  530. map.mapTypes.set("roadmap",layers)}
  531. else {
  532. currentLayers[0]='Google_Maps'
  533. currentLayers = currentLayers.filter(layer => layer !== 'Google_Satellite_Road')
  534. if(!currentLayers.includes('Google_Labels'))currentLayers.push('Google_Labels')
  535. const layers =new customMapType(currentLayers.map(layerName => setTileLayer(layerName)));
  536. map.mapTypes.set("roadmap",layers)
  537. }
  538. }
  539.  
  540. else if (e.key === customOptions.OpenWeather_Shortcut.toLowerCase()|| e.key === customOptions.OpenWeather_Shortcut) {
  541. e.stopImmediatePropagation();
  542. if(!map) getMap()
  543. if(!currentLayers.includes('OpenWeather')){
  544. initLayer(`layer:OpenWeather`)
  545. currentLayers.splice(1, 0, 'OpenWeather');
  546. const layers =new customMapType(currentLayers.map(layerName => setTileLayer(layerName)));
  547. map.mapTypes.set("roadmap",layers)
  548. }
  549. else{currentLayers = currentLayers.filter(layer => layer !== 'OpenWeather')
  550. removeOpacityControl('OpenWeather')
  551. const layers =new customMapType(currentLayers.map(layerName => setTileLayer(layerName)));
  552. map.mapTypes.set("roadmap",layers)}
  553. }
  554.  
  555. else if (e.key === 'e'|| e.key ==='E') {
  556. if(!map) getMap()
  557. e.stopImmediatePropagation();
  558. currentLayers=['Google_Maps_new']
  559. const layers =new customMapType(currentLayers.map(layerName => setTileLayer(layerName)));
  560. map.mapTypes.set("roadmap",layers)
  561. }
  562.  
  563. localStorage.setItem('custom_layers', JSON.stringify(currentLayers));
  564. map.setMapTypeId("roadmap")
  565. }
  566.  
  567. document.addEventListener("keydown", onKeyDown);
  568. const intervalId = setInterval(() => {
  569. getMap();
  570. if (map) {
  571. clearInterval(intervalId)}
  572. }, 500);
  573.  
  574. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址