مخزن Maps SDK برای iOS در GitHub حاوی نمونههایی است که استفاده از Maps SDK برای iOS را در برنامه iOS شما نشان میدهد. برنامه نمونه حاوی کدهایی برای ویژگی های برجسته SDK است و می تواند نقطه شروع برنامه شما باشد.
فهرست نمونه نقشههای SDK برای iOS
نمونه فعالیت های کلیدی از برنامه آزمایشی در زیر فهرست شده است و برای مرجع سریع در صفحات پیوند داده شده است. برای مشاهده لیست کامل نمونه های موجود به پوشه نمونه های GitHub مراجعه کنید.
برنامه نمونه Maps SDK برای iOS به عنوان یک بایگانی دانلود از GitHub در دسترس است. این مراحل را دنبال کنید تا برنامه نمونه Maps SDK برای iOS را نصب و امتحان کنید.
git clone https://github.com/googlemaps-samples/maps-sdk-for-ios-samples.git را اجرا کنید تا مخزن نمونه ها را در یک فهرست محلی کلون کنید.
یک پنجره ترمینال را باز کنید، به دایرکتوری که فایلهای نمونه را در آن کلون کردهاید بروید، و به فهرست راهنمای GoogleMaps بروید:
سویفت
cd maps-sdk-for-ios-samples-main/GoogleMaps-Swift pod installopen GoogleMapsSwiftDemos.xcworkspace
هدف-C
cd maps-sdk-for-ios-samples-main/GoogleMaps pod installopen GoogleMapsDemos.xcworkspace
در Xcode، دکمه کامپایل را فشار دهید تا برنامه با طرح فعلی ساخته شود . بیلد یک خطایی ایجاد میکند که از شما میخواهد کلید API خود را در فایل SDKConstants.swift برای Swift یا فایل SDKDemoAPIKey.h برای Objective-C وارد کنید.
فایل SDKConstants.swift را برای Swift یا SDKDemoAPIKey.h برای Objective-C ویرایش کنید و کلید API خود را در تعریف ثابت apiKey یا kAPIKey قرار دهید. به عنوان مثال:
سویفت
staticletapiKey="YOUR_API_KEY"
هدف-C
staticNSString*constkAPIKey=@"YOUR_API_KEY";
در فایل SDKConstants.swift (Swift) یا فایل SDKDemoAPIKey.h (Objective-C)، خط زیر را حذف کنید، زیرا برای ثبت مشکل تعریف شده توسط کاربر استفاده می شود:
تاریخ آخرین بهروزرسانی 2025-07-23 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-07-23 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eThe Maps SDK for iOS provides a sample app with code examples showcasing key features, serving as a starting point for your iOS app development.\u003c/p\u003e\n"],["\u003cp\u003eYou can find a comprehensive list of samples in the GitHub repository and easily access specific feature implementations through provided links.\u003c/p\u003e\n"],["\u003cp\u003eTo run the full sample app locally, clone the repository, install dependencies using CocoaPods, and build the project in Xcode after configuring your API key.\u003c/p\u003e\n"],["\u003cp\u003eTroubleshooting 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.\u003c/p\u003e\n"]]],["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"],null,["Select platform: [Android](/maps/documentation/android-sdk/examples \"View this page for the Android platform docs.\") [iOS](/maps/documentation/ios-sdk/examples \"View this page for the iOS platform docs.\") [JavaScript](/maps/documentation/javascript/examples \"View this page for the JavaScript platform docs.\")\n\n\u003cbr /\u003e\n\nThe Maps SDK for iOS repository on\n[GitHub](https://github.com/googlemaps-samples/maps-sdk-for-ios-samples/tree/main/GoogleMaps)\ncontains samples illustrating the use of the Maps SDK for iOS\nin your iOS app. The sample app contains code for feature highlights of the SDK,\nand can be used starting point for your app.\n| **Troubleshooting:** If the sample app runs successfully but you don't see a map, check that you've added your API key to the app's manifest file, as described in [Using API Keys](/maps/documentation/ios-sdk/get-api-key).\n\nMaps SDK for iOS samples list\n\nKey sample activities from the demo app are listed below and reproduced at the\nlinked pages for quick reference. See the GitHub [samples\nfolder](https://github.com/googlemaps-samples/maps-sdk-for-ios-samples/tree/main/GoogleMaps/GoogleMapsDemos/Samples)\nfor the full list of available samples.\n\n- [Display a basic map](/maps/documentation/ios-sdk/examples/basic-map)\n- [Display an info window for a marker](/maps/documentation/ios-sdk/examples/info-window-marker)\n- [Add a marker to a map](/maps/documentation/ios-sdk/examples/add-marker)\n- [Reverse geocode a location](/maps/documentation/ios-sdk/examples/reverse-geocode)\n- [Enable and disable map gestures](/maps/documentation/ios-sdk/examples/enable-disable-gestures)\n- [Handle marker events](/maps/documentation/ios-sdk/examples/handle-marker-events)\n- [Enable the My Location Button](/maps/documentation/ios-sdk/examples/enable-my-location)\n- [Draw polygons on a map](/maps/documentation/ios-sdk/examples/draw-polygons)\n- [Draw polylines on a map](/maps/documentation/ios-sdk/examples/draw-polylines)\n\nRun the full sample app locally\n\nThe Maps SDK for iOS sample app is available as a\n[download archive](https://github.com/googlemaps-samples/maps-sdk-for-ios-samples/archive/main.zip)\nfrom [GitHub](https://github.com/googlemaps-samples/maps-sdk-for-ios-samples/tree/main/GoogleMaps).\nFollow these steps to install and try the Maps SDK for iOS sample app.\n\n1. Run `git clone https://github.com/googlemaps-samples/maps-sdk-for-ios-samples.git` to clone the samples repository into a local directory.\n2. Open a terminal window, navigate to the directory where you cloned the sample files, and\n drill down into the GoogleMaps directory:\n\n Swift \n\n cd maps-sdk-for-ios-samples-main/GoogleMaps-Swift\n pod install\n open GoogleMapsSwiftDemos.xcworkspace\n\n Objective-C \n\n cd maps-sdk-for-ios-samples-main/GoogleMaps\n pod install\n open GoogleMapsDemos.xcworkspace\n\n3. In Xcode, press the compile button to [build the app](https://developer.apple.com/documentation/xcode/building-and-running-an-app) with the current scheme. The build produces an error, prompting you to enter your API key in the `SDKConstants.swift` file for Swift or`SDKDemoAPIKey.h` file for Objective-C.\n4. [Get an API key](/maps/documentation/ios-sdk/get-api-key) from your project with the [Maps SDK for iOS enabled](/maps/documentation/ios-sdk/cloud-setup#enabling-apis).\n5. Edit the `SDKConstants.swift` file for Swift or`SDKDemoAPIKey.h` file for Objective-C and paste your API key into the definition of either the `apiKey` or `kAPIKey` constant. For example: \n\n Swift \n\n ```swift\n static let apiKey = \"YOUR_API_KEY\"\n ```\n\n Objective-C \n\n ```objective-c\n static NSString *const kAPIKey = @\"YOUR_API_KEY\";\n ```\n6. In the `SDKConstants.swift` file (Swift) or`SDKDemoAPIKey.h` file (Objective-C), remove the following line, because it's used to register the user-defined issue: \n\n Swift \n\n ```swift\n #error (Register for API Key and insert here. Then delete this line.)\n ```\n\n Objective-C \n\n ```objective-c\n #error Register for API Key and insert here.\n ```\n7. Build and run the project. The iOS simulator window appears, showing a list of **Maps SDK Demos**.\n8. Choose one of the options displayed, to experiment with a feature of the Maps SDK for iOS.\n9. If prompted to allow GoogleMapsDemos to access your location, choose **Allow**."]]