summaryrefslogtreecommitdiff
path: root/libs/js/jquery-geo-1.0a4/docs/geo/bbox.html
blob: 83d25445263fc373b15e987654c3e1116a9e829e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!doctype html>  

<html lang="en" class="no-js">
<head>
  <meta charset="utf-8">

  <title>bbox | $.geo</title>
  <meta name="description" content="jQuery Geo bbox method">
  <meta name="author" content="Ryan Westphal">

  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <link rel="stylesheet" href="../css/style.css?v=2">
  <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
</head>

<body>

  <div id="bbox" data-role="page">
    <div data-role="header" data-theme="b">
      <h1>bbox</h1>
    </div>
    
    <div data-role="content">
      <table>
        <tr>
          <th>return type</th>
          <td>Array ( <a href="http://geojson.org/geojson-spec.html#bounding-boxes" rel="external">GeoJSON bounding box</a> )</td>
        </tr>
        <tr>
          <th>syntax</th>
          <td>$.geo.bbox( Object shape ( <a href="http://geojson.org/geojson-spec.html" rel="external">GeoJSON object</a> ) )</td>
        </tr>
        <tr>
          <th>usage</th>
          <td><pre><code>var bbox = $.geo.bbox( {
  type: &quot;LineString&quot;, coordinates: [
    [ -71, 40 ], [ -70.5, 41 ]
  ]
} )</code></pre></td>
        </tr>
      </table>
      <p>The bbox method calculates the smallest box that will contain all the positions in the passed-in shape. The shape can be any GeoJSON geometry object from Point to GeometryCollection.</p>
      <p>The GeoJSON spec allows for each geometry type to have a bbox property. The $.geo.bbox method will honor that property and assume it is accurate. It will return the value of that property before attempting to calculate the bbox itself. If you wish to force $.geo.bbox to calculate the bbox, you will have to manually delete the bbox property from the geometry object.</p>
      <pre><code>var shape = {
  type: &quot;LineString&quot;, coordinates: [
    [ -71, 40 ], [ -70.5, 41 ]
  ],
  bbox: [ -71, 40, -70.5, 41 ]
};
var bboxFromProperty = $.geo.bbox(shape);
delete shape.bbox;
var calculatedBbox = $.geo.bbox(shape);
</code></pre>
      <p>If the argument is not a basic GeoJSON geometry object, this function returns undefined.</p>
      <!--<p>Due to the liberties taken by web mercator to display a round Earth on a single 
        flat plane, when working in geodetic (lon/lat) coordinates, the result of the 
        $.geo.bbox function may not be exactly what you expect based on your input 
        geodetic geometry.</p>-->
      <p>This function is similar to Geometry.getEnvelope in JTS.</p>
     </div>
  </div> <!-- end of #container -->

  <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
  <script src="http://code.jquerygeo.com/jquery.geo-1.0a4.min.js"></script>
  <script src="../js/script.js"></script>
  <script src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>
</body>
</html>