UNPKG

@igo2/geo

Version:
97 lines (96 loc) 3.36 kB
import { ConfigService } from '@igo2/core/config'; import { StorageService } from '@igo2/core/storage'; import olGeolocation from 'ol/Geolocation'; import OlMap from 'ol/Map'; import { BehaviorSubject } from 'rxjs'; import type { MapBase } from '../map.abstract'; import { MapViewOptions } from '../map.interface'; import { MapController } from './controller'; import { GeolocationBuffer, MapGeolocationControllerOptions, MapGeolocationState } from './geolocation.interface'; /** * Controller to handle map view interactions */ export declare class MapGeolocationController extends MapController { private map; private options?; private storageService?; private configService?; private arrowRotation; private subscriptions$$; private geolocationOverlay; private positionFeatureStyle; private accuracyFeatureStyle; private get bufferStyle(); private get arrowStyle(); private geolocation; /** * Observable of the current emission interval of the position. In seconds */ readonly emissionIntervalSeconds$: BehaviorSubject<number>; /** * Observable of the current position */ readonly position$: BehaviorSubject<MapGeolocationState>; /** * Observable of the tracking state */ readonly tracking$: BehaviorSubject<boolean>; /** * Observable of the follow position state */ readonly followPosition$: BehaviorSubject<boolean>; private lastPosition; /** * Whether the geolocate should show a buffer around the current position */ set buffer(value: GeolocationBuffer); get buffer(): GeolocationBuffer; private _buffer; /** * Whether the geolocate controller accuracy threshold to store/show the position. */ set accuracyThreshold(value: number); get accuracyThreshold(): number; private _accuracyThreshold; get olGeolocation(): olGeolocation; /** * Whether the activate the geolocation. */ get tracking(): boolean; set tracking(value: boolean); /** * Whether the activate the view tracking of the current position */ set followPosition(value: boolean); get followPosition(): boolean; private _followPosition; constructor(map: MapBase, options?: MapGeolocationControllerOptions, storageService?: StorageService, configService?: ConfigService); /** * Add or remove this controller to/from a map. * @param map OL Map */ setOlMap(olMap: OlMap | undefined): void; private deleteGeolocationFeatures; setupObservers(): void; updateArrowFeatureOrientation(position: MapGeolocationState): void; /** * @returns distance in km between coord1 and coord2 */ private distanceBetweenPoints; addOnChangedListener(event: (geo: olGeolocation) => any): () => void; deleteChangedListener(event: () => any): void; updateGeolocationOptions(options: MapViewOptions): void; /** * Teardown any observers */ teardownObservers(): void; /** * On position change, get the position, show it on the map and record it. * @param emitEvent Map event */ private onPositionChange; private getFeatureByType; private deleteFeatureByType; private handleFeatureCreation; handleViewFromFeatures(position: MapGeolocationState, zoomTo?: boolean): void; }