001    package com.google.gwt.maps.client.base;
002    
003    import com.google.gwt.core.client.JavaScriptObject;
004    
005    /**
006     * A LatLngBounds instance represents a rectangle in geographical coordinates, including one that crosses the 180 degrees longitudinal meridian.
007     * <br><br>
008     * See <a href="https://developers.google.com/maps/documentation/javascript/reference#LatLngBounds">LatLngBounds API Doc</a> 
009     */
010    public class LatLngBounds extends JavaScriptObject {
011      
012      /**
013       * A LatLngBounds instance represents a rectangle in geographical coordinates, including one that crosses the 180 degrees longitudinal meridian.
014       * use newInstance(...);
015       */
016      protected LatLngBounds() {}
017      
018      /**
019       * creates A LatLngBounds instance represents a rectangle in geographical coordinates, including one that crosses the 180 degrees longitudinal meridian.
020       * @param sw {@link LatLng}
021       * @param ne {@link LatLng}
022       */
023      public final static LatLngBounds newInstance(LatLng sw, LatLng ne) {
024        return createJso(sw, ne).cast(); 
025      }
026    
027      private final static native JavaScriptObject createJso(LatLng sw, LatLng ne) /*-{
028        return new $wnd.google.maps.LatLngBounds(sw, ne);
029      }-*/;
030      
031      /**
032       * Returns true if the given lat/lng is in this bounds.
033       * @param latlng {@link LatLng}
034       */
035      public final native boolean contains(LatLng latlng) /*-{
036        return this.contains(latlng);
037      }-*/;
038      
039      /**
040       * Returns true if this bounds approximately equals the given bounds.
041       * @param other {@link LatLngBounds}
042       */
043      public final native boolean equals(LatLngBounds other) /*-{
044        return this.equals(other);
045      }-*/;
046      
047      /**
048       * Extends this bounds to contain the given point.
049       * @param point {@link LatLng}
050       * @return {@link LatLngBounds}
051       */
052      public final native LatLngBounds extend(LatLng point) /*-{
053        return this.extend(point);
054      }-*/;
055      
056      /**
057       * Computes the center of this LatLngBounds
058       * @return {@link LatLng}
059       */
060      public final native LatLng getCenter() /*-{
061        return this.getCenter();
062      }-*/;
063      
064      /**
065       * Returns the north-east corner of this bounds.
066       * @return {@link LatLng}
067       */
068      public final native LatLng getNorthEast() /*-{
069        return this.getNorthEast();
070      }-*/;
071      
072      /**
073       * Returns the south-west corner of this bounds.
074       * @return {@link LatLng}
075       */
076      public final native LatLng getSouthWest() /*-{
077        return this.getSouthWest();
078      }-*/;
079      
080      /**
081       * Returns true if this bounds shares any points with this bounds.
082       * @param other {@link LatLngBounds}
083       * @return boolean
084       */
085      public final native boolean intersects(LatLngBounds other) /*-{
086        return this.intersects(other);
087      }-*/;
088      
089      /**
090       * Returns if the bounds are empty.
091       * @return boolean
092       */
093      public final native boolean isEmpty() /*-{
094        return this.isEmpty();
095      }-*/;
096      
097      /**
098       * Converts the given map bounds to a lat/lng span.
099       * @return {@link LatLng}
100       */
101      public final native LatLng toSpan() /*-{
102        return this.toSpan();
103      }-*/;
104      
105      /**
106       * Converts to string.
107       * @return boolean
108       */
109      public final native String getToString() /*-{
110        return this.toString();
111      }-*/;
112      
113      /**
114       * Returns a string of the form "lat_lo,lng_lo,lat_hi,lng_hi" for this bounds, where "lo" corresponds to the southwest corner of the bounding box, while "hi" corresponds to the northeast corner of that box.
115       * @param precision
116       * @return String
117       */
118      public final native String toUrlValue(int precision) /*-{
119        return this.toUrlValue(precision);
120      }-*/;
121      
122      /**
123       * Extends this bounds to contain the union of this and the given bounds.
124       * @param other {@link LatLngBounds}
125       * @return {@link LatLngBounds}
126       */
127      public final native LatLngBounds union(LatLngBounds other) /*-{
128        return this.union(other);
129      }-*/;
130      
131    }