Skip to content

Commit 45f1bff

Browse files
fix: broken declarations (#459) 2ae6186
1 parent 42a6cd9 commit 45f1bff

File tree

7 files changed

+586
-28
lines changed

7 files changed

+586
-28
lines changed

classes/Loader.html

Lines changed: 15 additions & 15 deletions
Large diffs are not rendered by default.

dist/dist/index.d.ts

Lines changed: 278 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,278 @@
1+
/**
2+
* Copyright 2019 Google LLC. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at.
7+
*
8+
* Http://www.apache.org/licenses/LICENSE-2.0.
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
/// <reference types="google.maps" />
17+
/**
18+
* @ignore
19+
*/
20+
declare global {
21+
interface Window {
22+
__googleMapsCallback: (e: Event) => void;
23+
}
24+
}
25+
export declare const DEFAULT_ID = "__googleMapsScriptId";
26+
declare type Libraries = ("drawing" | "geometry" | "localContext" | "places" | "visualization")[];
27+
/**
28+
* The Google Maps JavaScript API
29+
* [documentation](https://developers.google.com/maps/documentation/javascript/tutorial)
30+
* is the authoritative source for [[LoaderOptions]].
31+
/**
32+
* Loader options
33+
*/
34+
export interface LoaderOptions {
35+
/**
36+
* See https://developers.google.com/maps/documentation/javascript/get-api-key.
37+
*/
38+
apiKey: string;
39+
/**
40+
* @deprecated See https://developers.google.com/maps/premium/overview.
41+
*/
42+
channel?: string;
43+
/**
44+
* @deprecated See https://developers.google.com/maps/premium/overview, use `apiKey` instead.
45+
*/
46+
client?: string;
47+
/**
48+
* In your application you can specify release channels or version numbers:
49+
*
50+
* The weekly version is specified with `version=weekly`. This version is
51+
* updated once per week, and is the most current.
52+
*
53+
* ```
54+
* const loader = Loader({apiKey, version: 'weekly'});
55+
* ```
56+
*
57+
* The quarterly version is specified with `version=quarterly`. This version
58+
* is updated once per quarter, and is the most predictable.
59+
*
60+
* ```
61+
* const loader = Loader({apiKey, version: 'quarterly'});
62+
* ```
63+
*
64+
* The version number is specified with `version=n.nn`. You can choose
65+
* `version=3.40`, `version=3.39`, or `version=3.38`. Version numbers are
66+
* updated once per quarter.
67+
*
68+
* ```
69+
* const loader = Loader({apiKey, version: '3.40'});
70+
* ```
71+
*
72+
* If you do not explicitly specify a version, you will receive the
73+
* weekly version by default.
74+
*/
75+
version?: string;
76+
/**
77+
* The id of the script tag. Before adding a new script, the Loader will check for an existing one.
78+
*/
79+
id?: string;
80+
/**
81+
* When loading the Maps JavaScript API via the URL you may optionally load
82+
* additional libraries through use of the libraries URL parameter. Libraries
83+
* are modules of code that provide additional functionality to the main Maps
84+
* JavaScript API but are not loaded unless you specifically request them.
85+
*
86+
* ```
87+
* const loader = Loader({
88+
* apiKey,
89+
* libraries: ['drawing', 'geometry', 'places', 'visualization'],
90+
* });
91+
* ```
92+
*
93+
* Set the [list of libraries](https://developers.google.com/maps/documentation/javascript/libraries) for more options.
94+
*/
95+
libraries?: Libraries;
96+
/**
97+
* By default, the Maps JavaScript API uses the user's preferred language
98+
* setting as specified in the browser, when displaying textual information
99+
* such as the names for controls, copyright notices, driving directions and
100+
* labels on maps. In most cases, it's preferable to respect the browser
101+
* setting. However, if you want the Maps JavaScript API to ignore the
102+
* browser's language setting, you can force it to display information in a
103+
* particular language when loading the Maps JavaScript API code.
104+
*
105+
* For example, the following example localizes the language to Japan:
106+
*
107+
* ```
108+
* const loader = Loader({apiKey, language: 'ja', region: 'JP'});
109+
* ```
110+
*
111+
* See the [list of supported
112+
* languages](https://developers.google.com/maps/faq#languagesupport). Note
113+
* that new languages are added often, so this list may not be exhaustive.
114+
*
115+
*/
116+
language?: string;
117+
/**
118+
* When you load the Maps JavaScript API from maps.googleapis.com it applies a
119+
* default bias for application behavior towards the United States. If you
120+
* want to alter your application to serve different map tiles or bias the
121+
* application (such as biasing geocoding results towards the region), you can
122+
* override this default behavior by adding a region parameter when loading
123+
* the Maps JavaScript API code.
124+
*
125+
* The region parameter accepts Unicode region subtag identifiers which
126+
* (generally) have a one-to-one mapping to country code Top-Level Domains
127+
* (ccTLDs). Most Unicode region identifiers are identical to ISO 3166-1
128+
* codes, with some notable exceptions. For example, Great Britain's ccTLD is
129+
* "uk" (corresponding to the domain .co.uk) while its region identifier is
130+
* "GB."
131+
*
132+
* For example, the following example localizes the map to the United Kingdom:
133+
*
134+
* ```
135+
* const loader = Loader({apiKey, region: 'GB'});
136+
* ```
137+
*/
138+
region?: string;
139+
/**
140+
* @deprecated Passing `mapIds` is no longer required in the script tag.
141+
*/
142+
mapIds?: string[];
143+
/**
144+
* Use a custom url and path to load the Google Maps API script.
145+
*/
146+
url?: string;
147+
/**
148+
* Use a cryptographic nonce attribute.
149+
*/
150+
nonce?: string;
151+
/**
152+
* The number of script load retries.
153+
*/
154+
retries?: number;
155+
}
156+
/**
157+
* [[Loader]] makes it easier to add Google Maps JavaScript API to your application
158+
* dynamically using
159+
* [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).
160+
* It works by dynamically creating and appending a script node to the the
161+
* document head and wrapping the callback function so as to return a promise.
162+
*
163+
* ```
164+
* const loader = new Loader({
165+
* apiKey: "",
166+
* version: "weekly",
167+
* libraries: ["places"]
168+
* });
169+
*
170+
* loader.load().then((google) => {
171+
* const map = new google.maps.Map(...)
172+
* })
173+
* ```
174+
*/
175+
export declare class Loader {
176+
private static instance;
177+
/**
178+
* See [[LoaderOptions.version]]
179+
*/
180+
readonly version: string;
181+
/**
182+
* See [[LoaderOptions.apiKey]]
183+
*/
184+
readonly apiKey: string;
185+
/**
186+
* See [[LoaderOptions.channel]]
187+
*/
188+
readonly channel: string;
189+
/**
190+
* See [[LoaderOptions.client]]
191+
*/
192+
readonly client: string;
193+
/**
194+
* See [[LoaderOptions.id]]
195+
*/
196+
readonly id: string;
197+
/**
198+
* See [[LoaderOptions.libraries]]
199+
*/
200+
readonly libraries: Libraries;
201+
/**
202+
* See [[LoaderOptions.language]]
203+
*/
204+
readonly language: string;
205+
/**
206+
* See [[LoaderOptions.region]]
207+
*/
208+
readonly region: string;
209+
/**
210+
* See [[LoaderOptions.mapIds]]
211+
*/
212+
readonly mapIds: string[];
213+
/**
214+
* See [[LoaderOptions.nonce]]
215+
*/
216+
readonly nonce: string | null;
217+
/**
218+
* See [[LoaderOptions.retries]]
219+
*/
220+
readonly retries: number;
221+
/**
222+
* See [[LoaderOptions.url]]
223+
*/
224+
readonly url: string;
225+
private CALLBACK;
226+
private callbacks;
227+
private done;
228+
private loading;
229+
private onerrorEvent;
230+
private errors;
231+
/**
232+
* Creates an instance of Loader using [[LoaderOptions]]. No defaults are set
233+
* using this library, instead the defaults are set by the Google Maps
234+
* JavaScript API server.
235+
*
236+
* ```
237+
* const loader = Loader({apiKey, version: 'weekly', libraries: ['places']});
238+
* ```
239+
*/
240+
constructor({ apiKey, channel, client, id, libraries, language, region, version, mapIds, nonce, retries, url, }: LoaderOptions);
241+
get options(): LoaderOptions;
242+
private get failed();
243+
/**
244+
* CreateUrl returns the Google Maps JavaScript API script url given the [[LoaderOptions]].
245+
*
246+
* @ignore
247+
*/
248+
createUrl(): string;
249+
deleteScript(): void;
250+
/**
251+
* Load the Google Maps JavaScript API script and return a Promise.
252+
*/
253+
load(): Promise<typeof google>;
254+
/**
255+
* Load the Google Maps JavaScript API script and return a Promise.
256+
*
257+
* @ignore
258+
*/
259+
loadPromise(): Promise<typeof google>;
260+
/**
261+
* Load the Google Maps JavaScript API script with a callback.
262+
*/
263+
loadCallback(fn: (e: ErrorEvent) => void): void;
264+
/**
265+
* Set the script on document.
266+
*/
267+
private setScript;
268+
/**
269+
* Reset the loader state.
270+
*/
271+
private reset;
272+
private resetIfRetryingFailed;
273+
private loadErrorCallback;
274+
private setCallback;
275+
private callback;
276+
private execute;
277+
}
278+
export {};

dist/dist/index.test.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {};

0 commit comments

Comments
 (0)