@geogirafe/lib-geoportal
Version:
GeoGirafe is a flexible application to build online geoportals.
60 lines (59 loc) • 2.72 kB
TypeScript
import GirafeHTMLElement from '../../base/GirafeHTMLElement.js';
import { StreetViewProvider } from '../../tools/state/streetview.js';
import type { StreetViewProviderAdapter } from './tools/provider.js';
/**
* A StreetView, displaying the footage of a provider (Google Street View, ...) side by side with the 2D Map.
*
* The Component stays lightweight: the provider and its external library are only loaded when the
* StreetView is displayed for the first time. A click on the map displays the closest footage, and a
* marker on the map shows the position and the direction of sight of the displayed footage.
* The map is accessed through the MapManager: there is no dependency to the map-2d Component.
*/
export default abstract class StreetViewComponent extends GirafeHTMLElement {
protected templateUrl: string | null;
protected styleUrls: string[] | null;
template: () => import("uhtml").Hole;
loading: boolean;
hasFootage: boolean;
protected readonly provider: StreetViewProvider;
private adapter;
/** Promise of the currently running adapter creation, to prevent creating it twice. */
private adapterCreation;
/** The view of the footage displayed by the adapter, to tell the views coming from a shared state apart. */
private displayedView;
private readonly markerIcon;
private readonly markerGeometry;
private readonly marker;
private readonly markerSource;
private readonly markerLayer;
protected constructor(provider: StreetViewProvider);
private get olMap();
private get cellId();
private get isDisplayed();
private get searchRadius();
/** Creates the adapter of the provider, loading its module on demand. */
protected abstract createAdapter(): Promise<StreetViewProviderAdapter>;
/** The StreetView is displayed in a Cell of the Grid, like the Maps. */
protected get isFullscreenComponent(): boolean;
protected connectedCallback(): void;
protected disconnectedCallback(): void;
render(): void;
private registerEvents;
/**
* Loads the provider and shows its viewer when the StreetView is displayed in a Cell of the Grid,
* and hides it when it is not displayed anymore. The clicks on the map are only followed while displayed.
*/
private onDisplayToggled;
private createAdapterOnce;
private onMapClick;
private showClosestFootage;
private onFootageChanged;
private onViewChanged;
/**
* Displays the footage of the view in the state when it was not displayed by this Component itself,
* which is the case when a shared state is restored.
*/
private showStateView;
private isDisplayedView;
private updateMarker;
}