001    package com.google.gwt.maps.client.base;
002    
003    import com.google.gwt.core.client.JavaScriptObject;
004    
005    /**
006     * LatLng is a point in geographical coordinates, latitude and longitude.
007     * 
008     * Notice that although usual map projections associate longitude with the x-coordinate of the map, and latitude with the y-coordinate, the latitude coordinate is always written first, followed by the longitude.
009     * Notice also that you cannot modify the coordinates of a LatLng. If you want to compute another point, you have to create a new one.
010     * 
011     * <br><br>
012     * See <a href="https://developers.google.com/maps/documentation/javascript/reference#LatLng">LatLng API Doc</a>
013     */
014    public class LatLng extends JavaScriptObject {
015    
016      /**
017       * LatLng is a point in geographical coordinates, latitude and longitude.
018       */
019      protected LatLng() {}
020      
021      /**
022       * Notice the ordering of latitude and longitude. If the noWrap flag is true, then the numbers will be used as passed, otherwise latitude will be clamped to lie between -90&deg; and +90 &deg;, and longitude will be wrapped to lie between -180 &deg; and +180 &deg;.
023       * @param lat
024       * @param lng
025       */
026      public static LatLng newInstance(double lat, double lng) {
027        return newInstance(lat, lng, false);
028      }
029    
030      /**
031       * Notice the ordering of latitude and longitude. If the noWrap flag is true, then the numbers will be used as passed, otherwise latitude will be clamped to lie between -90&deg; and +90 &deg;, and longitude will be wrapped to lie between -180 &deg; and +180 &deg;.
032       * @param lat
033       * @param lng
034       * @param noWrap
035       */
036      public static LatLng newInstance(double lat, double lng, boolean noWrap) {
037        return createJso(lat, lng, noWrap);
038      }
039    
040      /**
041       * Notice the ordering of latitude and longitude. If the noWrap flag is true, then the numbers will be used as passed, otherwise latitude will be clamped to lie between -90&deg; and +90&deg;, and longitude will be wrapped to lie between -180&deg; and +180&deg;.
042       * LatLng(lat:number, lng:number, noWrap?:boolean)
043       * @return LatLng
044       */
045      private static native LatLng createJso(double lat, double lng, boolean noWrap) /*-{
046        return new $wnd.google.maps.LatLng(lat, lng, noWrap);
047      }-*/;
048    
049      /**
050       * is equal?
051       * @param other
052       */
053      public final native boolean equals(LatLng other) /*-{
054        return this.equals(other);
055      }-*/;
056    
057      /**
058       * get latitude
059       * @return double
060       */
061      public final double getLatitude() {
062         return getLat();
063      }
064    
065      /**
066       * Returns the latitude in degrees.
067       * @return double
068       */
069      private final native double getLat() /*-{
070        return this.lat();
071      }-*/;
072    
073      /**
074       * Returns the longitude in degrees.
075       * @return double
076       */
077      public final double getLongitude() {
078        return getLng();
079      }
080    
081      /**
082       * Returns the latitude in degrees.
083       * @return double
084       */
085      private final native double getLng() /*-{
086        return this.lng();
087      }-*/;
088    
089      /**
090       * Converts to string representation.
091       */
092      public final native String getToString() /*-{
093        return this.toString();
094      }-*/;
095    
096      /**
097       * Returns a string of the form "lat,lng" for this LatLng. We round the lat/lng values to 6 decimal places by default.
098       * @param precision
099       * @return String
100       */
101      public final native String getToUrlValue(int precision) /*-{
102        return this.toUrlValue(precision);
103      }-*/;
104    
105    }