選擇 SDK 版本

Places SDK for iOS 8.5.0 版支援兩個 SDK 版本:Places SDK for iOS 是現行的 Places SDK for iOS (新版) 版本。

Places SDK for iOS 8.5.0 推出後,您的第一項工作就是決定要使用哪個 SDK。如果您是新客戶或已使用 SDK 的現有客戶,就屬於這種情況。本指南將說明這兩個 SDK 之間的主要差異。

如何選取 SDK 版本

Places SDK for iOS 需要使用 Places API 服務。您必須先在 Google Cloud 專案中啟用 Places API 服務,才能使用 Places SDK for iOS。

您啟用的 Places API 服務版本會控制應用程式使用的 SDK 版本:

  • Places API:啟用現有的 Places SDK for iOS。如果只針對與應用程式所用 API 金鑰相關聯的專案啟用 Places API,您的應用程式將無法存取 Places SDK for iOS 8.5.0 以上版本中新增的功能。

  • Places API (新版):啟用 Places SDK for iOS (新版),包括「文字搜尋」和「Places SDK for iOS (新版) 新增的主要功能」一文中所述的所有新功能。不會啟用現有功能,例如 Place Details、Place Photos、Current Place 和 Place Autocomplete。

  • 兩者:啟用 Places SDK for iOS (New)Places SDK for iOS 的所有功能。

如要進一步瞭解如何選取 Places API 服務,請參閱「設定 Google Cloud 專案」一文。

您選用哪一種 SDK?

如何決定要選擇的版本:

  1. 如果您是剛開始使用 Places SDK for iOS 的新客戶,請先採用 Places API (新版) 和 Places API,以便使用所有功能。

  2. 如果您是現有客戶,可以繼續使用現有的 SDK。不過,如要享有 Places SDK for iOS (新版) 的效能改善項目和功能強化項目,您可以使用新版 SDK。

    改用新版 SDK 時不需要進行遷移。您只需為應用程式使用的 API 金鑰啟用 Places SDK for iOS (新版)。如果同時使用現有的 Places SDK for iOSPlaces SDK for iOS (新版),請在 API 金鑰中啟用這兩個版本。詳情請參閱「使用 API 金鑰」一文。

Places SDK for iOS 新增的主要功能

本節說明新增至 Places SDK for iOS (新版) 的主要功能。

已在 Google Cloud Standard 平台上實作

Places SDK for iOS (新版) 已導入 Google Cloud 的服務基礎架構。這種實作方式可提供更加安全可靠的平台。 這個標準設計可跨 SDK 具備一致性,使用 Places SDK for iOS (新版) 可改善開發效率。

提高效能

Places SDK for iOS (新版) 已改善效能,建議您替換使用現有 SDK 的應用程式。

Text Search 可根據字串 (例如「臺北披薩」、「臺北披薩店」或「中正路 123 號」) 傳回一組地點的相關資訊。這項服務會傳回與文字字串和位置自訂調整設定相符的地點清單。

簡化計費模式

Places SDK for iOS (新版) 簡化了定價作業,因此您只需要為實際使用的資料付費。系統會使用欄位清單 (也稱為「欄位遮罩」) 來實作簡化定價。

使用 Places SDK for iOSText Search 時,您可以使用欄位清單控管回應中要傳回的欄位清單。如此一來,您只需為所要求的資料付費。使用欄位清單是不錯的設計做法,可避免要求不必要的資料,避免不必要的處理時間和帳單費用。

如需詳細的兩個 SDK 的定價資訊,請參閱「用量與帳單」一文。

展開的地點類型

新版 SDK 會新增下表顯示的地點類型。這些類型會做為 Place Details 和 Text Search 回應的一部分傳回。您也可以使用這些新類型和現有類型,透過文字搜尋進行搜尋。新類型已包含在表 A 中。

類型
american_restaurant discount_store ice_cream_shop sandwich_shop
amusement_center dog_park indian_restaurant school_district
athletic_field electric_vehicle_charging_station indonesian_restaurant seafood_restaurant
auto_parts_store event_venue italian_restaurant ski_resort
banquet_hall extended_stay_hotel japanese_restaurant spanish_restaurant
barbecue_restaurant 設備 korean_restaurant sporting_goods_store
barber_shop Farmstay lebanese_restaurant sports_club
bed_and_breakfast fast_food_restaurant Marina sports_complex
brazilian_restaurant ferry_terminal 市場 steak_house
breakfast_restaurant fitness_center medical_lab sushi_restaurant
brunch_restaurant french_restaurant mediterranean_restaurant swimming_pool
bus_stop gift_shop mexican_restaurant 量身訂製
camping_cabin golf_course middle_eastern_restaurant telecommunications_service_provider
cell_phone_store greek_restaurant 汽車旅館 thai_restaurant
child_care_agency grocery_store national_park transit_depot
chinese_restaurant guest_house park_and_ride truck_stop
coffee_shop hair_salon performing_arts_theater turkish_restaurant
community_center hamburger_restaurant pizza_restaurant vegan_restaurant
顧問 Heliport playground vegetarian_restaurant
convention_center hiking_area 學齡前幼童 vietnamese_restaurant
木屋 historical_landmark private_guest_room visitor_center
courier_service home_improvement_store ramen_restaurant wedding_venue
cultural_center 青年旅館 resort_hotel 批發商
dental_clinic hotel rest_stop
除了這些新類型外,Places API (新版) 已從資料表 B 中移除下列類型。也就是說,現在您可以在搜尋中使用下列類型:
  • country
  • administrative_area_level_1
  • administrative_area_level_2
  • postal_code
  • locality