diff --git a/vendor/clouds3d.js b/vendor/clouds3d.js index 6003a5f..d94a81f 100644 --- a/vendor/clouds3d.js +++ b/vendor/clouds3d.js @@ -13,6 +13,14 @@ // Progress and build diagnostics are only interesting while the debug panel // is on; a wall display must not fill the console with them. var DEBUG_LOG = !!(window.CONFIG && window.CONFIG.debug); +var BASE_PATH = (function () { + var p = window.location.pathname || '/'; + if (p.charAt(p.length - 1) !== '/') { + var i = p.lastIndexOf('/'); + p = i >= 0 ? p.substring(0, i + 1) : '/'; + } + return p; +})(); function dbgLog() { if (DEBUG_LOG) console.log.apply(console, arguments); } @@ -1408,7 +1416,7 @@ var GROUND_STYLE = GROUND_STYLE_CFG === 'satellite' ? 'satellite' : 'streets'; var GROUND_TILE_DIRECT = (GROUND_STYLE === 'satellite') ? 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/' : 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/'; -var GROUND_TILE_PROXY = (GROUND_STYLE === 'satellite') ? '/esri/imagery/' : '/esri/streets/'; +var GROUND_TILE_PROXY = BASE_PATH + (GROUND_STYLE === 'satellite' ? 'esri/imagery/' : 'esri/streets/'); // direct by default: works from any origin, including a plain file:// open var GROUND_TILE_URL = GROUND_TILE_DIRECT; var GROUND_TILE_ID_PREFIX = GROUND_STYLE === 'satellite' ? 'sat/' : ''; @@ -2127,7 +2135,7 @@ var ELEV_UNIT_PX = 256 / ELEV_TILES_PER; // canvas px per z11 tile // elevation-tiles-prod (AWS) answers cross-origin GETs with CORS, so the // DEM also loads without our server; /terrarium/ is preferred when present. var ELEV_TILE_DIRECT = 'https://s3.amazonaws.com/elevation-tiles-prod/terrarium/'; -var ELEV_TILE_PROXY = '/terrarium/'; +var ELEV_TILE_PROXY = BASE_PATH + 'terrarium/'; var ELEV_TILE_URL = ELEV_TILE_DIRECT; // (the probe needs both URL pairs assigned, so it runs here, not at the // ground-source block) @@ -3184,14 +3192,14 @@ var OP_PUBLIC = [ 'https://overpass-api.de/api/interpreter', 'https://maps.mail.ru/osm/tools/overpass/api/interpreter' ]; -var OP_PROXY = ['/overpass/api/interpreter', '/overpass/mail/interpreter']; +var OP_PROXY = [BASE_PATH + 'overpass/api/interpreter', BASE_PATH + 'overpass/mail/interpreter']; var CAR_ENDPOINTS = OP_PUBLIC.slice(); var _opProxyChecked = false; function opProbeProxy() { if (_opProxyChecked) return; _opProxyChecked = true; if (location.protocol === 'file:') return; - fetch('/overpass/api/interpreter', { + fetch(OP_PROXY[0], { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: 'data=' + encodeURIComponent('[out:json][timeout:5];out;')