Telogis.GeoBase.BoundingBox |
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.
// 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) );
Name | Description |
---|---|
BoundingBox(p1, p2) | Arguments
|
Name | Description |
---|---|
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));
|
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'); };
|
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()); }; 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()); 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()); 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());
|
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);
|
intersects (Telogis.GeoBase.Boundingbox other) | Tests whether the calling BoundingBox intersects with another. Arguments
|