mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 02:44:02 +00:00
- One provider is lit at a time: lighting a chip darkens the others, and a chip click records every registered provider's switch in one update so the share link keeps the swap (also off Google 3D, where Street View is not listed). The layer starts with the first default-on provider (Mapillary, free); params that light several keep the one already on, so reapplying them never flips (litByParams). The now-unreachable "several lit" chip paths are gone. - Leaving Google 3D during a Street View lookup ends it without an error or a stuck loading state (openImage's early return resets it; the lookup loop rechecks availability). - A source swap during a lookup no longer reports "no imagery". - Street View lit off Google 3D says the panel needs the Google 3D map. - Comments trimmed to the why; keySetupCore.test.mjs back to upstream's formatting plus the one new test (was a 551-line reformat). Co-Authored-By: Claude Opus 5.5 <[email protected]>
66 lines
2.5 KiB
JavaScript
66 lines
2.5 KiB
JavaScript
import { COLORS as SHARED_COLORS, PROVIDER_COLORS } from '../../policy.js';
|
|
|
|
export { NEAREST_RADIUS_M } from '../../policy.js';
|
|
|
|
export const GOOGLE_PROVIDER_ID = 'google';
|
|
export const GOOGLE_NAME = 'Google Street View';
|
|
export const GOOGLE_LABEL = 'GOOGLE STREET VIEW';
|
|
/** The browser Maps key; Street View also needs the Maps JavaScript API on it. */
|
|
export const GOOGLE_KEY_ID = 'google-maps';
|
|
|
|
export const PICK_PREFIX = Object.freeze({ root: 'gsv:' });
|
|
|
|
export const COLORS = Object.freeze({
|
|
coverage: PROVIDER_COLORS.google,
|
|
selected: SHARED_COLORS.selected,
|
|
});
|
|
|
|
export const GOOGLE_CREDIT_HTML =
|
|
'Street View imagery © <a href="https://www.google.com/streetview/" target="_blank" rel="noopener">Google</a>';
|
|
|
|
/** Shown when Google refuses the key (gm_authFailure). */
|
|
export const KEY_REJECTED_MESSAGE =
|
|
'Google refused GOOGLE_MAPS_API_KEY for Street View — check that the Maps JavaScript API is enabled for it and this site is an allowed referrer';
|
|
|
|
/** Past these, a nearest lookup, an open or a details lookup has failed. */
|
|
export const NEAREST_TIMEOUT_MS = 10_000;
|
|
export const OPEN_TIMEOUT_MS = 20_000;
|
|
export const DETAILS_TIMEOUT_MS = 10_000;
|
|
/** Pause after a failed details lookup before a view event can retry. */
|
|
export const DETAILS_RETRY_COOLDOWN_MS = 5_000;
|
|
|
|
export const NO_ANSWER_MESSAGE =
|
|
'Street View did not answer — check the network, and that the Maps JavaScript API is enabled for GOOGLE_MAPS_API_KEY';
|
|
|
|
export const GROUND_CLICK_HINT = 'click a street to open Street View';
|
|
|
|
/** Deep link to a panorama on Google Maps (Maps URLs). */
|
|
export function streetViewUrl(panoId, { heading = 0, pitch = 0 } = {}) {
|
|
const params = new URLSearchParams({
|
|
api: '1',
|
|
map_action: 'pano',
|
|
pano: String(panoId),
|
|
heading: String(Math.round(heading)),
|
|
pitch: String(Math.round(pitch)),
|
|
});
|
|
return `https://www.google.com/maps/@?${params}`;
|
|
}
|
|
|
|
/** Epoch ms for a Street View image date ('YYYY-MM'), or null. */
|
|
export function imageDateMs(imageDate) {
|
|
const match = /^(\d{4})-(\d{2})/.exec(String(imageDate ?? ''));
|
|
if (!match) return null;
|
|
const month = Number(match[2]);
|
|
if (month < 1 || month > 12) return null;
|
|
return Date.UTC(Number(match[1]), month - 1, 1);
|
|
}
|
|
|
|
/** The photographer from a copyright line ('© 2024 Google' → 'Google'). */
|
|
export function creatorFrom(copyright) {
|
|
const text = String(copyright ?? '')
|
|
.replace(/^©\s*(\d{4}\s+)?/, '')
|
|
.replace(/^From the Owner,\s*Photo by:\s*/i, '')
|
|
.trim();
|
|
return text || null;
|
|
}
|