UNPKG

map-zoomtospan

Version:

A cross-platform utility designed to calculate the optimal map zoom level and/or center point for a given map viewport, ensuring a balanced view of map features.

92 lines 2.9 kB
export interface ILatLng { lat: number; lng: number; } export interface ILatLngBounds { ne: ILatLng; sw: ILatLng; } export interface IPoint { x: number; y: number; } export interface IPointBounds { topLeft: IPoint; bottomRight: IPoint; } export interface ISize { width: number; height: number; } export interface IInsets { left: number; right: number; top: number; bottom: number; } export interface IAnchor { x: number; y: number; } export interface IViewport { size: ISize; insets: IInsets; } export interface IPolylineOverlay { points: ILatLng[]; width: number; } export type IPolygonOverlay = IPolylineOverlay; export interface ICircleOverlay { center: ILatLng; radius: number; } export interface IMarkerOverlay { position: ILatLng; boundingRect?: ISize; anchor?: IAnchor; } export type IStandardOverlay = IMarkerOverlay; export type IOverlay = IPolylineOverlay | ICircleOverlay | IMarkerOverlay; export interface MapZoomToSpanOptions { center?: ILatLng; zoomRange?: [number, number]; viewport: IViewport; overlays: IOverlay[]; projection?: IProjection; worldSize?: number; precision?: number; } export type MapResult<T> = { ok: true; result: T; } | { ok: false; error: string; }; export interface MapZoomToSpanResult { center: ILatLng; zoom: number; } export interface IProjection { project(latLng: ILatLng, zoom: number): IPoint; unproject(point: IPoint, zoom: number): ILatLng; } export declare class WebMercatorProjection implements IProjection { private readonly worldSize; constructor(worldSize?: number); project(latLng: ILatLng, zoom?: number): IPoint; unproject(point: IPoint, zoom?: number): ILatLng; static readonly defaultWorldSize = 512; } export declare function wrapLng(lng: number): number; export declare function wrapLat(lat: number): number; export declare function wrapLatLng(latLng: ILatLng): ILatLng; export declare function extendLatLngBounds(bounds: ILatLngBounds, otherBounds: ILatLng | ILatLngBounds): ILatLngBounds; export declare function extendPointBounds(bounds: IPointBounds, otherBounds: IPointBounds): IPointBounds; export declare function normalizeOverlay(overlay: IOverlay): IStandardOverlay[]; export declare function getOverlaysContainingPointBounds(overlays: IStandardOverlay[], zoom: number, projection: IProjection): IPointBounds; export declare function extendOverlaysContainingPointBoundsWithCenter(overlays: IStandardOverlay[], zoom: number, projection: IProjection, center: ILatLng): IPointBounds; export declare function isAllOverlaysCanBePutInsideContentArea(overlayBounds: IPointBounds, contentBounds: IPointBounds): boolean; export declare function mapZoomToSpan(options: MapZoomToSpanOptions): MapResult<MapZoomToSpanResult>; //# sourceMappingURL=zoomtospan.d.ts.map