Class DirectionFinder

रास्ताढूंढने वाला टूल

इस कुकी की मदद से, जगहों के बीच रास्ते की जानकारी वापस पाई जा सकती है.
नीचे दिए गए उदाहरण में बताया गया है कि इस क्लास का इस्तेमाल करके, टाइम्स स्क्वेयर से सेंट्रल पार्क तक के निर्देश कैसे पाए जा सकते हैं. इसमें सबसे पहले लिंकन सेंटर पर रुकना, मैप पर जगहों और रास्ते को प्लॉट करना, और ईमेल में मैप भेजना शामिल है.

// 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'),
      },
    },
);

इन्हें भी देखें

तरीके

तरीकारिटर्न टाइपसंक्षिप्त विवरण
addWaypoint(latitude, longitude)DirectionFinderयह एक ऐसा वेपॉइंट जोड़ता है जिससे होकर रास्ता गुज़रना चाहिए. इसके लिए, पॉइंट (अक्षांश/देशांतर) का इस्तेमाल किया जाता है.
addWaypoint(address)DirectionFinderयह किसी पते का इस्तेमाल करके, एक ऐसा वेपॉइंट जोड़ता है जिससे होकर रास्ता गुज़रना चाहिए.
clearWaypoints()DirectionFinderइससे वेपॉइंट का मौजूदा सेट मिट जाता है.
getDirections()Objectयह कुकी, सेट किए गए शुरुआती पते, मंज़िल, और अन्य विकल्पों का इस्तेमाल करके दिशा-निर्देशों को लोड करती है.
setAlternatives(useAlternatives)DirectionFinderइस विकल्प से यह तय किया जाता है कि सबसे ज़्यादा रैंक वाले रूट के बजाय, वैकल्पिक रूट दिखाए जाने चाहिए या नहीं. डिफ़ॉल्ट रूप से, यह विकल्प false पर सेट होता है.
setArrive(time)DirectionFinderयह कुकी, पहुंचने का समय सेट करती है. हालांकि, यह सुविधा कुछ ही मामलों में उपलब्ध है.
setAvoid(avoid)DirectionFinderइससे यह तय किया जाता है कि कुछ तरह की पाबंदियों से बचना है या नहीं.
setDepart(time)DirectionFinderयह कुकी, यात्रा शुरू करने का समय सेट करती है. यह तब लागू होता है, जब इसकी ज़रूरत होती है.
setDestination(latitude, longitude)DirectionFinderयह उस जगह की जानकारी सेट करता है जहां के लिए दिशा-निर्देशों का हिसाब लगाना है. इसके लिए, पॉइंट (अक्षांश/देशांतर) का इस्तेमाल किया जाता है.
setDestination(address)DirectionFinderयह कुकी, पते का इस्तेमाल करके उस जगह की जानकारी सेट करती है जहां के लिए रास्ते का हिसाब लगाना है.
setLanguage(language)DirectionFinderइससे दिशाओं के लिए इस्तेमाल की जाने वाली भाषा सेट की जाती है.
setMode(mode)DirectionFinderइससे यात्रा का मोड सेट किया जाता है. डिफ़ॉल्ट रूप से, इसे ड्राइविंग पर सेट किया जाता है.
setOptimizeWaypoints(optimizeOrder)DirectionFinderइस विकल्प से यह तय किया जाता है कि दिए गए रास्ते को ऑप्टिमाइज़ करना है या नहीं. इसके लिए, वेपॉइंट को ज़्यादा असरदार क्रम में फिर से व्यवस्थित किया जाता है. डिफ़ॉल्ट रूप से, यह विकल्प false पर सेट होता है.
setOrigin(latitude, longitude)DirectionFinderयह विकल्प, दिशा-निर्देशों का हिसाब लगाने के लिए शुरुआती जगह सेट करता है. इसके लिए, पॉइंट (अक्षांश/देशांतर) का इस्तेमाल किया जाता है.
setOrigin(address)DirectionFinderयह कुकी, पते का इस्तेमाल करके, दिशाओं का हिसाब लगाने के लिए शुरुआती जगह सेट करती है.
setRegion(region)DirectionFinderजगह के नामों को समझने के लिए, किसी क्षेत्र को सेट करता है.

ज़्यादा जानकारी वाला दस्तावेज़

addWaypoint(latitude, longitude)

यह एक ऐसा वेपॉइंट जोड़ता है जिससे होकर रास्ता गुज़रना चाहिए. इसके लिए, पॉइंट (अक्षांश/देशांतर) का इस्तेमाल किया जाता है.

// Creates a DirectionFinder with a wapoint at Lincoln Center.
const directionFinder = Maps.newDirectionFinder().addWaypoint(
    40.772628,
    -73.984243,
);

पैरामीटर

नामटाइपब्यौरा
latitudeNumberवेपॉइंट का अक्षांश.
longitudeNumberवेपॉइंट का देशांतर.

