UNPKG

6.8 kBTypeScriptView Raw
1declare namespace google.maps.places {
2 // TODO find source documentation
3 interface RadarSearchRequest {
4 bounds?: LatLngBounds | LatLngBoundsLiteral;
5 keyword?: string;
6 location?: LatLng | LatLngLiteral;
7 name?: string;
8 radius?: number;
9 types?: string[] /* Deprecated. Will be removed February 16, 2017 */;
10 type?: string;
11 }
12
13 class PlacesService {
14 constructor(attrContainer: HTMLDivElement | Map);
15 findPlaceFromPhoneNumber(
16 request: FindPlaceFromPhoneNumberRequest,
17 callback: (results: PlaceResult[], status: PlacesServiceStatus) => void,
18 ): void;
19 findPlaceFromQuery(
20 request: FindPlaceFromQueryRequest,
21 callback: (results: PlaceResult[], status: PlacesServiceStatus) => void,
22 ): void;
23 getDetails(
24 request: PlaceDetailsRequest,
25 callback: (result: PlaceResult, status: PlacesServiceStatus) => void,
26 ): void;
27 nearbySearch(
28 request: PlaceSearchRequest,
29 callback: (results: PlaceResult[], status: PlacesServiceStatus, pagination: PlaceSearchPagination) => void,
30 ): void;
31 /**
32 * @deprecated Radar search is deprecated as of June 30, 2018. After that
33 * time, this feature will no longer be available.
34 */
35 radarSearch(
36 request: RadarSearchRequest,
37 callback: (results: PlaceResult[], status: PlacesServiceStatus) => void,
38 ): void;
39 textSearch(
40 request: TextSearchRequest,
41 callback: (results: PlaceResult[], status: PlacesServiceStatus, pagination: PlaceSearchPagination) => void,
42 ): void;
43 }
44
45 interface PlaceDetailsRequest {
46 placeId: string;
47 fields?: string[];
48 sessionToken?: AutocompleteSessionToken;
49 }
50
51 interface FindPlaceFromPhoneNumberRequest {
52 fields: string[];
53 locationBias?: LocationBias;
54 phoneNumber: string;
55 }
56
57 interface FindPlaceFromQueryRequest {
58 fields: string[];
59 locationBias?: LocationBias;
60 query: string;
61 }
62
63 interface PlaceSearchRequest {
64 bounds?: LatLngBounds | LatLngBoundsLiteral;
65 keyword?: string;
66 location?: LatLng | LatLngLiteral;
67 maxPriceLevel?: number;
68 minPriceLevel?: number;
69 name?: string;
70 openNow?: boolean;
71 radius?: number;
72 rankBy?: RankBy;
73 types?: string[] /* Deprecated. Will be removed February 16, 2017 */;
74 type?: string;
75 }
76
77 interface TextSearchRequest {
78 bounds?: LatLngBounds | LatLngBoundsLiteral;
79 location?: LatLng | LatLngLiteral;
80 query: string;
81 radius?: number;
82 types?: string[] /* Deprecated. Will be removed February 16, 2017 */;
83 type?: string;
84 }
85
86 enum RankBy {
87 PROMINENCE = 0,
88 DISTANCE = 1,
89 }
90
91 type LocationBias = LatLng | LatLngLiteral | LatLngBounds | LatLngBoundsLiteral | Circle | CircleLiteral | string;
92
93 enum PlacesServiceStatus {
94 INVALID_REQUEST = 'INVALID_REQUEST',
95 NOT_FOUND = 'NOT_FOUND',
96 OK = 'OK',
97 OVER_QUERY_LIMIT = 'OVER_QUERY_LIMIT',
98 REQUEST_DENIED = 'REQUEST_DENIED',
99 UNKNOWN_ERROR = 'UNKNOWN_ERROR',
100 ZERO_RESULTS = 'ZERO_RESULTS',
101 }
102
103 interface PlaceSearchPagination {
104 nextPage(): void;
105 hasNextPage: boolean;
106 }
107
108 interface PlaceResult {
109 address_components?: GeocoderAddressComponent[];
110 adr_address?: string;
111 aspects?: PlaceAspectRating[];
112 formatted_address?: string;
113 formatted_phone_number?: string;
114 geometry?: PlaceGeometry;
115 html_attributions?: string[];
116 icon?: string;
117 id?: string;
118 international_phone_number?: string;
119 name: string;
120 opening_hours?: OpeningHours;
121 permanently_closed?: boolean;
122 photos?: PlacePhoto[];
123 place_id?: string;
124 plus_code?: PlacePlusCode;
125 price_level?: number;
126 rating?: number;
127 reviews?: PlaceReview[];
128 types?: string[];
129 url?: string;
130 user_ratings_total?: number;
131 /**
132 * @deprecated utc_offset is deprecated as of November 2019 and will be turned off in November 2020.
133 * Use PlaceResult.utc_offset_minutes instead.
134 */
135 utc_offset?: number;
136 utc_offset_minutes?: number;
137 vicinity?: string;
138 website?: string;
139 }
140
141 interface PlaceAspectRating {
142 rating: number;
143 type: string;
144 }
145
146 // TODO add BusinessStatus https://developers.google.com/maps/documentation/javascript/reference/places-service#BusinessStatus
147
148 interface PlaceGeometry {
149 location: LatLng;
150 viewport: LatLngBounds;
151 }
152
153 // TODO rename to PlaceOpeningHours https://developers.google.com/maps/documentation/javascript/reference/places-service#PlaceOpeningHours
154 interface OpeningHours {
155 /**
156 * @deprecated open_now is deprecated as of November 2019 and will be turned off in November 2020.
157 * Use the PlaceOpeningHours.isOpen function from a PlacesService.getDetails result instead.
158 */
159 open_now: boolean;
160 periods: OpeningPeriod[];
161 weekday_text: string[];
162 isOpen(date?: Date): boolean;
163 }
164
165 // TODO rename to PlaceOpeningHoursPeriod https://developers.google.com/maps/documentation/javascript/reference/places-service#PlaceOpeningHoursPeriod
166 interface OpeningPeriod {
167 open: OpeningHoursTime;
168 close?: OpeningHoursTime;
169 }
170
171 // TODO rename to PlaceOpeningHoursTime https://developers.google.com/maps/documentation/javascript/reference/places-service#PlaceOpeningHoursTime
172 interface OpeningHoursTime {
173 day: number;
174 hours: number;
175 minutes: number;
176 nextDate: number;
177 time: string;
178 }
179
180 interface PlacePlusCode {
181 compound_code?: string;
182 global_code: string;
183 }
184
185 interface PlacePhoto {
186 height: number;
187 html_attributions: string[];
188 width: number;
189 getUrl(opts: PhotoOptions): string;
190 }
191
192 interface PhotoOptions {
193 maxHeight?: number;
194 maxWidth?: number;
195 }
196
197 interface PlaceReview {
198 aspects: PlaceAspectRating[];
199 author_name: string;
200 author_url?: string;
201 language: string;
202 profile_photo_url: string;
203 // TODO rating is documented in the HTTP API (https://developers.google.com/places/web-service/details#PlaceDetailsResults) but not in the Javascript API.
204 rating: number;
205 relative_time_description: string;
206 text: string;
207 time: number;
208 }
209}