|
| 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 class Circle extends React.Component<any, any> { |
| 87 | + |
| 88 | +} |
| 89 | + |
| 90 | +export interface IInfoWindowProps extends Partial<google.maps.InfoWindowOptions> { |
| 91 | + google: typeof google |
| 92 | + map: google.maps.Map |
| 93 | + marker: google.maps.Marker |
| 94 | + |
| 95 | + mapCenter?: google.maps.LatLng | google.maps.LatLngLiteral |
| 96 | + visible?: boolean |
| 97 | + |
| 98 | +} |
| 99 | + |
| 100 | +export class InfoWindow extends React.Component<IInfoWindowProps, any> { |
| 101 | + |
| 102 | +} |
0 commit comments