ประสบการณ์การนำทางที่กำหนดเอง
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
Navigation SDK มีวิธีต่างๆ ในการผสานรวมประสบการณ์การนำทางเข้ากับแอป หน้านี้จะอธิบายว่าประสบการณ์การนำทางที่กำหนดเองคืออะไร และแตกต่างจากประสบการณ์การนำทางอื่นๆ ที่มีใน Navigation SDK อย่างไร
ประสบการณ์การนำทางที่กำหนดเองคืออะไร
วิธีหลักในการติดตั้งใช้งาน Navigation SDK คือการใช้ประสบการณ์
การนำทางของ Google
ซึ่งช่วยให้คุณฝังประสบการณ์การนำทางแบบเลี้ยวต่อเลี้ยวที่ใช้
องค์ประกอบ UI และภาพที่ Google จัดหาให้ ซึ่งคล้ายกับประสบการณ์การนำทาง
ภายในแอป Google Maps หากต้องการความยืดหยุ่นมากกว่าที่ประสบการณ์การนำทางของ Google มอบให้ คุณสามารถใช้ประสบการณ์การนำทางที่กำหนดเองได้
ประสบการณ์การนำทางที่กำหนดเองหมายถึงทุกอย่างตั้งแต่การยกเลิกคำแนะนำการเลี้ยว
ทั้งหมดและการเรียกใช้การนำทางเป็นกระบวนการเบื้องหลังเท่านั้น ไปจนถึงการฉาย
ประสบการณ์การนำทางที่ปรับแต่งอย่างละเอียดไปยังหน้าจอที่แยกจากอุปกรณ์
ที่เรียกใช้การนำทาง เมื่อใช้ประสบการณ์การนำทางที่กำหนดเอง แอปจะเรียกใช้ Navigation SDK เพื่อขอฟีดการนำทางแบบเลี้ยวต่อเลี้ยว จากนั้นคุณจะจัดหาและจัดการองค์ประกอบ UI และภาพที่ผู้ใช้เห็นในประสบการณ์การนำทาง แม้ว่าการใช้ประสบการณ์การนำทางของ Google จะ
ติดตั้งใช้งานได้ง่ายกว่า แต่การสร้างประสบการณ์การนำทางที่กำหนดเองจะช่วยให้
ปรับแต่งได้มากขึ้น
เมื่อสร้างประสบการณ์การนำทางที่กำหนดเอง แอปจะเรียกใช้ Navigation
SDK เพื่อเริ่ม เรียกใช้ และหยุดการนำทางโดยใช้ขั้นตอนต่อไปนี้
เริ่มการนำทาง เช่นเดียวกับประสบการณ์การนำทางของ Google ประสบการณ์การนำทางที่กำหนดเองยังคงเกี่ยวข้องกับการสร้างอินสแตนซ์การนำทางและการตั้งค่าปลายทาง อย่างไรก็ตาม ด้วยประสบการณ์การนำทางที่ปรับแต่งแล้ว
คุณจะทำได้โดยการสร้างเซสชันการนำทางก่อนโดยใช้
GMSNavigationService.createNavigationSession
ซึ่งเป็นออบเจ็กต์ที่ไม่ใช่ UI ที่มีสถานะ
ซึ่งสามารถทำงานร่วมกับตัวควบคุมมุมมองหรือไม่มีตัวควบคุมมุมมองก็ได้
ดูข้อมูลเพิ่มเติมได้ที่รายละเอียดเกี่ยวกับฟีดข้อมูลแบบเลี้ยวต่อเลี้ยว
ดูการสาธิต: การดาวน์โหลด Navigation SDK มีการสาธิต
ที่คุณเรียกใช้เพื่อดูตัวอย่างประสบการณ์การนำทางที่สลับ
ระหว่างคำแนะนำแบบเลี้ยวต่อเลี้ยวผ่านการนำทางมาตรฐานกับประสบการณ์การนำทาง
ที่แสดงเฉพาะตำแหน่งอุปกรณ์ที่เคลื่อนที่ไปตามโพลีไลน์ของถนน
การนำทางที่ใช้งานอยู่ ความแตกต่างที่สำคัญอีกอย่างระหว่างประสบการณ์การนำทางที่ Google จัดหาให้กับประสบการณ์การนำทางที่กำหนดเองมีดังนี้
แทนที่จะส่งต่อคำแนะนำไปยังเครื่องมือจัดการเหตุการณ์ในตัวของ Navigation SDK คุณจะต้องตั้งค่า Listener สำหรับคำแนะนำแบบเลี้ยวต่อเลี้ยวโดยละเอียดด้วยการใช้โปรโตคอล GMSNavigatorListener
จากนั้นจึงใช้ตัวแฮนเดิลเหตุการณ์
ซึ่งจะช่วยให้ประสบการณ์การใช้งานตอบสนองต่อเหตุการณ์ที่อธิบายไว้ใน
ฟังเหตุการณ์
การนำทางได้
สิ้นสุดการนำทาง เช่นเดียวกับประสบการณ์การนำทางของ Google การนำทางที่กำหนดเอง
ยังกำหนดให้คุณสิ้นสุดการนำทางในลักษณะที่เหมาะสมที่สุด
สำหรับประสบการณ์การใช้งานของแอปด้วย
คุณสามารถใช้ประสบการณ์การนำทางที่กำหนดเองเมื่อใด
ตารางต่อไปนี้อธิบายสถานการณ์การนำทางที่กำหนดเองบางอย่าง
สถานการณ์ตัวอย่าง |
ขั้นตอนระดับสูง |
คุณต้องระบุคำแนะนำสำหรับผู้ขับขี่ที่เป็นข้อความเท่านั้นสำหรับอุปกรณ์ขนาดเล็ก เช่น
ยานพาหนะ 2 ล้อ |
สร้างเนวิเกเตอร์และตั้งค่าคำแนะนำแบบเลี้ยวต่อเลี้ยวเป็นฟีดข้อมูลไปยังอุปกรณ์หน้าจอขนาดเล็กขณะที่เนวิเกเตอร์ทำงานบนโทรศัพท์มือถือของผู้ขับขี่นอกมุมมองโดยตรง |
คุณต้องการทำให้แอปพร้อมให้บริการเป็นบริการรถยนต์สำหรับคนขับที่
ใช้ Apple CarPlay |
- ตั้งค่าบริการรถยนต์
- ตั้งค่าโปรเจ็กต์ Navigation SDK
- สร้างเนวิเกเตอร์หากยังไม่ได้ดำเนินการ
- ตั้งค่า Listener สำหรับคำแนะนำแบบเลี้ยวต่อเลี้ยว
- วาดแผนที่บนพื้นผิวแอปอัตโนมัติและป้อนข้อมูลในช่องจากฟีดข้อมูลที่คุณกำหนดค่าไว้
ดูข้อมูลเพิ่มเติมได้ที่เปิดใช้การนำทางสำหรับ Carplay |
คนขับที่ใช้แอปของคุณต้องการแผนที่ภาพรวมสำหรับการเดินทางส่วนใหญ่
โดยมีคำแนะนำแบบเลี้ยวต่อเลี้ยวเพียงเล็กน้อยสำหรับถนนในเมือง |
แอปของคุณควรอนุญาตให้คนขับเข้าและออกจากประสบการณ์การนำทางของ Google
ได้ตามต้องการ โดยไม่ต้องสลับการตั้งค่าของโปรแกรมนำทางสำหรับ
จุดหมายและโหมดการเดินทาง |
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-31 UTC
[null,null,["อัปเดตล่าสุด 2025-08-31 UTC"],[[["\u003cp\u003eThe Navigation SDK offers a custom navigation experience for greater flexibility beyond the standard Google navigation experience.\u003c/p\u003e\n"],["\u003cp\u003eCustom navigation involves managing UI elements and visuals, starting navigation sessions, listening for events, and ending navigation.\u003c/p\u003e\n"],["\u003cp\u003eCustom experiences are suitable for scenarios like text-only guidance, Carplay integration, or combining overview maps with minimal turn-by-turn guidance.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can access the turn-by-turn data feed and detailed navigation events to create highly customized navigation interfaces.\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/ios-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 \u003cbr /\u003e\n\n For more information, see [Details about the turn-by-turn data\n feed](/maps/documentation/navigation/ios-sdk/nav-only-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 set up a listener for detailed turn-by-turn guidance by implementing the `GMSNavigatorListener` protocol, and then implement event\n handlers. This allows your experience to respond to the events described in\n [Listen for navigation\n events](/maps/documentation/navigation/ios-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 Apple Carplay. | 1. Set up the car service. 2. Set up your Navigation SDK project. 3. Establish a navigator if you haven't already. 4. Set up a listener for turn-by-turn guidance. 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 Carplay](/maps/documentation/navigation/ios-sdk/carplay) |\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. |"]]