Skip to content

ym.modules.provider.Bounds

Overview

Creates a bounds object from two pixel coordinates or from the contained points.

var p1 = ym.point(10, 10),
    p2 = ym.point(40, 60),
    bounds = ym.bounds(p1, p2);

All leaflet methods that accept bounds objects also accept them in a simple array form (unless otherwise specified), so that the above bounds example can be rewritten that way:

otherBounds.intersects([[10, 10], [40, 60]]);

Initialization

Factory: ym.bounds(Point topLeft, Point bottomRight)

Creates a bounds object from two pixel coordinates (top-left and bottom-right).

Factory: ym.bounds(Point[] points)

Creates a Bounds object that is defined by the points it contains.

Features

  • min
  • Description: The upper left corner of the rectangle.
  • Data type: Point

  • max

  • Description: The lower right corner of the rectangle.
  • Data type: Point

Methods

extend(point)

Extends the limits by the specified point.

  • Parameter
  • point
    • Data type: Point

getCenter()

Returns the center of the boundaries.

  • Return: Point

contains(bounds)

Returns true if the rectangle contains the specified rectangle.

  • Parameter
  • bounds

    • Data type: Bounds
  • Return: Bool

contains(point)

Returns true if the rectangle contains the specified point.

  • Parameter
  • point

    • Data type: Point
  • Return: Bool

intersects(bounds)

Returns true if the rectangle intersects the specified boundaries.

  • Parameter
  • bounds

    • Data type: Bounds
  • Return: Bool

isValid()

Returns true if the limits are correctly initialized.

  • Return: Bool

getSize()

Returns the size of the specified limits.

  • Return: Point