title: Given two point coordinates calculate rectangle coordinates android
body: <p>I have my coordinates from database as </p>
  
  <pre><code> (x,y) -&gt;   (37.18312184219552, -122.5216064453125), (37.74655686277364, -122.63720703125).
  </code></pre>
  
  <p>I need to find the equivalent rectangle bounds to pass to this function. </p>
  
  <pre><code>Polygon polygon = map.addPolygon(new PolygonOptions()
          .add(new LatLng(0, 0), new LatLng(0, 5), new LatLng(3, 5), new LatLng(0, 0))
          .strokeColor(Color.RED)
          .fillColor(Color.BLUE));
  </code></pre>
  
  <p>Required Result:</p>
  
  <p><a href="https://i.stack.imgur.com/Cy2N9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Cy2N9.png" alt="enter image description here"></a></p>
  
  <p>When I do this, it shows two lines and not rectangle. </p>
  
  <pre><code>points.add(new LatLong(x,y)); &lt;-- x and y passed from given coordinates
  googleMap.addPolygon(new PolygonOptions()
                                  .addAll(points)
                                  .strokeColor(Color.RED)
                                  .fillColor(Color.BLUE));
  </code></pre>
  
  <p>Obtained Result:</p>
  
  <p><a href="https://i.stack.imgur.com/x8YNh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/x8YNh.png" alt="enter image description here"></a></p>
  
  <p>JS has a function to calculate the rectangle bounds but Google Maps Android API doesn't seem to have any function or method. Can anyone please help me figure this out.</p>