如果您尚未取得 API 金鑰,請按照操作說明在 Google Cloud 控制台中設定專案並取得 API 金鑰。在 Cloud 控制台中設定金鑰時,您可以限制金鑰,只允許範例應用程式的軟體包 ID 使用金鑰,確保只有您的應用程式可以使用金鑰。SDK 範例應用程式的預設套件 ID 為 com.example.GoogleMapsDemos。
編輯 Swift 的 SDKConstants.swift 檔案或 Objective-C 的 SDKDemoAPIKey.h 檔案,然後將 API 金鑰貼到 apiKey 或 kAPIKey 常數的定義中。例如:
[null,null,["上次更新時間:2025-02-25 (世界標準時間)。"],[[["The Maps SDK for iOS provides a sample app with code examples showcasing key features, serving as a starting point for your iOS app development."],["You can find a comprehensive list of samples in the GitHub repository and easily access specific feature implementations through provided links."],["To run the full sample app locally, clone the repository, install dependencies using CocoaPods, and build the project in Xcode after configuring your API key."],["Troubleshooting steps are available if you encounter issues like not seeing a map after successfully running the app, guiding you to add your API key correctly."]]],["The provided content focuses on using the Maps SDK for iOS. Key actions include cloning the sample app repository from GitHub, building the app in Xcode, and integrating an API key. The API key is obtained from the Google Cloud console. After entering the API key, you can build and run the project. You then can interact with the various features demonstrated, like displaying a basic map, adding markers, drawing shapes, enabling location, and handling events. Finally, the content mentions the necessity to grant the app location access.\n"]]