DefinitelyTyped/types/load-google-maps-api/load-google-maps-api-tests.ts
Dmitry Demensky 93901a2c0d [googlemaps] improve map types & docs (#41044)
* Add `MVCEventHandler` alias

* Fix & specify type of `mapDiv`

[`mapDiv`](https://developers.google.com/maps/documentation/javascript/reference/map#Map.constructor) is not nullable.

* Add the missing [`getClickableIcons`](https://developers.google.com/maps/documentation/javascript/reference/map#Map.getClickableIcons) method

* Fix [`setStreetView`](https://developers.google.com/maps/documentation/javascript/reference/map#Map.setStreetView) nullable argument

* Specify types of events

* Add blank line between fields

* Add JSDoc

* Update typescript

* Fix googlemaps-tests

* Fix load-google-maps-api-tests

* Update load-google-maps-api typescript

* Fix load-google-maps-api-tests
2019-12-23 10:30:58 -06:00

40 lines
1.0 KiB
TypeScript

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.createElement('div'), {
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({
apiUrl: 'https://localhost/',
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.createElement('div')); // $ExpectType Map<HTMLDivElement>
const polygon = new gm.Polygon(); // $ExpectType Polygon
});