Skip to content

Commit 4c076ca

Browse files
author
Gordon
committed
Add Typescript definitions
1 parent f3c70a6 commit 4c076ca

File tree

3 files changed

+128
-0
lines changed

3 files changed

+128
-0
lines changed

index.d.ts

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import 'googlemaps'
2+
import * as React from 'react'
3+
4+
interface IGoogleApiOptions {
5+
apiKey: string,
6+
libraries?: string[],
7+
client?: string,
8+
url?: string,
9+
version?: string,
10+
language?: string,
11+
region?: string,
12+
LoadingContainer?: any
13+
}
14+
type GoogleApiOptionsFunc = (props: any) => IGoogleApiOptions
15+
16+
type Omit<T1, T2> = Pick<T1, Exclude<keyof T1, keyof T2>>
17+
18+
export type GoogleAPI = typeof google
19+
export function GoogleApiWrapper(opts: IGoogleApiOptions | GoogleApiOptionsFunc):
20+
<TProps extends IProvidedProps>(ctor: React.ComponentType<TProps>) => React.ComponentType<Omit<TProps, IProvidedProps>>
21+
22+
export interface IProvidedProps {
23+
google: GoogleAPI
24+
loaded?: boolean
25+
}
26+
27+
type mapEventHandler = (mapProps?: IMapProps, map?: google.maps.Map, event?) => any
28+
29+
export interface IMapProps extends google.maps.MapOptions {
30+
google: GoogleAPI
31+
loaded?: boolean
32+
33+
bounds?: google.maps.LatLngBounds | google.maps.LatLngBoundsLiteral
34+
centerAroundCurrentLocation?: boolean
35+
initialCenter?: google.maps.LatLngLiteral
36+
37+
visible?: boolean
38+
39+
onReady?: mapEventHandler
40+
onClick?: mapEventHandler
41+
onDragend?: mapEventHandler
42+
onRecenter?: mapEventHandler
43+
onBoundsChanged?: mapEventHandler
44+
onCenterChanged?: mapEventHandler
45+
onDblclick?: mapEventHandler
46+
onDragstart?: mapEventHandler
47+
onHeadingChange?: mapEventHandler
48+
onIdle?: mapEventHandler
49+
onMaptypeidChanged?: mapEventHandler
50+
onMousemove?: mapEventHandler
51+
onMouseover?: mapEventHandler
52+
onMouseout?: mapEventHandler
53+
onProjectionChanged?: mapEventHandler
54+
onResize?: mapEventHandler
55+
onRightclick?: mapEventHandler
56+
onTilesloaded?: mapEventHandler
57+
onTiltChanged?: mapEventHandler
58+
onZoomChanged?: mapEventHandler
59+
}
60+
61+
type markerEventHandler = (props?: IMarkerProps, marker?: google.maps.Marker, event?) => any
62+
63+
export interface IMarkerProps extends Partial<google.maps.MarkerOptions> {
64+
mapCenter?: google.maps.LatLng | google.maps.LatLngLiteral
65+
66+
onClick?: markerEventHandler
67+
onMouseover?: markerEventHandler
68+
}
69+
70+
export class Map extends React.Component<IMapProps, any> {
71+
72+
}
73+
74+
export class Marker extends React.Component<IMarkerProps, any> {
75+
76+
}
77+
78+
export class Polygon extends React.Component<any, any> {
79+
80+
}
81+
82+
export class Polyline extends React.Component<any, any> {
83+
84+
}
85+
86+
export interface IInfoWindowProps extends Partial<google.maps.InfoWindowOptions> {
87+
google: typeof google
88+
map: google.maps.Map
89+
marker: google.maps.Marker
90+
91+
mapCenter?: google.maps.LatLng | google.maps.LatLngLiteral
92+
visible?: boolean
93+
94+
}
95+
96+
export class InfoWindow extends React.Component<IInfoWindowProps, any> {
97+
98+
}

package-lock.json

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
"test-watch": "npm run testonly -- --watch --watch-extensions js"
2929
},
3030
"devDependencies": {
31+
"@types/googlemaps": "^3",
32+
"@types/react": "^15.0.0",
3133
"autoprefixer": "^6.3.6",
3234
"babel-cli": "^6.7.7",
3335
"babel-core": "^6.7.4",

0 commit comments

Comments
 (0)