UNPKG

7.14 kBTypeScriptView Raw
1declare namespace google.maps {
2 /**
3 * A LatLng is a point in geographical coordinates: latitude and longitude.
4 *
5 * * Latitude ranges between -90 and 90 degrees, inclusive. Values above or
6 * below this range will be clamped to the range [-90, 90]. This means
7 * that if the value specified is less than -90, it will be set to -90.
8 * And if the value is greater than 90, it will be set to 90.
9 * * Longitude ranges between -180 and 180 degrees, inclusive. Values above
10 * or below this range will be wrapped so that they fall within the
11 * range. For example, a value of -190 will be converted to 170. A value
12 * of 190 will be converted to -170. This reflects the fact that
13 * longitudes wrap around the globe.
14 *
15 * Although the default map projection associates longitude with the
16 * x-coordinate of the map, and latitude with the y-coordinate, the
17 * latitude coordinate is always written first, followed by the longitude.
18 * Notice that you cannot modify the coordinates of a LatLng. If you want
19 * to compute another point, you have to create a new one.
20 */
21 class LatLng {
22 /**
23 * Creates a LatLng object representing a geographic point.
24 * Note the ordering of latitude and longitude.
25 * @param lat Latitude is specified in degrees within the range [-90, 90].
26 * @param lng Longitude is specified in degrees within the range [-180,
27 * 180].
28 * @param noWrap Set noWrap to true to enable values outside of this range.
29 */
30 constructor(lat: number, lng: number, noWrap?: boolean);
31
32 /**
33 * Creates a LatLng object representing a geographic point.
34 * @param literal Object literal.
35 * @param noWrap Set noWrap to true to enable values outside of this range.
36 */
37 constructor(literal: LatLngLiteral, noWrap?: boolean);
38
39 /** Comparison function. */
40 equals(other: LatLng): boolean;
41
42 /** Returns the latitude in degrees. */
43 lat(): number;
44
45 /** Returns the longitude in degrees. */
46 lng(): number;
47
48 /** Converts to string representation. */
49 toString(): string;
50
51 /**
52 * Returns a string of the form "lat,lng". We round the lat/lng values to 6
53 * decimal places by default.
54 */
55 toUrlValue(precision?: number): string;
56
57 /**
58 * Converts to JSON representation. This function is intended to be used
59 * via JSON.stringify.
60 */
61 toJSON(): LatLngLiteral;
62 }
63
64 /**
65 * Object literals are accepted in place of {@link LatLng} objects, as a
66 * convenience, in many places. These are converted to {@link LatLng} objects
67 * when the Maps API encounters them.
68 * @see {@link https://developers.google.com/maps/documentation/javascript/reference/coordinates#LatLngLiteral Maps JavaScript API}
69 */
70 interface LatLngLiteral {
71 /**
72 * Latitude in degrees. Values will be clamped to the range [-90, 90]. This
73 * means that if the value specified is less than -90, it will be set to
74 * -90. And if the value is greater than 90, it will be set to 90.
75 */
76 lat: number;
77
78 /**
79 * Longitude in degrees. Values outside the range [-180, 180] will be
80 * wrapped so that they fall within the range. For example, a value of -190
81 * will be converted to 170. A value of 190 will be converted to -170. This
82 * reflects the fact that longitudes wrap around the globe.
83 */
84 lng: number;
85 }
86
87 /** @see {@link LatLngLiteral}. */
88 interface ReadonlyLatLngLiteral {
89 /** @see {@link LatLngLiteral#lat} */
90 readonly lat: number;
91
92 /** @see {@link LatLngLiteral#lng} */
93 readonly lng: number;
94 }
95
96 /**
97 * A LatLngBounds instance represents a rectangle in geographical coordinates,
98 * including one that crosses the 180 degrees longitudinal meridian.
99 */
100 class LatLngBounds {
101 /**
102 * Constructs a rectangle from the points at its south-west and north-east
103 * corners.
104 */
105 constructor(sw?: LatLng | LatLngLiteral, ne?: LatLng | LatLngLiteral);
106
107 /** Returns true if the given lat/lng is in this bounds. */
108 contains(latLng: LatLng | LatLngLiteral): boolean;
109
110 /** Returns true if this bounds approximately equals the given bounds. */
111 equals(other: LatLngBounds | LatLngBoundsLiteral): boolean;
112
113 /** Extends this bounds to contain the given point. */
114 extend(point: LatLng | LatLngLiteral): LatLngBounds;
115
116 /** Computes the center of this LatLngBounds */
117 getCenter(): LatLng;
118
119 /** Returns the north-east corner of this bounds. */
120 getNorthEast(): LatLng;
121
122 /** Returns the south-west corner of this bounds. */
123 getSouthWest(): LatLng;
124
125 /** Returns true if this bounds shares any points with the other bounds. */
126 intersects(other: LatLngBounds | LatLngBoundsLiteral): boolean;
127
128 /** Returns if the bounds are empty. */
129 isEmpty(): boolean;
130
131 /**
132 * Converts to JSON representation. This function is intended to be used
133 * via JSON.stringify.
134 */
135 toJSON(): LatLngBoundsLiteral;
136
137 /** Converts the given map bounds to a lat/lng span. */
138 toSpan(): LatLng;
139
140 /** Converts to string. */
141 toString(): string;
142
143 /**
144 * Returns a string of the form "lat_lo,lng_lo,lat_hi,lng_hi" for this
145 * bounds, where "lo" corresponds to the southwest corner of the bounding
146 * box, while "hi" corresponds to the northeast corner of that box.
147 */
148 toUrlValue(precision?: number): string;
149
150 /**
151 * Extends this bounds to contain the union of this and the given bounds.
152 */
153 union(other: LatLngBounds | LatLngBoundsLiteral): LatLngBounds;
154 }
155
156 interface LatLngBoundsLiteral {
157 east: number;
158
159 north: number;
160
161 south: number;
162
163 west: number;
164 }
165
166 class Point {
167 /** A point on a two-dimensional plane. */
168 constructor(x: number, y: number);
169
170 /** The X coordinate */
171 x: number;
172
173 /** The Y coordinate */
174 y: number;
175
176 /** Compares two Points */
177 equals(other: Point): boolean;
178
179 /** Returns a string representation of this Point. */
180 toString(): string;
181 }
182
183 class Size {
184 constructor(width: number, height: number, widthUnit?: string, heightUnit?: string);
185
186 height: number;
187
188 width: number;
189
190 equals(other: Size): boolean;
191
192 toString(): string;
193 }
194
195 interface Padding {
196 bottom: number;
197
198 left: number;
199
200 right: number;
201
202 top: number;
203 }
204
205 interface CircleLiteral extends CircleOptions {
206 /** The center of the Circle. */
207 center?: LatLng | LatLngLiteral;
208
209 /** The radius in meters on the Earth's surface. */
210 radius?: number;
211 }
212}