Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Trang này mô tả những việc bạn cần làm để thiết lập và bắt đầu tạo bằng Maps 3D SDK cho iOS. Quy trình thiết lập bao gồm việc định cấu hình một dự án Google Cloud và API để sử dụng với SDK, sau đó thiết lập một dự án Xcode.
Hoàn tất các bước sau trước khi thêm bản đồ 3D đầu tiên vào ứng dụng của bạn.
Thiết lập dự án trên Google Cloud và khoá API
Trước khi có thể bắt đầu tạo bằng Maps 3D SDK cho iOS, bạn cần thiết lập một dự án Google Cloud và khoá API để sử dụng với Maps 3D SDK cho iOS bằng cách hoàn tất các bước sau:
Trong cửa sổ Chọn sản phẩm trong gói, hãy xác minh rằng GoogleMaps3D sẽ được thêm vào mục tiêu chính được chỉ định. Sau khi hoàn tất, hãy nhấp vào Thêm gói.
Để xác minh quá trình cài đặt, hãy chuyển đến ngăn Chung của mục tiêu. Trong phần Frameworks, Libraries, and Embedded Content (Khung, thư viện và nội dung được nhúng), bạn sẽ thấy các gói đã cài đặt. Bạn cũng có thể xem phần Package Dependencies (Phần phụ thuộc của gói) trong Project Navigator (Trình điều hướng dự án) để xác minh gói và phiên bản của gói.
Bước 3: Thêm khoá API vào ứng dụng
Trình quản lý gói Swift
Thêm khoá API vào điểm truy cập chính cho ứng dụng của bạn (hoặc bất cứ lúc nào trước khi bản đồ tải) như sau.
Thêm câu lệnh nhập sau:
importGoogleMaps3D
Thêm phương thức sau. Thay thế YOUR_API_KEY bằng khoá API của bạn.
Bước 4 (không bắt buộc): Kiểm tra tệp Tuyên bố về quyền riêng tư của Apple
Apple yêu cầu cung cấp thông tin chi tiết về quyền riêng tư trong ứng dụng cho các ứng dụng trên App Store.
Tệp Tuyên bố về quyền riêng tư của Apple có trong gói tài nguyên cho SDK.
Để xác minh rằng Tệp kê khai quyền riêng tư đã được đưa vào và để kiểm tra nội dung của tệp này, hãy tạo một kho lưu trữ ứng dụng rồi tạo báo cáo về quyền riêng tư từ kho lưu trữ đó.
Các bước tiếp theo
Giờ đây, bạn đã thiết lập dự án Google Cloud, khoá API và dự án Xcode để sử dụng với Maps 3D SDK cho iOS, bạn có thể Thêm bản đồ 3D vào ứng dụng của mình.
[null,null,["Cập nhật lần gần đây nhất: 2025-08-31 UTC."],[],[],null,["\u003cbr /\u003e\n\n| This product or feature is Experimental (pre-GA). Pre-GA products and features might have limited support, and changes to pre-GA products and features might not be compatible with other pre-GA versions. Pre-GA Offerings are covered by the [Google\n| Maps Platform Service Specific Terms](https://cloud.google.com/maps-platform/terms/maps-service-terms). For more information, see the [launch stage descriptions](/maps/launch-stages).\n\n\u003cbr /\u003e\n\nThis page describes what you need to do to get set up to start building with the\nMaps 3D SDK for iOS. The setup process involves configuring a Google Cloud\nproject and API for use with the SDK, and then setting up an Xcode project.\nComplete these steps before [adding your first 3D map to your\napp](/maps/documentation/maps-3d/ios-sdk/add-a-3d-map).\n\nSet up a Google Cloud project and API key\n\nBefore you can start building with the Maps 3D SDK for iOS, you need to set up a\nGoogle Cloud project and API key to use with the Maps 3D SDK for iOS by\ncompleting the following steps:\n\nStep 1\n\nConsole \n\n1. In the Google Cloud console, on the project selector page, click\n **Create Project** to begin creating a new Cloud\n project.\n\n [Go to the project selector page](https://console.cloud.google.com/projectselector2/home/dashboard?utm_source=Docs_NewProject&utm_content=Docs_Central)\n2. Make sure that billing is enabled for your Cloud project.\n [Confirm that billing is enabled for your project](https://console.cloud.google.com/project/_/billing?utm_source=Docs_Billing&utm_content=Docs_Central).\n\n Google Cloud offers a $0.00 charge trial. The trial expires at either end of 90\n days or after the account has accrued $300 worth of charges, whichever comes first. Cancel\n anytime. For more information, see\n [Billing account credits](/maps/billing-credits) and [Billing](/maps/billing-and-pricing/billing).\n\nCloud SDK \n\n```bash\ngcloud projects create \"\u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e\"\n```\n\nRead more about the\n[Google Cloud SDK](https://cloud.google.com/sdk)\n,\n[Cloud SDK installation](https://cloud.google.com/sdk/docs/install)\n, and the following commands:\n\n- [`gcloud projects create`](https://cloud.google.com/sdk/gcloud/reference/projects/create)\n| **Note**: If you don't plan to keep the resources that you create in a learning exercise, create a project instead of selecting an existing project. After you finish the exercise, you can delete the project, removing all resources associated with the project.\n\nStep 2\n\nTo use Google Maps Platform, you must enable the APIs or SDKs you plan to use with your project.\n\nNote that some integrations require you to enable multiple APIs/SDKs. If you are not sure which\nAPIs or SDKs to enable, try using\nthe [API Picker](/maps/documentation/api-picker), or consult the\ndocumentation for the API/SDK you want to use.\n\nTo enable one or more APIs or SDKs:\n\nConsole \n\n1. See the Google Maps Platform APIs and SDKs that you can enable by going to the Maps API\n Library page in the Cloud console:\n\n Go to the [Maps API Library\n page](https://console.cloud.google.com/project/_/google/maps-apis/api-list?utm_source=Docs_EnableAPIs&utm_content=Docs_Central)\n2. Click the API or SDK you want to enable.\n - If the button says **ENABLE**, click the button to enable the API or SDK.\n - If the button says **MANAGE**, the API or SDK is already enabled and you don't need to do anything further.\n - Clicking either button will display the dashboard for the API or SDK. (Click the **DISABLE** button to remove the API or SDK from this project.)\n\nCloud SDK\n\nThe following command enables all of the Maps, Routes, and Places APIs: \n\n```bash\ngcloud services enable \\\n --project \"\u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e\" \\\n \"addressvalidation.googleapis.com\" \\\n \"areainsights.googleapis.com\" \\\n \"tile.googleapis.com\" \\\n \"aerialview.googleapis.com\" \\\n \"elevation-backend.googleapis.com\" \\\n \"routes.googleapis.com\" \\\n \"geocoding-backend.googleapis.com\" \\\n \"geolocation.googleapis.com\" \\\n \"maps-android-backend.googleapis.com\" \\\n \"maps-backend.googleapis.com\" \\\n \"maps-embed-backend.googleapis.com\" \\\n \"maps-ios-backend.googleapis.com\" \\\n \"mapsplatformdatasets.googleapis.com\" \\\n \"places-backend.googleapis.com\" \\\n \"roads.googleapis.com\" \\\n \"routeoptimization.googleapis.com\" \\\n \"static-maps-backend.googleapis.com\" \\\n \"street-view-image-backend.googleapis.com\" \\\n \"timezone-backend.googleapis.com\"\n```\n\nRead more about the\n[Google Cloud SDK](https://cloud.google.com/sdk)\n,\n[Cloud SDK installation](https://cloud.google.com/sdk/docs/install)\n, and the following commands:\n\n- [`gcloud services enable`](https://cloud.google.com/sdk/gcloud/reference/services/enable)\n- [`gcloud services disable`](https://cloud.google.com/sdk/gcloud/reference/services/disable)\n\nUse this command to enable the Environment APIs: \n\n```bash\ngcloud services enable \\\n --project \"\u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e\" \\\n \"airquality.googleapis.com\" \\\n \"solar.googleapis.com\" \\\n \"pollen.googleapis.com\" \\\n \"weather.googleapis.com\"\n```\n| **Note:** Enabling Places API also enables the Places Library, Maps JavaScript API, Places SDK for Android and Places SDK for iOS.\n\nStep 3\n\nThis step only goes through the API Key creation process. If you use your API Key in\nproduction, we strongly recommend that you restrict your API key. You can find more\ninformation in the product-specific **Using API Keys** page.\n\nThe API key is a unique identifier that authenticates requests associated with your project for\nusage and billing purposes. You must have at least one API key associated with your project.\n\nTo create an API key:\n\nConsole \n\n1. Go to the **Google Maps Platform \\\u003e Credentials** page.\n\n [Go to the Credentials page](https://console.cloud.google.com/project/_/google/maps-apis/credentials?utm_source=Docs_CreateAPIKey&utm_content=Docs_Central)\n2. On the **Credentials** page, click **Create credentials \\\u003e API key** . \n The **API key created** dialog displays your newly created API key.\n3. Click **Close.** \n The new API key is listed on the **Credentials** page under **API keys** . \n (Remember to [restrict the API](/maps/api-security-best-practices#restricting-api-keys) key before using it in production.)\n\nCloud SDK \n\n```bash\ngcloud services api-keys create \\\n --project \"\u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e\" \\\n --display-name \"\u003cvar translate=\"no\"\u003eDISPLAY_NAME\u003c/var\u003e\"\n```\n\nRead more about the\n[Google Cloud SDK](https://cloud.google.com/sdk)\n,\n[Cloud SDK installation](https://cloud.google.com/sdk/docs/install)\n, and the following commands:\n\n- [`gcloud services api-keys create`](https://cloud.google.com/sdk/gcloud/reference/services/api-keys/create)\n\nTo enable the SDK, see the [Maps 3D SDK for iOS](https://console.cloud.google.com/apis/library/mapsios.googleapis.com)\npage in the Google Cloud console. For more information about completing these\nsteps, see [Getting started with the Google Maps Platform](/maps/get-started).\n\nSet up an Xcode project\n\nThis section explains how to create and configure an Xcode project for use with\nthe Maps 3D SDK for iOS.\n\nAfter you enable billing and create an API key, you're ready to set up the Xcode\nproject that you use to develop your app.\n\nStep 1: Install the required software\n\nTo build a project using the Maps 3D SDK for iOS, you must download and install:\n\n- [Xcode](https://developer.apple.com/xcode/) **version\n 16.0** or later\n\nStep 2: Create the Xcode project and install the Maps 3D SDK for iOS \n\nSwift Package Manager\n\n\nThe Maps 3D SDK for iOS can be installed using Swift Package Manager.\n\nTo add the SDK to a new or existing project, follow these steps:\n\n- Open your Xcode `project` or `workspace`, then go to **File** \\\u003e **Add Package Dependencies**.\n- Enter \u003chttps://github.com/googlemaps/ios-maps-3d-sdk\u003e as the URL, press **Enter** to pull in the package, and click \"Add Package\".\n- From the **Choose Package Products** window, verify that `GoogleMaps3D` will be added to your designated main target. Once complete, click **Add Package**.\n- To verify your installation, navigate to your target's **General** pane. In **Frameworks, Libraries, and Embedded Content** , you should see the installed packages. You can also view the **Package Dependencies** section of **Project Navigator** to verify the package and its version.\n\nStep 3: Add the API key to your app \n\nSwift Package Manager\n\nAdd your API key to the main entry point for your app (or any time before the map loads) as follows.\n\n1. Add the following import statement: \n\n ```swift\n import GoogleMaps3D\n ```\n2. Add the following method. Replace `YOUR_API_KEY` with your API key. \n\n ```swift\n struct ContentView: View {\n init () {\n Map.apiKey = \"YOUR_API_KEY\"\n }\n\n var body: some View {\n Map(mode: .hybrid)\n }\n }\n \n ```\n| The API key can appear in your app's entry point or separately for each map view. If the API key is specified both in the entry point and the map views, however, the console will produce an error.\n\nStep 4 (optional): Inspect Apple Privacy Manifest file **Note:** The following is relevant when you deploy your app to the web store.\n\nApple requires app privacy details for apps on the App Store.\n\nThe Apple Privacy Manifest file is included in the resources bundle for the SDK.\nTo verify that the Privacy Manifest File has been included, and to inspect its\ncontents, create an archive of your app and [generate a privacy\nreport](https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/describing_data_use_in_privacy_manifests#4239187)\nfrom the archive.\n\nNext steps\n\nNow that you have a Google Cloud project, API key, and Xcode project\nset up for use with the Maps 3D SDK for iOS, you can [Add a 3D map to your\napp](/maps/documentation/maps-3d/ios-sdk/add-a-3d-map)."]]