تجربه ناوبری سفارشی
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
Navigation SDK راه های مختلفی را برای ادغام تجربه ناوبری در برنامه شما ارائه می دهد. این صفحه توضیح میدهد که تجربه پیمایش سفارشی چیست و چه تفاوتی با سایر تجربههای ناوبری موجود در Navigation SDK دارد.
تجربه ناوبری سفارشی چیست؟
راه اصلی برای اجرای Navigation SDK استفاده از تجربه ناوبری Google است که به شما امکان می دهد یک تجربه ناوبری گام به گام را جاسازی کنید که از عناصر و تصاویر بصری ارائه شده توسط Google استفاده می کند - شبیه به تجربه ناوبری در برنامه های Google Maps. اگر به انعطافپذیری بیشتری نسبت به تجربه ناوبری Google نیاز دارید، میتوانید یک تجربه ناوبری سفارشی را پیادهسازی کنید. یک تجربه ناوبری سفارشی به هر چیزی اشاره دارد، از حذف کامل هدایت چرخشی با و اجرای ناوبری فقط به عنوان یک فرآیند پسزمینه، تا نمایش یک تجربه هدایت بسیار سفارشی شده به صفحهای جدا از دستگاهی که ناوبری را اجرا میکند. با یک تجربه ناوبری سفارشی، برنامه شما Navigation SDK را برای درخواست فید پیمایش گام به گام فراخوانی می کند و سپس عناصر و تصاویر بصری UI را که کاربر در تجربه ناوبری می بیند، ارائه و مدیریت می کنید. در حالی که استفاده از تجربه ناوبری Google به طور کلی ساده تر است، ایجاد تجربه ناوبری سفارشی شما امکان سفارشی سازی بیشتر را فراهم می کند.
وقتی یک تجربه ناوبری سفارشی ایجاد میکنید، برنامه شما با استفاده از جریان زیر، Navigation SDK را برای شروع، اجرا و توقف ناوبری فراخوانی میکند:
ناوبری را شروع کنید . همانند تجربه ناوبری Google، یک تجربه ناوبری سفارشی همچنان شامل ایجاد یک نمونه ناوبری و تنظیم مقصد است. با این حال، با یک تجربه ناوبری سفارشی شده، ابتدا با ایجاد یک جلسه ناوبری با استفاده از GMSNavigationService.createNavigationSession
، که یک شی غیر UI دارای حالت است که می تواند با یک view controller یا بدون آن کار کند، به این مهم دست می یابید.
برای اطلاعات بیشتر، به فعال کردن فید داده گام به گام مراجعه کنید.
مشاهده نسخه نمایشی: دانلود Navigation SDK حاوی نسخهای است که میتوانید آن را اجرا کنید تا نمونهای از تجربه ناوبری را مشاهده کنید که بین هدایت گام به گام از طریق ناوبری استاندارد به تجربه ناوبری تغییر میکند که فقط مکان دستگاه را نشان میدهد که در امتداد چند خط جاده حرکت میکند.
ناوبری فعال در اینجا یک تفاوت کلیدی دیگر بین یک تجربه ناوبری ارائه شده توسط Google و یک تجربه ناوبری سفارشی وجود دارد. به جای اینکه راهنمایی را به مدیر رویداد داخلی Navigation SDK بدهید، فید گام به گام را فعال کرده و کنترلکنندههای رویداد را پیادهسازی میکنید. این به تجربه شما اجازه میدهد به رویدادهایی که در گوش دادن به رویدادهای پیمایش توضیح داده شده است پاسخ دهد.
پایان ناوبری مانند تجربه ناوبری Google، ناوبری سفارشی همچنین از شما میخواهد که ناوبری را به بهترین شکلی که برای تجربه برنامه مناسب است، خاتمه دهید.
چه زمانی ممکن است از یک تجربه ناوبری سفارشی استفاده کنید؟
جدول زیر برخی از سناریوهای ناوبری سفارشی را شرح می دهد.
سناریوی نمونه | مراحل سطح بالا |
---|
برای دستگاههای کوچک مانند وسایل نقلیه دو چرخ، باید راهنمای راننده فقط به صورت متنی ارائه کنید. | ناوبر خود را ایجاد کنید و راهنمایی گام به گام را به عنوان یک تغذیه داده برای یک دستگاه صفحه کوچک تنظیم کنید، در حالی که ناوبر در تلفن همراه راننده خارج از نمای فوری او کار می کند. |
میخواهید برنامهتان را بهعنوان یک سرویس خودرو برای رانندگانی که از Android Auto استفاده میکنند در دسترس قرار دهید. | - سرویس خودرو را راه اندازی کنید.
- پروژه Navigation SDK خود را تنظیم کنید.
- اگر قبلاً این کار را نکرده اید، یک ناوبر ایجاد کنید.
- فید راهنمای گام به گام را فعال کنید.
- نقشه را روی سطح برنامه خودکار بکشید و فیلدها را از فید داده ای که پیکربندی کرده اید پر کنید.
برای اطلاعات بیشتر، به فعال کردن پیمایش برای Android Auto مراجعه کنید |
رانندگانی که از برنامه شما استفاده میکنند، برای بیشتر سفر خود نقشهای کلی میخواهند، تنها با حداقل راهنمایی گام به گام برای خیابانهای شهر. | برنامه شما باید به رانندگان اجازه دهد تا بدون تغییر تنظیمات ناوبر برای حالت مقصد و سفر، در صورت نیاز به تجربه ناوبری Google وارد و خارج شوند. |
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eThe Navigation SDK offers both a pre-built Google navigation experience and the flexibility to create custom navigation experiences.\u003c/p\u003e\n"],["\u003cp\u003eCustom navigation experiences allow developers to manage UI elements, visuals, and event handling for a highly tailored user interface.\u003c/p\u003e\n"],["\u003cp\u003eThis customization ranges from background navigation to projecting guidance onto separate screens, giving developers more control.\u003c/p\u003e\n"],["\u003cp\u003eCustom experiences involve starting navigation, managing active navigation with event handlers, and ending navigation as needed.\u003c/p\u003e\n"],["\u003cp\u003eUse cases for custom navigation include text-only guidance, Android Auto integration, and dynamic switching between map views and turn-by-turn instructions.\u003c/p\u003e\n"]]],[],null,["# Custom navigation experience\n\nThe Navigation SDK provides different ways to integrate a navigation\nexperience into your app. This page explains what a custom navigation experience\nis and how it differs from other navigation experiences that are available in\nthe Navigation SDK.\n\nWhat is a custom navigation experience?\n---------------------------------------\n\nThe primary way to implement the Navigation SDK is to use the [Google\nnavigation\nexperience](/maps/documentation/navigation/android-sdk/intro-google-nav),\nwhich lets you embed a turn-by-turn navigation experience that uses\nGoogle-provided UI elements and visuals --- similar to the navigation experience\nwithin the Google Maps apps. If you need more flexibility than the Google\nnavigation experience offers, you can implement a custom navigation experience.\nA custom navigation experience refers to anything from eliminating turn guidance\nentirely with and running navigation only as a background process, to projecting\na highly customized guidance experience to a screen separate from the device\nthat runs the navigation. With a custom navigation experience, your app calls\nthe Navigation SDK to request a turn-by-turn navigation feed, and then\nyou provide and manage the UI elements and visuals that the user sees in the\nnavigation experience. While using the Google navigation experience is generally\neasier to implement, building your own custom navigation experience allows for\nmore customization.\n\nWhen you create a custom navigation experience, your app calls the Navigation\nSDK to start, run, and stop navigation, using the following flow:\n\n1. **Start navigation** . As with the Google navigation experience, a custom\n navigation experience still involves creating a navigation instance and\n setting the destination. However, with a customized navigation experience,\n you achieve this by first establishing a navigation session using\n `GMSNavigationService.createNavigationSession`, which is a state-bearing\n non-UI object that can operate either with a view controller, or without\n one.\n\n For more information, see [Enable turn-by-turn data\n feed](/maps/documentation/navigation/android-sdk/tbt-feed).\n\n **See the demo:** The download of the Navigation SDK contains a demo\n you can run to see an example of a navigation experience that switches\n between turn-by-turn guidance through standard navigation to a navigation\n experience that shows only the device location moving along a road\n polyline.\n2. **Active navigation** . Here is another key difference between a\n Google-provided navigation experience and a custom navigation experience.\n Instead of handing off guidance to the built-in event manager of the\n Navigation SDK, you enable the turn-by-turn feed and implement event\n handlers. This allows your experience to respond to the events described in\n [Listen for navigation\n events](/maps/documentation/navigation/android-sdk/events).\n\n3. **End navigation**. As with the Google navigation experience, custom\n navigation also requires you to terminate navigation in the manner best\n suited for the app's experience.\n\nWhen might you use a custom navigation experience?\n--------------------------------------------------\n\nThe following table describes some custom navigation scenarios.\n\n| **Example scenario** | **High-level steps** |\n|----------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| You need to provide text-only driver guidance for small devices such as 2-wheeled vehicles. | Create your navigator and set up the turn-by-turn guidance as a data feed to a small screen device while the navigator runs on the driver's mobile phone outside of their immediate view. |\n| You want to make your app available as a car service for drivers who use Android Auto. | 1. Set up the car service. 2. Set up your Navigation SDK project. 3. Establish a navigator if you haven't already. 4. Enable the turn-by-turn guidance feed. 5. Draw the map on the auto app surface and populate the fields from the data feed you configured. For more information, see [Enable Navigation for Android Auto](/maps/documentation/navigation/android-sdk/android-auto) |\n| Drivers using your app want an overview map for most of their journey, with only minimal turn-by-turn guidance for city streets. | Your app should allow drivers to enter and exit the Google navigation experience as they need, without alternating the navigator's settings for destination and trip mode. |"]]