वापसी का टिकट

DirectionFinder — DirectionFinder ऑब्जेक्ट, ताकि कॉल को एक साथ जोड़ा जा सके.


addWaypoint(address)

यह किसी पते का इस्तेमाल करके, एक ऐसा वेपॉइंट जोड़ता है जिससे होकर रास्ता गुज़रना चाहिए.

// Creates a DirectionFinder with a wapoint at Lincoln Center.
const directionFinder = Maps.newDirectionFinder().addWaypoint(
    'Lincoln Center, New York, NY',
);

पैरामीटर

नामटाइपब्यौरा
addressStringपता.

वापसी का टिकट

DirectionFinder — DirectionFinder ऑब्जेक्ट, ताकि कॉल को एक साथ जोड़ा जा सके.


clearWaypoints()

इससे वेपॉइंट का मौजूदा सेट मिट जाता है.

const directionFinder = Maps.newDirectionFinder();
// ...
// Do something interesting here ...
// ...
// Remove all waypoints added with addWaypoint().
directionFinder.clearWaypoints();

वापसी का टिकट

DirectionFinder — DirectionFinder ऑब्जेक्ट, ताकि कॉल को एक साथ जोड़ा जा सके.


getDirections()

यह कुकी, सेट किए गए शुरुआती पते, मंज़िल, और अन्य विकल्पों का इस्तेमाल करके दिशा-निर्देशों को लोड करती है.

// 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 ऑब्जेक्ट है. इसमें दिशा-निर्देशों के लिए रास्तों का सेट होता है. इसके बारे में यहां बताया गया है.

इन्हें भी देखें


setAlternatives(useAlternatives)

इस विकल्प से यह तय किया जाता है कि सबसे ज़्यादा रैंक वाले रास्ते (डिफ़ॉल्ट रूप से false) के बजाय, वैकल्पिक रास्ते दिखाए जाने चाहिए या नहीं. अगर true है, तो नतीजे के तौर पर मिले ऑब्जेक्ट के routes कलेक्शन में एक से ज़्यादा एंट्री हो सकती हैं.

// Creates a DirectionFinder with alternative routes enabled.
const directionFinder = Maps.newDirectionFinder().setAlternatives(true);

पैरामीटर

नामटाइपब्यौरा
useAlternativesBooleanवैकल्पिक रास्ते देखने के लिए true पर टैप करें. false पर टैप करने से, आपको वैकल्पिक रास्ते नहीं दिखेंगे.

वापसी का टिकट

DirectionFinder — DirectionFinder ऑब्जेक्ट, ताकि कॉल को एक साथ जोड़ा जा सके.


setArrive(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);

पैरामीटर

नामटाइपब्यौरा
timeDateबस के पहुंचने का समय.

वापसी का टिकट

DirectionFinder — DirectionFinder ऑब्जेक्ट, ताकि कॉल को एक साथ जोड़ा जा सके.

इन्हें भी देखें


setAvoid(avoid)

इससे यह तय किया जाता है कि कुछ तरह की पाबंदियों से बचना है या नहीं.

// Creates a DirectionFinder that avoid highways.
const directionFinder = Maps.newDirectionFinder().setAvoid(
    Maps.DirectionFinder.Avoid.HIGHWAYS,
);

पैरामीटर

नामटाइपब्यौरा
avoidStringAvoid एट्रिब्यूट की कॉन्स्टेंट वैल्यू.

वापसी का टिकट

DirectionFinder — DirectionFinder ऑब्जेक्ट, ताकि कॉल को एक साथ जोड़ा जा सके.

इन्हें भी देखें


setDepart(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);

पैरामीटर

नामटाइपब्यौरा
timeDateरवाना होने का समय.

वापसी का टिकट

DirectionFinder — DirectionFinder ऑब्जेक्ट, ताकि कॉल को एक साथ जोड़ा जा सके.

इन्हें भी देखें


setDestination(latitude, longitude)

यह उस जगह की जानकारी सेट करता है जहां के लिए दिशा-निर्देशों का हिसाब लगाना है. इसके लिए, पॉइंट (अक्षांश/देशांतर) का इस्तेमाल किया जाता है.

// Creates a DirectionFinder with the destination set to Central Park.
const directionFinder = Maps.newDirectionFinder().setDestination(
    40.777052,
    -73.975464,
);

पैरामीटर

नामटाइपब्यौरा
latitudeNumberयात्रा खत्म होने की जगह का अक्षांश.
longitudeNumberयात्रा खत्म होने की जगह का देशांतर.

वापसी का टिकट

DirectionFinder — DirectionFinder ऑब्जेक्ट, ताकि कॉल को एक साथ जोड़ा जा सके.


setDestination(address)

यह कुकी, पते का इस्तेमाल करके उस जगह की जानकारी सेट करती है जहां के लिए रास्ते का हिसाब लगाना है.

