Skip to content

Commit 3049b76

Browse files
Google APIscopybara-github
authored andcommitted
feat: add AutoComplete API
feat: add Searchable EV feature to TextSearch API PiperOrigin-RevId: 608184544
1 parent 87fc56b commit 3049b76

2 files changed

Lines changed: 319 additions & 8 deletions

File tree

google/maps/places/v1/place.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,8 @@ message Place {
283283
optional bool wheelchair_accessible_seating = 4;
284284
}
285285

286-
// An ID representing this place which may be used to look up this place
287-
// again (a.k.a. the API "resource" name: places/place_id).
286+
// This Place's resource name, in `places/{place_id}` format. Can be used to
287+
// look up the Place.
288288
string name = 1;
289289

290290
// The unique identifier of a place.

google/maps/places/v1/places_service.proto

Lines changed: 317 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ import "google/api/client.proto";
2121
import "google/api/field_behavior.proto";
2222
import "google/api/resource.proto";
2323
import "google/geo/type/viewport.proto";
24+
import "google/maps/places/v1/ev_charging.proto";
2425
import "google/maps/places/v1/geometry.proto";
2526
import "google/maps/places/v1/place.proto";
27+
import "google/type/latlng.proto";
2628

2729
option cc_enable_arenas = true;
2830
option csharp_namespace = "Google.Maps.Places.V1";
@@ -66,13 +68,23 @@ service Places {
6668
option (google.api.method_signature) = "name";
6769
}
6870

69-
// Get place details with a place id (in a name) string.
71+
// Get the details of a place based on its resource name, which is a string
72+
// in the `places/{place_id}` format.
7073
rpc GetPlace(GetPlaceRequest) returns (Place) {
7174
option (google.api.http) = {
7275
get: "/v1/{name=places/*}"
7376
};
7477
option (google.api.method_signature) = "name";
7578
}
79+
80+
// Returns predictions for the given input.
81+
rpc AutocompletePlaces(AutocompletePlacesRequest)
82+
returns (AutocompletePlacesResponse) {
83+
option (google.api.http) = {
84+
post: "/v1/places:autocomplete"
85+
body: "*"
86+
};
87+
}
7688
}
7789

