Click or drag to resize

Telogis.GeoBase.BoundingBox

Verizon Connect Logo
Print this page
Learn more about Verizon Connect GeoBase.
Get information about the latest release

Represents a rectangular area between top-left and bottom-right corners, specified as latitude-longitude coordinates. Potentially useful for zooming, or hit-testing a given area.

JavaScript
// Create a BoundingBox in Los Angeles, Ca
var BBox = new Telogis.GeoBase.BoundingBox(
    new Telogis.GeoBase.LatLon(33.587137,-117.742878),
    new Telogis.GeoBase.LatLon(33.575037,-117.724762)
);
Constructor
NameDescription
BoundingBox(p1, p2)

Arguments

  • p1 (LatLon) - The first location to define the bounds of the rectangle by, or another BoundingBox (invoking a copy constructor).

  • p2 (LatLon) - An optional second location to complete the bounds of the rectangle. This can be added later with BoundingBox.add.

Functions
NameDescription
add (BoundingBox loc)

Inflates the BoundingBox to contain the given location or other BoundingBox.

JavaScript
// Create a BoundingBox in Los Angeles, Ca
var BBox = new Telogis.GeoBase.BoundingBox(
    new Telogis.GeoBase.LatLon(33.587137,-117.742878),
    new Telogis.GeoBase.LatLon(33.575037,-117.724762)
);

// Expand the BoundingBox to include a point
BBox.add(new Telogis.GeoBase.LatLon(33.687137,-117.742978));
Arguments
contains (LatLon other)

Tests if a given point lies (non-strictly) within this bounding box.

JavaScript
// Create a BoundingBox in Los Angeles, Ca
var BBox = new Telogis.GeoBase.BoundingBox(
    new Telogis.GeoBase.LatLon(33.587137,-117.742878),
    new Telogis.GeoBase.LatLon(33.575037,-117.724762)
);

// Create a point location to test
var testLoc = new Telogis.GeoBase.LatLon(33.583928,-117.732813);

// Test the location using 'contains'
if (BBox.contains(testLoc)){
    alert('The BoundingBox contains the test location');
} else {
    alert('The BoundingBox does not contain the test location');
};
Arguments
getCenter ()

Finds the center of the box.

JavaScript
// Create a BoundingBox in Los Angeles, Ca
var BBox = new Telogis.GeoBase.BoundingBox(
    new Telogis.GeoBase.LatLon(33.587137,-117.742878),
    new Telogis.GeoBase.LatLon(33.575037,-117.724762)
);

// Center map on BoundingBox center and zoom close
function myTestFunction(){
    map.setZoomIndex(15);
    map.pan(BBox.getCenter());
};
Returns

LatLon - The latitude-longitude coordinates of the BoundingBox's center.

getNE ()

Gets the maximum latitude-longitude extents of the BoundingBox (the coordinates of its north-east corner).

JavaScript
// Create a BoundingBox in Los Angeles, Ca
var BBox = new Telogis.GeoBase.BoundingBox(
    new Telogis.GeoBase.LatLon(33.587137,-117.742878),
    new Telogis.GeoBase.LatLon(33.575037,-117.724762)
);

// Get the north-east corner location
alert('BoundingBox North-East corner LatLon: ' + BBox.getNE());
Returns

LatLon - The north-east corner of the bounded area.

getSW ()

Gets the minimum latitude-longitude extents of the BoundingBox (the coordinates of its south-west corner).

JavaScript
// Create a BoundingBox in Los Angeles, Ca
var BBox = new Telogis.GeoBase.BoundingBox(
    new Telogis.GeoBase.LatLon(33.587137,-117.742878),
    new Telogis.GeoBase.LatLon(33.575037,-117.724762)
);

// Get the south-west corner location
alert('BoundingBox South-West corner LatLon: ' + BBox.getSW());
Returns

LatLon - The south-west corner of the bounded area.

inflate (Number degrees)

Makes each side of the box larger or smaller by the given coordinate angle.

JavaScript
// Create a BoundingBox in Los Angeles, Ca
var BBox = new Telogis.GeoBase.BoundingBox(
    new Telogis.GeoBase.LatLon(33.587137,-117.742878),
    new Telogis.GeoBase.LatLon(33.575037,-117.724762)
);

// Get the south-west corner location
alert('BoundingBox South-West corner LatLon: ' + BBox.getSW());

// Inflate the BoundingBox by two degrees
BBox.inflate(2);

// Get the south-west corner location again
alert('BoundingBox South-West corner LatLon is now: ' + BBox.getSW());
Arguments
  • degrees (Number) - The coordinate angle, in degrees, to widen the bounds of BoundingBox by. The box can be narrowed by setting this to a negative value.

inflateBy (Number factor)

Shifts the BoundingBox's boundaries symmetrically such that its dimensions are scaled by the given amount.

JavaScript
// Create a BoundingBox in Los Angeles, Ca
var BBox = new Telogis.GeoBase.BoundingBox(
    new Telogis.GeoBase.LatLon(33.587137,-117.742878),
    new Telogis.GeoBase.LatLon(33.575037,-117.724762)
);));

// Double the size of the BoundingBox
BBox.inflateBy(2);
Arguments
  • factor (Number) - The amount by which to multiply the box's dimensions. Cannot be a negative.

intersects (Telogis.GeoBase.Boundingbox other)

Tests whether the calling BoundingBox intersects with another.

Arguments