// Creates a DirectionFinder with the destination set to Central Park.
const directionFinder = Maps.newDirectionFinder().setDestination(
    'Central Park, New York, NY',
);

पैरामीटर

नामटाइपब्यौरा
addressStringगंतव्य का पता.

वापसी का टिकट

DirectionFinder — DirectionFinder ऑब्जेक्ट, ताकि कॉल को एक साथ जोड़ा जा सके.


setLanguage(language)

इससे दिशाओं के लिए इस्तेमाल की जाने वाली भाषा सेट की जाती है.

// Creates a DirectionFinder with the language set to French.
const directionFinder = Maps.newDirectionFinder().setLanguage('fr');

पैरामीटर

नामटाइपब्यौरा
languageStringBCP-47 भाषा आइडेंटिफ़ायर.

वापसी का टिकट

DirectionFinder — DirectionFinder ऑब्जेक्ट, ताकि कॉल को एक साथ जोड़ा जा सके.

इन्हें भी देखें


setMode(mode)

इससे यात्रा का मोड सेट किया जाता है. डिफ़ॉल्ट रूप से, इसे ड्राइविंग पर सेट किया जाता है.

// Creates a DirectionFinder with the mode set to walking.
const directionFinder = Maps.newDirectionFinder().setMode(
    Maps.DirectionFinder.Mode.WALKING,
);

पैरामीटर

नामटाइपब्यौरा
modeStringMode एट्रिब्यूट की कॉन्स्टेंट वैल्यू.

वापसी का टिकट

DirectionFinder — DirectionFinder ऑब्जेक्ट, ताकि कॉल को एक साथ जोड़ा जा सके.

इन्हें भी देखें


setOptimizeWaypoints(optimizeOrder)

इस विकल्प से यह तय किया जाता है कि दिए गए रास्ते को ऑप्टिमाइज़ करना है या नहीं. इसके लिए, वेपॉइंट को ज़्यादा असरदार क्रम में फिर से व्यवस्थित किया जाता है. डिफ़ॉल्ट रूप से, यह विकल्प false पर सेट होता है.

// Creates a DirectionFinder with wapoint optimization enabled.
const directionFinder = Maps.newDirectionFinder().setOptimizeWaypoints(true);

पैरामीटर

नामटाइपब्यौरा
optimizeOrderBooleantrue ऑर्डर को ऑप्टिमाइज़ करने के लिए या false किसी अन्य वजह से.

वापसी का टिकट

DirectionFinder — DirectionFinder ऑब्जेक्ट, ताकि कॉल को एक साथ जोड़ा जा सके.

इन्हें भी देखें


setOrigin(latitude, longitude)

यह विकल्प, दिशा-निर्देशों का हिसाब लगाने के लिए शुरुआती जगह सेट करता है. इसके लिए, पॉइंट (अक्षांश/देशांतर) का इस्तेमाल किया जाता है.

// Creates a DirectionFinder with the origin set to Times Square.
const directionFinder = Maps.newDirectionFinder().setOrigin(
    40.759011,
    -73.984472,
);

पैरामीटर

नामटाइपब्यौरा
latitudeNumberयात्रा शुरू करने की जगह का अक्षांश.
longitudeNumberयात्रा शुरू करने की जगह का देशांतर.

वापसी का टिकट

DirectionFinder — DirectionFinder ऑब्जेक्ट, ताकि कॉल को एक साथ जोड़ा जा सके.


setOrigin(address)

यह कुकी, पते का इस्तेमाल करके, दिशाओं का हिसाब लगाने के लिए शुरुआती जगह सेट करती है.

// Creates a DirectionFinder with the origin set to Times Square.
const directionFinder = Maps.newDirectionFinder().setOrigin(
    'Times Square, New York, NY',
);

पैरामीटर

नामटाइपब्यौरा
addressStringशुरुआती पता.

वापसी का टिकट

DirectionFinder — यह DirectionFinder इंस्टेंस है, ताकि कॉल को एक-दूसरे से जोड़ा जा सके.


setRegion(region)

जगह के नामों को समझने के लिए, किसी क्षेत्र को सेट करता है. जिन देशों/इलाकों के कोड इस्तेमाल किए जा सकते हैं वे Google Maps के साथ काम करने वाले सीसीटीएलडी से मेल खाते हैं. उदाहरण के लिए, क्षेत्र कोड "uk" का मतलब "maps.google.co.uk" है.

// Creates a DirectionFinder with the region set to France.
const directionFinder = Maps.newDirectionFinder().setRegion('fr');

पैरामीटर

नामटाइपब्यौरा
regionStringइस्तेमाल करने के लिए क्षेत्र का कोड.

वापसी का टिकट

DirectionFinder — DirectionFinder ऑब्जेक्ट, ताकि कॉल को एक साथ जोड़ा जा सके.

इन्हें भी देखें