7890
// Request proto for Search Nearby.
@@ -214,7 +226,6 @@ message SearchNearbyRequest {
214226

215227
// Response proto for Search Nearby.
216228
//
217-
//
218229
message SearchNearbyResponse {
219230
// A list of places that meets user's requirements like places
220231
// types, number of places and specific location restriction.
@@ -269,6 +280,19 @@ message SearchTextRequest {
269280
}
270281
}
271282

283+
// Searchable EV options of a place search request.
284+
message EVOptions {
285+
// Optional. Filtering places by minimum charging rate. Any places with
286+
// charging a rate less than the minimum charging rate are filtered out.
287+
double minimum_charging_rate_kw = 1
288+
[(google.api.field_behavior) = OPTIONAL];
289+
290+
// Optional. The list of preferred EV connector types. A place that does not
291+
// support any of the listed connector types are filter out.
292+
repeated EVConnectorType connector_types = 2
293+
[(google.api.field_behavior) = OPTIONAL];
294+
}
295+
272296
// Required. The text query for textual search.
273297
string text_query = 1 [(google.api.field_behavior) = REQUIRED];
274298

@@ -336,6 +360,9 @@ message SearchTextRequest {
336360
// results outside given location will not be returned. Cannot be set along
337361
// with location_bias.
338362
LocationRestriction location_restriction = 14;
363+
364+
// Optional. Set the searchable EV options of a place search request.
365+
EVOptions ev_options = 15 [(google.api.field_behavior) = OPTIONAL];
339366
}
340367

341368
// Response proto for SearchText.
@@ -411,11 +438,10 @@ message PhotoMedia {
411438
string photo_uri = 2;
412439
}
413440

414-
// Request for fetching a Place with a place id (in a name) string.
441+
// Request for fetching a Place based on its resource name, which is a string in
442+
// the `places/{place_id}` format.
415443
message GetPlaceRequest {
416-
// Required. A place ID returned in a Place (with "places/" prefix), or
417-
// equivalently the name in the same Place. Format:
418-
// `places/{place_id}`.
444+
// Required. The resource name of a place, in the `places/{place_id}` format.
419445
string name = 1 [
420446
(google.api.field_behavior) = REQUIRED,
421447
(google.api.resource_reference) = { type: "places.googleapis.com/Place" }
@@ -438,4 +464,289 @@ message GetPlaceRequest {
438464
//
439465
// Note that 3-digit region codes are not currently supported.
440466
string region_code = 3 [(google.api.field_behavior) = OPTIONAL];
467+
468+
// Optional. An arbitrary string which identifies an autocomplete session for
469+
// billing purposes. Must be at most 36 characters in length. Otherwise an
470+
// INVALID_ARGUMENT error is returned.
471+
//
472+
// The session begins when the user starts typing a query, and concludes when
473+
// they select a place and a call to Place Details or Address Validation is
474+
// made. Each session can have multiple queries, followed by one Place
475+
// selection. The credentials used for each request within a session must
476+
// belong to the same Google Cloud Console project. Once a session has
477+
// concluded, the token is no longer valid; your app must generate a fresh
478+
// token for each session. If the `session_token` parameter is omitted, or if
479+
// you reuse a session token, the session is charged as if no session token
480+
// was provided (each request is billed separately).
481+
//
482+
// We recommend the following guidelines:
483+
// * Use session tokens for all Place Autocomplete calls.
484+
// * Generate a fresh token for each session. Using a version 4 UUID is
485+
// recommended.
486+
// * Ensure that the credentials used for all Place Autocomplete, Place
487+
// Details, and Address Validation requests within a session belong to the
488+
// same Cloud Console project.
489+
// * Be sure to pass a unique session token for each new session. Using the
490+
// same token for more than one session will result in each request being
491+
// billed individually.
492+
string session_token = 4 [(google.api.field_behavior) = OPTIONAL];
493+
}
494+
495+
// Request proto for AutocompletePlaces.
496+
message AutocompletePlacesRequest {
497+
// The region to search. The results may be biased around the specified
498+
// region.
499+
message LocationBias {
500+
oneof type {
501+
// A viewport defined by a northeast and a southwest corner.
502+
google.geo.type.Viewport rectangle = 1;
503+
504+
// A circle defined by a center point and radius.
505+
Circle circle = 2;
506+
}
507+
}
508+
509+
// The region to search. The results will be restricted to the specified
510+
// region.
511+
message LocationRestriction {
512+
oneof type {
513+
// A viewport defined by a northeast and a southwest corner.
514+
google.geo.type.Viewport rectangle = 1;
515+
516+
// A circle defined by a center point and radius.
517+
Circle circle = 2;
518+
}
519+
}
520+
521+
// Required. The text string on which to search.
522+
string input = 1 [(google.api.field_behavior) = REQUIRED];
523+
524+
// Optional. Bias results to a specified location.
525+
//
526+
// At most one of `location_bias` or `location_restriction` should be set. If
527+
// neither are set, the results will be biased by IP address, meaning the IP
528+
// address will be mapped to an imprecise location and used as a biasing
529+
// signal.
530+
LocationBias location_bias = 2 [(google.api.field_behavior) = OPTIONAL];
531+
532+
// Optional. Restrict results to a specified location.
533+
//
534+
// At most one of `location_bias` or `location_restriction` should be set. If
535+
// neither are set, the results will be biased by IP address, meaning the IP
536+
// address will be mapped to an imprecise location and used as a biasing
537+
// signal.
538+
LocationRestriction location_restriction = 3
539+
[(google.api.field_behavior) = OPTIONAL];
540+
541+
// Optional. Included primary Place type (e.g. "restaurant" or "gas_station")
542+
// from
543+
// https://developers.google.com/maps/documentation/places/web-service/place-types.
544+
// A Place is only returned if its primary type is included in this list. Up
545+
// to 5 values can be specified. If no types are specified, all Place types
546+
// are returned.
547+
repeated string included_primary_types = 4
548+
[(google.api.field_behavior) = OPTIONAL];
549+
550+
// Optional. Only include results in the specified regions, specified as up to
551+
// 15 CLDR two-character region codes. An empty set will not restrict the
552+
// results. If both `location_restriction` and `included_region_codes` are
553+
// set, the results will be located in the area of intersection.
554+
repeated string included_region_codes = 5
555+
[(google.api.field_behavior) = OPTIONAL];
556+
557+
// Optional. The language in which to return results. Defaults to en-US. The
558+
// results may be in mixed languages if the language used in `input` is
559+
// different from `language_code` or if the returned Place does not have a
560+
// translation from the local language to `language_code`.
561+
string language_code = 6 [(google.api.field_behavior) = OPTIONAL];
562+
563+
// Optional. The region code, specified as a CLDR two-character region code.
564+
// This affects address formatting, result ranking, and may influence what
565+
// results are returned. This does not restrict results to the specified
566+
// region. To restrict results to a region, use `region_code_restriction`.
567+
string region_code = 7 [(google.api.field_behavior) = OPTIONAL];
568+
569+
// Optional. The origin point from which to calculate geodesic distance to the
570+
// destination (returned as `distance_meters`). If this value is omitted,
571+
// geodesic distance will not be returned.
572+
google.type.LatLng origin = 8 [(google.api.field_behavior) = OPTIONAL];
573+
574+
// Optional. A zero-based Unicode character offset of `input` indicating the
575+
// cursor position in `input`. The cursor position may influence what
576+
// predictions are returned.
577+
//
578+
// If empty, defaults to the length of `input`.
579+
int32 input_offset = 9 [(google.api.field_behavior) = OPTIONAL];
580+
581+
// Optional. If true, the response will include both Place and query
582+
// predictions. Otherwise the response will only return Place predictions.
583+
bool include_query_predictions = 10 [(google.api.field_behavior) = OPTIONAL];
584+
585+
// Optional. An arbitrary string which identifies an autocomplete session for
586+
// billing purposes. Must be at most 36 characters in length. Otherwise an
587+
// INVALID_ARGUMENT error is returned.
588+
//
589+
// The session begins when the user starts typing a query, and concludes when
590+
// they select a place and a call to Place Details or Address Validation is
591+
// made. Each session can have multiple queries, followed by one Place
592+
// selection. The credentials used for each request within a session must
593+
// belong to the same Google Cloud Console project. Once a session has
594+
// concluded, the token is no longer valid; your app must generate a fresh
595+
// token for each session. If the `session_token` parameter is omitted, or if
596+
// you reuse a session token, the session is charged as if no session token
597+
// was provided (each request is billed separately).
598+
//
599+
// We recommend the following guidelines:
600+
// * Use session tokens for all Place Autocomplete calls.
601+
// * Generate a fresh token for each session. Using a version 4 UUID is
602+
// recommended.
603+
// * Ensure that the credentials used for all Place Autocomplete, Place
604+
// Details, and Address Validation requests within a session belong to the
605+
// same Cloud Console project.
606+
// * Be sure to pass a unique session token for each new session. Using the
607+
// same token for more than one session will result in each request being
608+
// billed individually.
609+
string session_token = 11 [(google.api.field_behavior) = OPTIONAL];
610+
}
611+
612+
// Response proto for AutocompletePlaces.
613+
message AutocompletePlacesResponse {
614+
// An Autocomplete suggestion result.
615+
message Suggestion {
616+
// Identifies a substring within a given text.
617+
message StringRange {
618+
// Zero-based offset of the first Unicode character of the string
619+
// (inclusive).
620+
int32 start_offset = 1;
621+
622+
// Zero-based offset of the last Unicode character (exclusive).
623+
int32 end_offset = 2;
624+
}
625+
626+
// Text representing a Place or query prediction. The text may be used as is
627+
// or formatted.
628+
message FormattableText {
629+
// Text that may be used as is or formatted with `matches`.
630+
string text = 1;
631+
632+
// A list of string ranges identifying where the input request matched in
633+
// `text`. The ranges can be used to format specific parts of `text`. The
634+
// substrings may not be exact matches of `input` if the matching was
635+
// determined by criteria other than string matching (e.g. spell
636+
// corrections or transliterations).
637+
//
638+
// These values are Unicode character offsets of `text`. The ranges are
639+
// guaranteed to be ordered in increasing offset values.
640+
repeated StringRange matches = 2;
641+
}
642+
643+
// Contains a breakdown of a Place or query prediction into main text
644+
// and secondary text.
645+
//
646+
// For Place predictions, the main text contains the specific name of the
647+
// Place. For query predictions, the main text contains the query.
648+
//
649+
// The secondary text contains additional disambiguating features (such as a
650+
// city or region) to further identify the Place or refine the query.
651+
message StructuredFormat {
652+
// Represents the name of the Place or query.
653+
FormattableText main_text = 1;
654+
655+
// Represents additional disambiguating features (such as a city or
656+
// region) to further identify the Place or refine the query.
657+
FormattableText secondary_text = 2;
658+
}
659+
660+
// Prediction results for a Place Autocomplete prediction.
661+
message PlacePrediction {
662+
// The resource name of the suggested Place. This name can be used in
663+
// other APIs that accept Place names.
664+
string place = 1 [(google.api.resource_reference) = {
665+
type: "places.googleapis.com/Place"
666+
}];
667+
668+
// The unique identifier of the suggested Place. This identifier can be
669+
// used in other APIs that accept Place IDs.
670+
string place_id = 2;
671+
672+
// Contains the human-readable name for the returned result. For
673+
// establishment results, this is usually the business name and address.
674+
//
675+
// `text` is recommended for developers who wish to show a single UI
676+
// element. Developers who wish to show two separate, but related, UI
677+
// elements may want to use `structured_format` instead. They are two
678+
// different ways to represent a Place prediction. Users should not try to
679+
// parse `structured_format` into `text` or vice versa.
680+
//
681+
// This text may be different from the `display_name` returned by
682+
// GetPlace.
683+
//
684+
// May be in mixed languages if the request `input` and `language_code`
685+
// are in different languages or if the Place does not have a translation
686+
// from the local language to `language_code`.
687+
FormattableText text = 3;
688+
689+
// A breakdown of the Place prediction into main text containing the name
690+
// of the Place and secondary text containing additional disambiguating
691+
// features (such as a city or region).
692+
//
693+
// `structured_format` is recommended for developers who wish to show two
694+
// separate, but related, UI elements. Developers who wish to show a
695+
// single UI element may want to use `text` instead. They are two
696+
// different ways to represent a Place prediction. Users should not try to
697+
// parse `structured_format` into `text` or vice versa.
698+
StructuredFormat structured_format = 4;
699+
700+
// List of types that apply to this Place from Table A or Table B in
701+
// https://developers.google.com/maps/documentation/places/web-service/place-types.
702+
//
703+
// A type is a categorization of a Place. Places with shared types will
704+
// share similar characteristics.
705+
repeated string types = 5;
706+
707+
// The length of the geodesic in meters from `origin` if `origin` is
708+
// specified. Certain predictions such as routes may not populate this
709+
// field.
710+
int32 distance_meters = 6;
711+
}
712+
713+
// Prediction results for a Query Autocomplete prediction.
714+
message QueryPrediction {
715+
// The predicted text. This text does not represent a Place, but rather a
716+
// text query that could be used in a search endpoint (e.g. TextSearch).
717+
//
718+
// `text` is recommended for developers who wish to show a single UI
719+
// element. Developers who wish to show two separate, but related, UI
720+
// elements may want to use `structured_format` instead. They are two
721+
// different ways to represent a query prediction. Users should not try to
722+
// parse `structured_format` into `text` or vice versa.
723+
//
724+
// May be in mixed languages if the request `input` and `language_code`
725+
// are in different languages or if part of the query does not have a
726+
// translation from the local language to `language_code`.
727+
FormattableText text = 1;
728+
729+
// A breakdown of the query prediction into main text containing the query
730+
// and secondary text containing additional disambiguating features (such
731+
// as a city or region).
732+
//
733+
// `structured_format` is recommended for developers who wish to show two
734+
// separate, but related, UI elements. Developers who wish to show a
735+
// single UI element may want to use `text` instead. They are two
736+
// different ways to represent a query prediction. Users should not try to
737+
// parse `structured_format` into `text` or vice versa.
738+
StructuredFormat structured_format = 2;
739+
}
740+
741+
oneof kind {
742+
// A prediction for a Place.
743+
PlacePrediction place_prediction = 1;
744+
745+
// A prediction for a query.
746+
QueryPrediction query_prediction = 2;
747+
}
748+
}
749+
750+
// Contains a list of suggestions, ordered in descending order of relevance.
751+
repeated Suggestion suggestions = 1;
441752
}

0 commit comments

Comments
 (0)