leaflet
Version:
JavaScript library for mobile-friendly interactive maps
107 lines (106 loc) • 4.37 kB
TypeScript
import { LatLng } from './LatLng.js';
import type { LatLngExpression, LatLngTuple } from './LatLng.js';
export type LatLngBoundsLiteral = LatLngTuple[];
export type LatLngBoundsExpression = LatLngBounds | LatLngExpression[];
/** @import {LatLngExpression, LatLngTuple} from './LatLng.js' */
/** @typedef {LatLngTuple[]} LatLngBoundsLiteral */
/**
* A `LatLngBounds`, or an array of the points it should contain (usually two opposite corners).
* @typedef {LatLngBounds | LatLngExpression[]} LatLngBoundsExpression
*/
/**
* Represents a rectangular geographical area on a map.
*
* @example
* ```js
* const corner1 = new LatLng(40.712, -74.227),
* corner2 = new LatLng(40.774, -74.125),
* bounds = new LatLngBounds(corner1, corner2);
* ```
*
* All Leaflet methods that accept LatLngBounds objects also accept them in a simple Array form (unless noted
* otherwise), so the bounds example above can be passed like this:
*
* ```js
* map.fitBounds([
* [40.712, -74.227],
* [40.774, -74.125]
* ]);
* ```
*
* Caution: if the area crosses the antimeridian (often confused with the International Date Line), you must specify
* corners _outside_ the [-180, 180] degrees longitude range.
*
* Note that `LatLngBounds` does not inherit from Leaflet's `Class` object, which means new classes can't inherit
* from it, and new methods can't be added to it with the `include` function.
*/
export declare class LatLngBounds {
/** @type {LatLng} */
_southWest: LatLng;
/** @type {LatLng} */
_northEast: LatLng;
constructor(corner1: LatLngExpression, corner2: LatLngExpression);
constructor(latlngs: LatLngBoundsExpression);
constructor();
/**
* Extend the bounds to contain the given point or bounds.
* @param {LatLngExpression | LatLngBoundsExpression} obj
* @returns {this}
*/
extend(obj: LatLngExpression | LatLngBoundsExpression): this;
/**
* Returns bounds created by extending or retracting the current bounds by a given ratio in each direction. For
* example, a ratio of 0.5 extends the bounds by 50% in each direction. Negative values will retract the bounds.
* @param {number} bufferRatio
*/
pad(bufferRatio: number): LatLngBounds;
/** Returns the center point of the bounds. */
getCenter(): LatLng;
/** Returns the south-west point of the bounds. */
getSouthWest(): LatLng;
/** Returns the north-east point of the bounds. */
getNorthEast(): LatLng;
/** Returns the north-west point of the bounds. */
getNorthWest(): LatLng;
/** Returns the south-east point of the bounds. */
getSouthEast(): LatLng;
/** Returns the west longitude of the bounds */
getWest(): number;
/** Returns the south latitude of the bounds */
getSouth(): number;
/** Returns the east longitude of the bounds */
getEast(): number;
/** Returns the north latitude of the bounds */
getNorth(): number;
/**
* Returns `true` if the rectangle contains the given point or bounds.
* @param {LatLngExpression | LatLngBoundsExpression} obj
*/
contains(obj: LatLngExpression | LatLngBoundsExpression): boolean;
/**
* Returns `true` if the rectangle intersects the given bounds. Two
* bounds intersect if they have at least one point in common.
* @param {LatLngBoundsExpression} bounds
*/
intersects(bounds: LatLngBoundsExpression): boolean;
/**
* Returns `true` if the rectangle overlaps the given bounds.
* Two bounds overlap if their intersection is an area.
* @param {LatLngBoundsExpression} bounds
*/
overlaps(bounds: LatLngBoundsExpression): boolean;
/**
* Returns a string with bounding box coordinates in a 'southwest_lng,southwest_lat,northeast_lng,northeast_lat'
* format. Useful for sending requests to web services that return geo data.
*/
toBBoxString(): string;
/**
* Returns `true` if the rectangle is equivalent (within a small margin of error) to the given
* bounds. The margin of error can be overridden by setting `maxMargin` to a small number.
* @param {LatLngBoundsExpression} [bounds]
* @param {number} [maxMargin]
*/
equals(bounds?: LatLngBoundsExpression, maxMargin?: number): boolean;
/** Returns `true` if the bounds are properly initialized. */
isValid(): boolean;
}