mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 22:37:03 +00:00
Add types for load-google-maps-api
This commit is contained in:
+59
@@ -0,0 +1,59 @@
|
||||
// Type definitions for load-google-maps-api 1.3
|
||||
// Project: https://github.com/yuanqing/load-google-maps-api#readme
|
||||
// Definitions by: Oscar Busk <https://github.com/oBusk>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="googlemaps" />
|
||||
|
||||
interface Options {
|
||||
/**
|
||||
* Client usage reporting channel
|
||||
*
|
||||
* https://developers.google.com/maps/premium/reports/usage-reports#channels
|
||||
*/
|
||||
channel?: string;
|
||||
/**
|
||||
* Client ID
|
||||
*
|
||||
* https://developers.google.com/maps/documentation/javascript/get-api-key#specifying-a-client-id-when-loading-the-api
|
||||
*/
|
||||
client?: string;
|
||||
/**
|
||||
* Your API key
|
||||
*
|
||||
* https://developers.google.com/maps/documentation/javascript/get-api-key#step-2-add-the-api-key-to-your-application
|
||||
*/
|
||||
key?: string;
|
||||
/**
|
||||
* https://developers.google.com/maps/documentation/javascript/localization#Language
|
||||
*/
|
||||
language?: string;
|
||||
/**
|
||||
* Supplemental libraries to load
|
||||
*
|
||||
* Default Value `[]`
|
||||
*
|
||||
* https://developers.google.com/maps/documentation/javascript/libraries
|
||||
*/
|
||||
libraries?: string[];
|
||||
/**
|
||||
* https://developers.google.com/maps/documentation/javascript/localization#Region
|
||||
*/
|
||||
region?: string;
|
||||
/**
|
||||
* Time in milliseconds before rejecting the Promise
|
||||
*
|
||||
* Default Value `10000`
|
||||
*/
|
||||
timeout?: number;
|
||||
/**
|
||||
* API Version
|
||||
*
|
||||
* https://developers.google.com/maps/documentation/javascript/versions
|
||||
*/
|
||||
v?: string;
|
||||
}
|
||||
|
||||
declare function loadGoogleMapsApi(options?: Options): Promise<typeof google.maps>;
|
||||
|
||||
export = loadGoogleMapsApi;
|
||||
@@ -0,0 +1,38 @@
|
||||
import loadGoogleMapsApi = require('load-google-maps-api');
|
||||
|
||||
// Example from README.md https://github.com/yuanqing/load-google-maps-api#usage
|
||||
loadGoogleMapsApi().then((googleMaps) => {
|
||||
new googleMaps.Map(document.querySelector('.map'), {
|
||||
center: {
|
||||
lat: 40.7484405,
|
||||
lng: -73.9944191
|
||||
},
|
||||
zoom: 12
|
||||
});
|
||||
}).catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
|
||||
loadGoogleMapsApi({ libraries: 'drawing' }); // $ExpectError
|
||||
loadGoogleMapsApi({ v: 3 }); // $ExpectError
|
||||
loadGoogleMapsApi({ timeout: '1000' }); // $ExpectError
|
||||
|
||||
loadGoogleMapsApi({
|
||||
channel: 'customer',
|
||||
client: '12345',
|
||||
key: 'abcde',
|
||||
language: 'se',
|
||||
libraries: [
|
||||
'drawing',
|
||||
'geometry',
|
||||
'places',
|
||||
'visualization',
|
||||
],
|
||||
region: 'SE',
|
||||
timeout: 500,
|
||||
v: '3.33',
|
||||
}).then(gm => {
|
||||
gm; // $ExpectType typeof maps
|
||||
const map = new gm.Map(document.querySelector('.map')); // $ExpectType Map
|
||||
const polygon = new gm.Polygon(); // $ExpectType Polygon
|
||||
});
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"load-google-maps-api-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user