इस कुकी की मदद से, जगहों के बीच रास्ते की जानकारी वापस पाई जा सकती है.
नीचे दिए गए उदाहरण में बताया गया है कि इस क्लास का इस्तेमाल करके, टाइम्स स्क्वेयर से सेंट्रल पार्क तक के निर्देश कैसे पाए जा सकते हैं. इसमें सबसे पहले लिंकन सेंटर पर रुकना, मैप पर जगहों और रास्ते को प्लॉट करना, और ईमेल में मैप भेजना शामिल है.
// Get the directions. const directions = Maps.newDirectionFinder() .setOrigin('Times Square, New York, NY') .addWaypoint('Lincoln Center, New York, NY') .setDestination('Central Park, New York, NY') .setMode(Maps.DirectionFinder.Mode.DRIVING) .getDirections(); const route = directions.routes[0]; // Set up marker styles. let markerLetterCode = 'A'.charCodeAt(); // Add markers to the map. const map = Maps.newStaticMap(); for (let i = 0; i < route.legs.length; i++) { const leg = route.legs[i]; if (i === 0) { // Add a marker for the start location of the first leg only. map.setMarkerStyle( Maps.StaticMap.MarkerSize.MID, Maps.StaticMap.Color.GREEN, String.fromCharCode(markerLetterCode), ); map.addMarker(leg.start_location.lat, leg.start_location.lng); markerLetterCode++; } map.setMarkerStyle( Maps.StaticMap.MarkerSize.MID, Maps.StaticMap.Color.GREEN, String.fromCharCode(markerLetterCode), ); map.addMarker(leg.end_location.lat, leg.end_location.lng); markerLetterCode++; } // Add a path for the entire route. map.addPath(route.overview_polyline.points); // Send the map in an email. const toAddress = Session.getActiveUser().getEmail(); MailApp.sendEmail( toAddress, 'Directions', `Please open: ${map.getMapUrl()}&key=YOUR_API_KEY`, { htmlBody: 'See below.<br/><img src="cid:mapImage">', inlineImages: { mapImage: Utilities.newBlob(map.getMapImage(), 'image/png'), }, }, );
इन्हें भी देखें
तरीके
| तरीका | रिटर्न टाइप | संक्षिप्त विवरण |
|---|---|---|
add | Direction | यह एक ऐसा वेपॉइंट जोड़ता है जिससे होकर रास्ता गुज़रना चाहिए. इसके लिए, पॉइंट (अक्षांश/देशांतर) का इस्तेमाल किया जाता है. |
add | Direction | यह किसी पते का इस्तेमाल करके, एक ऐसा वेपॉइंट जोड़ता है जिससे होकर रास्ता गुज़रना चाहिए. |
clear | Direction | इससे वेपॉइंट का मौजूदा सेट मिट जाता है. |
get | Object | यह कुकी, सेट किए गए शुरुआती पते, मंज़िल, और अन्य विकल्पों का इस्तेमाल करके दिशा-निर्देशों को लोड करती है. |
set | Direction | इस विकल्प से यह तय किया जाता है कि सबसे ज़्यादा रैंक वाले रूट के बजाय, वैकल्पिक रूट दिखाए जाने चाहिए या नहीं. डिफ़ॉल्ट रूप से, यह विकल्प false पर सेट होता है. |
set | Direction | यह कुकी, पहुंचने का समय सेट करती है. हालांकि, यह सुविधा कुछ ही मामलों में उपलब्ध है. |
set | Direction | इससे यह तय किया जाता है कि कुछ तरह की पाबंदियों से बचना है या नहीं. |
set | Direction | यह कुकी, यात्रा शुरू करने का समय सेट करती है. यह तब लागू होता है, जब इसकी ज़रूरत होती है. |
set | Direction | यह उस जगह की जानकारी सेट करता है जहां के लिए दिशा-निर्देशों का हिसाब लगाना है. इसके लिए, पॉइंट (अक्षांश/देशांतर) का इस्तेमाल किया जाता है. |
set | Direction | यह कुकी, पते का इस्तेमाल करके उस जगह की जानकारी सेट करती है जहां के लिए रास्ते का हिसाब लगाना है. |
set | Direction | इससे दिशाओं के लिए इस्तेमाल की जाने वाली भाषा सेट की जाती है. |
set | Direction | इससे यात्रा का मोड सेट किया जाता है. डिफ़ॉल्ट रूप से, इसे ड्राइविंग पर सेट किया जाता है. |
set | Direction | इस विकल्प से यह तय किया जाता है कि दिए गए रास्ते को ऑप्टिमाइज़ करना है या नहीं. इसके लिए, वेपॉइंट को ज़्यादा असरदार क्रम में फिर से व्यवस्थित किया जाता है. डिफ़ॉल्ट रूप से, यह विकल्प false पर सेट होता है. |
set | Direction | यह विकल्प, दिशा-निर्देशों का हिसाब लगाने के लिए शुरुआती जगह सेट करता है. इसके लिए, पॉइंट (अक्षांश/देशांतर) का इस्तेमाल किया जाता है. |
set | Direction | यह कुकी, पते का इस्तेमाल करके, दिशाओं का हिसाब लगाने के लिए शुरुआती जगह सेट करती है. |
set | Direction | जगह के नामों को समझने के लिए, किसी क्षेत्र को सेट करता है. |
ज़्यादा जानकारी वाला दस्तावेज़
add Waypoint(latitude, longitude)
यह एक ऐसा वेपॉइंट जोड़ता है जिससे होकर रास्ता गुज़रना चाहिए. इसके लिए, पॉइंट (अक्षांश/देशांतर) का इस्तेमाल किया जाता है.
// Creates a DirectionFinder with a wapoint at Lincoln Center. const directionFinder = Maps.newDirectionFinder().addWaypoint( 40.772628, -73.984243, );
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
latitude | Number | वेपॉइंट का अक्षांश. |
longitude | Number | वेपॉइंट का देशांतर. |
वापसी का टिकट
Direction — DirectionFinder ऑब्जेक्ट, ताकि कॉल को एक साथ जोड़ा जा सके.
add Waypoint(address)
यह किसी पते का इस्तेमाल करके, एक ऐसा वेपॉइंट जोड़ता है जिससे होकर रास्ता गुज़रना चाहिए.
// Creates a DirectionFinder with a wapoint at Lincoln Center. const directionFinder = Maps.newDirectionFinder().addWaypoint( 'Lincoln Center, New York, NY', );
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
address | String | पता. |
वापसी का टिकट
Direction — DirectionFinder ऑब्जेक्ट, ताकि कॉल को एक साथ जोड़ा जा सके.
clear Waypoints()
इससे वेपॉइंट का मौजूदा सेट मिट जाता है.
const directionFinder = Maps.newDirectionFinder(); // ... // Do something interesting here ... // ... // Remove all waypoints added with addWaypoint(). directionFinder.clearWaypoints();
वापसी का टिकट
Direction — DirectionFinder ऑब्जेक्ट, ताकि कॉल को एक साथ जोड़ा जा सके.
get Directions()
यह कुकी, सेट किए गए शुरुआती पते, मंज़िल, और अन्य विकल्पों का इस्तेमाल करके दिशा-निर्देशों को लोड करती है.
// Logs how long it takes to walk from Times Square to Central Park. const directions = Maps.newDirectionFinder() .setOrigin('Times Square, New York, NY') .setDestination('Central Park, New York, NY') .setMode(Maps.DirectionFinder.Mode.WALKING) .getDirections(); Logger.log(directions.routes[0].legs[0].duration.text);
वापसी का टिकट
Object — यह एक JSON ऑब्जेक्ट है. इसमें दिशा-निर्देशों के लिए रास्तों का सेट होता है. इसके बारे में यहां बताया गया है.
इन्हें भी देखें
set Alternatives(useAlternatives)
इस विकल्प से यह तय किया जाता है कि सबसे ज़्यादा रैंक वाले रास्ते (डिफ़ॉल्ट रूप से false) के बजाय, वैकल्पिक रास्ते दिखाए जाने चाहिए या नहीं. अगर true है, तो नतीजे के तौर पर मिले ऑब्जेक्ट के routes कलेक्शन में एक से ज़्यादा एंट्री हो सकती हैं.
// Creates a DirectionFinder with alternative routes enabled. const directionFinder = Maps.newDirectionFinder().setAlternatives(true);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
use | Boolean | वैकल्पिक रास्ते देखने के लिए true पर टैप करें. false पर टैप करने से, आपको वैकल्पिक रास्ते नहीं दिखेंगे. |
वापसी का टिकट
Direction — DirectionFinder ऑब्जेक्ट, ताकि कॉल को एक साथ जोड़ा जा सके.
set Arrive(time)
यह कुकी, पहुंचने का समय सेट करती है. हालांकि, यह सुविधा कुछ ही मामलों में उपलब्ध है.
// Creates a DirectionFinder with an arrival time of 2 hours from now. const now = new Date(); const arrive = new Date(now.getTime() + 2 * 60 * 60 * 1000); const directionFinder = Maps.newDirectionFinder().setArrive(arrive);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
time | Date | बस के पहुंचने का समय. |
वापसी का टिकट
Direction — DirectionFinder ऑब्जेक्ट, ताकि कॉल को एक साथ जोड़ा जा सके.
इन्हें भी देखें
set Avoid(avoid)
इससे यह तय किया जाता है कि कुछ तरह की पाबंदियों से बचना है या नहीं.
// Creates a DirectionFinder that avoid highways. const directionFinder = Maps.newDirectionFinder().setAvoid( Maps.DirectionFinder.Avoid.HIGHWAYS, );
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
avoid | String | Avoid एट्रिब्यूट की कॉन्स्टेंट वैल्यू. |
वापसी का टिकट
Direction — DirectionFinder ऑब्जेक्ट, ताकि कॉल को एक साथ जोड़ा जा सके.
इन्हें भी देखें
set Depart(time)
यह कुकी, यात्रा शुरू करने का समय सेट करती है. यह तब लागू होता है, जब इसकी ज़रूरत होती है.
// Creates a DirectionFinder with a departure time of 1 hour from now. const now = new Date(); const depart = new Date(now.getTime() + 1 * 60 * 60 * 1000); const directionFinder = Maps.newDirectionFinder().setDepart(depart);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
time | Date | रवाना होने का समय. |
वापसी का टिकट
Direction — DirectionFinder ऑब्जेक्ट, ताकि कॉल को एक साथ जोड़ा जा सके.
इन्हें भी देखें
set Destination(latitude, longitude)
यह उस जगह की जानकारी सेट करता है जहां के लिए दिशा-निर्देशों का हिसाब लगाना है. इसके लिए, पॉइंट (अक्षांश/देशांतर) का इस्तेमाल किया जाता है.
// Creates a DirectionFinder with the destination set to Central Park. const directionFinder = Maps.newDirectionFinder().setDestination( 40.777052, -73.975464, );
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
latitude | Number | यात्रा खत्म होने की जगह का अक्षांश. |
longitude | Number | यात्रा खत्म होने की जगह का देशांतर. |
वापसी का टिकट
Direction — DirectionFinder ऑब्जेक्ट, ताकि कॉल को एक साथ जोड़ा जा सके.
set Destination(address)
यह कुकी, पते का इस्तेमाल करके उस जगह की जानकारी सेट करती है जहां के लिए रास्ते का हिसाब लगाना है.
// Creates a DirectionFinder with the destination set to Central Park. const directionFinder = Maps.newDirectionFinder().setDestination( 'Central Park, New York, NY', );
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
address | String | गंतव्य का पता. |
वापसी का टिकट
Direction — DirectionFinder ऑब्जेक्ट, ताकि कॉल को एक साथ जोड़ा जा सके.
set Language(language)
इससे दिशाओं के लिए इस्तेमाल की जाने वाली भाषा सेट की जाती है.
// Creates a DirectionFinder with the language set to French. const directionFinder = Maps.newDirectionFinder().setLanguage('fr');
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
language | String | BCP-47 भाषा आइडेंटिफ़ायर. |
वापसी का टिकट
Direction — DirectionFinder ऑब्जेक्ट, ताकि कॉल को एक साथ जोड़ा जा सके.
इन्हें भी देखें
set Mode(mode)
इससे यात्रा का मोड सेट किया जाता है. डिफ़ॉल्ट रूप से, इसे ड्राइविंग पर सेट किया जाता है.
// Creates a DirectionFinder with the mode set to walking. const directionFinder = Maps.newDirectionFinder().setMode( Maps.DirectionFinder.Mode.WALKING, );
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
mode | String | Mode एट्रिब्यूट की कॉन्स्टेंट वैल्यू. |
वापसी का टिकट
Direction — DirectionFinder ऑब्जेक्ट, ताकि कॉल को एक साथ जोड़ा जा सके.
इन्हें भी देखें
set Optimize Waypoints(optimizeOrder)
इस विकल्प से यह तय किया जाता है कि दिए गए रास्ते को ऑप्टिमाइज़ करना है या नहीं. इसके लिए, वेपॉइंट को ज़्यादा असरदार क्रम में फिर से व्यवस्थित किया जाता है. डिफ़ॉल्ट रूप से, यह विकल्प false पर सेट होता है.
// Creates a DirectionFinder with wapoint optimization enabled. const directionFinder = Maps.newDirectionFinder().setOptimizeWaypoints(true);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
optimize | Boolean | true ऑर्डर को ऑप्टिमाइज़ करने के लिए या false किसी अन्य वजह से. |
वापसी का टिकट
Direction — DirectionFinder ऑब्जेक्ट, ताकि कॉल को एक साथ जोड़ा जा सके.
इन्हें भी देखें
set Origin(latitude, longitude)
यह विकल्प, दिशा-निर्देशों का हिसाब लगाने के लिए शुरुआती जगह सेट करता है. इसके लिए, पॉइंट (अक्षांश/देशांतर) का इस्तेमाल किया जाता है.
// Creates a DirectionFinder with the origin set to Times Square. const directionFinder = Maps.newDirectionFinder().setOrigin( 40.759011, -73.984472, );
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
latitude | Number | यात्रा शुरू करने की जगह का अक्षांश. |
longitude | Number | यात्रा शुरू करने की जगह का देशांतर. |
वापसी का टिकट
Direction — DirectionFinder ऑब्जेक्ट, ताकि कॉल को एक साथ जोड़ा जा सके.
set Origin(address)
यह कुकी, पते का इस्तेमाल करके, दिशाओं का हिसाब लगाने के लिए शुरुआती जगह सेट करती है.
// Creates a DirectionFinder with the origin set to Times Square. const directionFinder = Maps.newDirectionFinder().setOrigin( 'Times Square, New York, NY', );
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
address | String | शुरुआती पता. |
वापसी का टिकट
Direction — यह DirectionFinder इंस्टेंस है, ताकि कॉल को एक-दूसरे से जोड़ा जा सके.
set Region(region)
जगह के नामों को समझने के लिए, किसी क्षेत्र को सेट करता है. जिन देशों/इलाकों के कोड इस्तेमाल किए जा सकते हैं वे Google Maps के साथ काम करने वाले सीसीटीएलडी से मेल खाते हैं. उदाहरण के लिए, क्षेत्र कोड "uk" का मतलब "maps.google.co.uk" है.
// Creates a DirectionFinder with the region set to France. const directionFinder = Maps.newDirectionFinder().setRegion('fr');
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
region | String | इस्तेमाल करने के लिए क्षेत्र का कोड. |
वापसी का टिकट
Direction — DirectionFinder ऑब्जेक्ट, ताकि कॉल को एक साथ जोड़ा जा सके.