ज़रूरत के मुताबिक दिशा-निर्देश बनाना
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
इस पेज पर, कस्टम नेविगेशन की सुविधा के तहत, पसंद के मुताबिक गाइडेंस बनाने के लिए, आपको जिन चरणों का पालन करना होता है उनके बारे में बताया गया है.
यह प्रोसेस, रास्ते पर
नेविगेट करना लेख में बताई गई प्रोसेस से इस तरह अलग है:
- सबसे पहले, नेविगेशन सेशन को अलग से सेट अप करें. इसके बाद, व्यू कंट्रोलर को कॉल करने के बजाय, सेशन के ज़रिए नेविगेटर इंस्टेंस पाएं.
- नेविगेशन इवेंट का जवाब देने और उन्हें मैनेज करने के लिए, इवेंट लिसनर सेट अप करें.
GMSNavigationService.createNavigationSession
का इस्तेमाल करके, नेविगेशन सेशन बनाएं. इसके बाद, setDestination
कॉल करके नेविगेशन शुरू करें. Google नेविगेशन की सुविधा, नेविगेशन मैप व्यू के ज़रिए नेविगेटर को चालू करती है. इसमें GMSNavigationServices
, यूज़र इंटरफ़ेस (यूआई) इंस्टेंस से अलग नेविगेशन सेशन से इवेंट की स्ट्रीम को कंट्रोल करता है और उसे स्ट्रीम मिलती है. इसका मतलब है कि यह बिना यूज़र इंटरफ़ेस (यूआई) के भी चल सकता है या इसे यूज़र इंटरफ़ेस (यूआई) पर आधारित किसी भी अनुभव के लिए पास किया जा सकता है. इस तरीके से, नेविगेशन सेशन आपके ऐप्लिकेशन में तब तक चलता रहता है, जब तक कि उससे आखिरी रेफ़रंस नहीं हटा दिया जाता.
- सड़क के हिसाब से सटीक जगह की जानकारी देने वाली सेवा सेट अप करना. अगर आपको अपने ऐप्लिकेशन में लगातार जगह की जानकारी ट्रैक करनी है, तो लोकेशन प्रोवाइडर का इस्तेमाल करें. जैसे, रास्ते के साथ नीले रंग का बिंदु दिखाते हुए नेविगेशन व्यू दिखाने के दौरान.
GMSNavigatorListener
प्रोटोकॉल लागू करके, बारी-बारी से दिशा-निर्देश देने के लिए लिसनर सेट अप करें. इसके बाद, उस जानकारी को अपनी पसंद के मुताबिक नेविगेशन के लिए ज़रूरी जानकारी में बदलें. उदाहरण के लिए:
- दिशा-निर्देशों को आसानी से स्क्रीन पर कास्ट करने के लिए, सिर्फ़ टेक्स्ट वाले फ़ील्ड लागू करें.
- अपने यूज़र इंटरफ़ेस (यूआई) के लिए फ़ील्ड डिज़ाइन करें और उनमें डेटा भरें.
- नेविगेशन सिम्युलेटर सेट अप करें. यह कुकी, डेवलपमेंट और टेस्टिंग के लिए ज़रूरी है.
इंडिपेंडेंट नेविगेशन सेशन बनाना
डेमो का यह कोड स्निपेट, व्यू कंट्रोलर से अलग नेविगेशन दिखाता है. इसके बाद, कोड एक खास जानकारी वाला मैप जोड़ता है. इसे सड़क के हिसाब से तय की गई मौजूदा जगह की जानकारी दिखाने के लिए कॉन्फ़िगर किया जाता है.
// Create the navigation session.
_navigationSession = [GMSNavigationServices createNavigationSession];
GMSRoadSnappedLocationProvider *roadSnappedLocationProvider =
_navigationSession.roadSnappedLocationProvider;
[roadSnappedLocationProvider startUpdatingLocation];
GMSNavigator *navigator = _navigationSession.navigator;
[navigator addListener:self];
navigator.voiceGuidance = GMSNavigationVoiceGuidanceSilent;
navigator.sendsBackgroundNotifications = NO;
_navigationSession.started = YES;
[navigator setDestinations:@[ destination ]
callback:^(GMSRouteStatus routeStatus) {
// …handle changes in route status.
}];
// Add an overview map.
_mapView = [[GMSMapView alloc] initWithFrame:CGRectZero];
[self.mainStackView addArrangedSubview:_mapView];
[self.mainStackView setNeedsLayout];
_mapView.settings.compassButton = YES;
_mapView.delegate = self;
_mapView.myLocationEnabled = YES;
_mapView.roadSnappedMyLocationSource = roadSnappedLocationProvider;
कस्टम अनुभव से Google के अनुभव पर नेविगेशन पास करना
इस कोड स्निपेट में बताया गया है कि आपका ऐप्लिकेशन, उपयोगकर्ता को कस्टम नेविगेशन से Google नेविगेशन पर जाने की अनुमति कैसे दे सकता है. इस कोड स्निपेट में यह भी दिखाया गया है कि मैप शेयर करते समय, आपका ऐप्लिकेशन इस ट्रांज़िशन को कैसे करता है.
`UIButton *button = [UIButton buttonWithType:UIButtonTypePlain`];
[`button addTarget:self action:@selector(didTapEnterGoogleNavigationButton:)
forControlState:[_directionsButton addTarget:self`];
`…`
[`_mapView enableNavigationWithSession:_navigationSession`];
जब तक कुछ अलग से न बताया जाए, तब तक इस पेज की सामग्री को Creative Commons Attribution 4.0 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2025-09-04 (UTC) को अपडेट किया गया.
[null,null,["आखिरी बार 2025-09-04 (UTC) को अपडेट किया गया."],[[["\u003cp\u003eCreate custom turn-by-turn navigation experiences on iOS by establishing an independent navigation session using \u003ccode\u003eGMSNavigationServices\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eImplement the \u003ccode\u003eGMSNavigatorListener\u003c/code\u003e protocol to receive and utilize detailed guidance information for your custom UI elements.\u003c/p\u003e\n"],["\u003cp\u003eUtilize a road-snapped location provider for continuous location updates and accurate positioning on the route.\u003c/p\u003e\n"],["\u003cp\u003eSet up a navigation simulator for development and testing purposes to ensure the functionality of your custom navigation experience.\u003c/p\u003e\n"],["\u003cp\u003eTransition seamlessly from a custom navigation experience to the full Google Maps navigation experience, optionally sharing the existing map instance.\u003c/p\u003e\n"]]],["The core process involves creating a navigation session independently using `GMSNavigationService.createNavigationSession`, distinct from route navigation. A road-snapped location provider is established for continuous monitoring. Implement `GMSNavigatorListener` to set up turn-by-turn guidance, translating the information into your app's custom navigation UI. Set up a navigation simulator for testing. The navigation session persists until the last reference is removed. A custom experience can also be transition to the default google navigation experience.\n"],null,["# Create customized guidance\n\nThis page covers the high-level steps you follow to create customized guidance\nas part of a [custom navigation\nexperience](/maps/documentation/navigation/ios-sdk/intro-custom-nav). \n**This process differs from the process described in\n[Navigate a\nroute](/maps/documentation/navigation/ios-sdk/route) as follows:**\n\n- You first establish a navigation session independently and obtain a navigator instance through the session rather than by calling the view controller.\n- You set up an event listener to respond to and manage navigation events.\n\n1. **Create a navigation session** using [`GMSNavigationService.createNavigationSession`](/maps/documentation/navigation/ios-sdk/reference/objc/Classes/GMSNavigationServices#+createnavigationsession) and begin navigation with a `setDestination` call. Where the Google navigation experience invokes the navigator through the navigation map view, the `GMSNavigationServices` controls and receives a stream of events from a navigation session *independently* from a UI instance. This means it can either run without a UI, or get passed to *any* UI-based experience. With this approach, the navigation session continues to run in your app until the last reference is removed from it.\n2. **Establish a road-snapped location provider**. Use the location provider if you want your app to have continuous location monitoring, such as when displaying a navigation view with a blue dot along the route.\n3. **Set up a listener for detailed turn-by-turn guidance** by implementing the `GMSNavigatorListener` protocol. Then, transform that information into whatever is needed for your custom navigation experience. For example:\n 1. Implement text-only fields for simple screen casting of directions.\n 2. Design and populate fields for your own UI.\n4. **Set up a navigation simulator**. This is necessary for development and testing.\n\nCreate an independent navigation session\n----------------------------------------\n\nThe following code snippet from the demo shows navigation established\nindependently from the view controller. The code then adds an overview map\nconfigured to show the current road-snapped location. \n\n // Create the navigation session.\n\n _navigationSession = [GMSNavigationServices createNavigationSession];\n GMSRoadSnappedLocationProvider *roadSnappedLocationProvider =\n _navigationSession.roadSnappedLocationProvider;\n [roadSnappedLocationProvider startUpdatingLocation];\n GMSNavigator *navigator = _navigationSession.navigator;\n [navigator addListener:self];\n navigator.voiceGuidance = GMSNavigationVoiceGuidanceSilent;\n navigator.sendsBackgroundNotifications = NO;\n _navigationSession.started = YES;\n [navigator setDestinations:@[ destination ]\n callback:^(GMSRouteStatus routeStatus) {\n // ...handle changes in route status.\n }];\n\n // Add an overview map.\n _mapView = [[GMSMapView alloc] initWithFrame:CGRectZero];\n [self.mainStackView addArrangedSubview:_mapView];\n [self.mainStackView setNeedsLayout];\n _mapView.settings.compassButton = YES;\n _mapView.delegate = self;\n _mapView.myLocationEnabled = YES;\n _mapView.roadSnappedMyLocationSource = roadSnappedLocationProvider;\n\nPassing navigation from a custom experience to the Google experience\n--------------------------------------------------------------------\n\nThis code snippet illustrates how your app can allow the user to enter the\nGoogle navigation experience from a custom navigation experience. This code\nsnippet also shows how your app makes this transition while sharing the map. \n\n `UIButton *button = [UIButton buttonWithType:UIButtonTypePlain`];\n\n [`button addTarget:self action:@selector(didTapEnterGoogleNavigationButton:)\n forControlState:[_directionsButton addTarget:self`];\n\n `...`\n\n [`_mapView enableNavigationWithSession:_navigationSession`];"]]