Skip to content

ym.modules.provider.LatLngBounds

Overview

Represents a rectangular geographical area on a map.

var southWest = ym.latLng(40.712, -74.227),
    northEast = ym.latLng(40.774, -74.125),
    bounds = ym.latLngBounds(southWest, northEast);

All leaflet methods that accept LatLng objects also accept them in simple array and object form (unless otherwise specified). The example above can be written like this:

map.fitBounds([
    [40.712, -74.227],
    [40.774, -74.125]
]);

Initialization

Factory: ym.latLngBounds(southWest, northEast)

Creates a latLngBounds object by defining the southwest and northeast corners of the rectangle.

Parameter Description Data type Default value
southWest [erforderlich] LatLng
northEast [erforderlich] LatLng

Factory: ym.latLngBounds(latlngs)

Creates a latLngBounds object that is defined by the geographic points it contains. Very useful for zooming the map to fit a certain number of locations with fitBounds.

Parameter Description Data type Default value
latlngs [erforderlich] LatLng[]

Methods

extend(latlng)

Extends the boundaries so that they contain the specified point or boundaries.

Parameter Description Data type Default value
latlng LatLng or LatLngBounds
  • Return: this

getSouthWest()

Returns the southwestern point of the border.

  • Return: LatLng

getNorthEast()

Returns the northeast point of the border.

  • Return: LatLng

getNorthWest()

Returns the northwest point of the border.

  • Return: LatLng

getSouthEast()

Returns the southeast point of the border.

  • Return: LatLng

getWest()

Returns the western length of the boundaries.

  • Return: double

getSouth()

Returns the southern length of the boundaries.

  • Return: double

getEast()

Returns the eastern length of the boundaries.

  • Return: double

getNorth()

Returns the northern length of the boundaries.

  • Return: double

getCenter()

Returns the center of the boundaries.

  • Return: LatLng

contains(otherBounds)

Returns true if the rectangle contains the specified rectangle.

Parameter Description Data type Default value
latlng LatLng
  • Return: bool

intersects(otherBounds)

Returns true if the rectangle intersects the specified boundaries.

Parameter Description Data type Default value
otherBounds LatLngBounds
  • Return: bool

equals(otherBounds)

Returns true if the rectangle matches the specified limits (within a small error limit).

Parameter Description Data type Default value
otherBounds LatLngBounds
  • Return: bool

toBBoxString()

Returns a string with bounding box coordinates in a format specified as 'southwest longitude,southwest latitude,northeast longitude,northeast latitude'.

  • Return: string

pad(bufferRatio)

Returns larger limits created by extending the current limits by a certain percentage in each direction.

Parameter Description Data type Default value
bufferRatio double
  • Return: LatLngBounds

isValid()

Returns true if the limits are correctly initialized.

  • Return: bool