How to implement Google Places Autocomplete per se

2019-05-07 05:03发布

问题:

Is it possible to implement session based autocomplete from the places sdk for Android and iOS apps?

According to new Google Maps framework pricing coming into effect June 11th request made to autocomplete can be broken down into keystroke/session based.

I haven't been able to find documentation describing implementation steps, except for this reference.

回答1:

The session tokens will be available in the new versions of Google Places SDK for Android and Google Places SDK for iOS. These new versions are announced in the user guide documentation.

Google is currently preparing new versions of the Places SDK for Android, and the Places SDK for iOS. The following section describes the changes and explains how they will affect you.

  • A new Places SDK for Android will be made available as a standalone library, and will no longer be available through Google Play services; This version will not be backward-compatible with the current SDK
  • A new Places SDK for iOS will be made available

It's worth noting that several Places SDK features will be updated to reflect overall Places API changes, affecting both mobile platforms:

  • Place Details (Android, iOS) request will have a new fields parameter.
  • Autocomplete billing will be session-based.

In the coming months we will share more details including a timeline and appropriate lead time to migrate to the new SDK versions. These new versions will replace the current SDK versions. The current SDKs will be deprecated and will follow appropriate deprecation timelines.

source: https://cloud.google.com/maps-platform/user-guide/product-changes/

In the current version of Places SDK there are no session tokens. Unfortunately, there is no exact ETA for new versions of SDKs. Hopefully, they will be available in couple of months. Stay tuned to Google announcements.

Regarding billing of current versions of Places SDK for Android and Places SDK for iOS I'm not sure. Probably they will be free of charge as deprecated versions. I would suggest reach out to Google support with this question.

You can also check this question regarding sessions:

How long do the new Places API session tokens last?

I hope this clarifies your doubt.

Update

The new version of the Places Android SDK is now available. You can read about the new version at

https://developers.google.com/places/android-sdk/client-migration

Note that the previous SDK is deprecated and will be shut down on July 29, 2019.

The new version of SDK implements session tokens for autocomplete.

The new version of the Places SDK for Android is distributed as a static client library. Until now, the Places SDK for Android has been made available through Google Play Services.

A compatibility library is available, which enables you to switch from the deprecated Google Play Services Places library to the new static library with minimal effort.

There are all-new methods.

Field masks are now supported for methods that return place details. You can use field masks to specify which types of place data to return.

The exceptions used to report errors have been improved.

Autocomplete now supports session tokens.