Class DirectionFinder

DirectionFinder

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

// Get the directions.
var 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();
var route = directions.routes[0];

// Set up marker styles.
var markerSize = Maps.StaticMap.MarkerSize.MID;
var markerColor = Maps.StaticMap.Color.GREEN
var markerLetterCode = 'A'.charCodeAt();

// Add markers to the map.
var map = Maps.newStaticMap();
for (var i = 0; i < route.legs.length; i++) {
  var leg = route.legs[i];
  if (i == 0) {
    // Add a marker for the start location of the first leg only.
    map.setMarkerStyle(markerSize, markerColor, String.fromCharCode(markerLetterCode));
    map.addMarker(leg.start_location.lat, leg.start_location.lng);
    markerLetterCode++;
  }
  map.setMarkerStyle(markerSize, markerColor, 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.
var 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एक पॉइंट (lat/lng) का इस्तेमाल करके एक वेपॉइंट जोड़ता है जहां से रूट को गुज़रना ज़रूरी है.
addWaypoint(address)DirectionFinderपते का इस्तेमाल करके ऐसा वेपॉइंट जोड़ता है जहां से रूट को गुज़रना होगा.
clearWaypoints()DirectionFinderवेपॉइंट के मौजूदा सेट को हटाता है.
getDirections()Objectशुरुआत की जगह, मंज़िल, और सेट किए गए अन्य विकल्पों का इस्तेमाल करके रास्ते की जानकारी देता है.
setAlternatives(useAlternatives)DirectionFinderयह सेट करता है कि सिर्फ़ सबसे ऊंची रैंक वाले रूट (डिफ़ॉल्ट रूप से गलत पर सेट होता है) के बजाय, वैकल्पिक रास्ते दिखाए जाने चाहिए या नहीं.
setArrive(time)DirectionFinderपहुंचने का पसंदीदा समय सेट करता है (लागू होने पर).
setAvoid(avoid)DirectionFinderसेट करता है कि कुछ खास तरह की पाबंदियों से बचना है या नहीं.
setDepart(time)DirectionFinderउड़ान का पसंदीदा समय सेट करता है (लागू होने पर).
setDestination(latitude, longitude)DirectionFinderएक बिंदु (lat/lng) का उपयोग करके समाप्ति स्थान सेट करता है जिसके लिए निर्देशों की गणना करना है.
setDestination(address)DirectionFinderपते का इस्तेमाल करके वह आखिरी जगह सेट करता है जिसके लिए निर्देशों की गणना करना है.
setLanguage(language)DirectionFinderनिर्देशों के लिए इस्तेमाल की जाने वाली भाषा सेट करता है.
setMode(mode)DirectionFinderयात्रा का मोड सेट करता है (ड्राइविंग पर डिफ़ॉल्ट होता है).
setOptimizeWaypoints(optimizeOrder)DirectionFinderयह सेट करता है कि दिए गए रूट को ऑप्टिमाइज़ करना है या नहीं. वेपॉइंट को ज़्यादा किफ़ायती क्रम में फिर से व्यवस्थित करें. यह डिफ़ॉल्ट रूप से 'गलत' पर सेट होता है.
setOrigin(latitude, longitude)DirectionFinderएक बिंदु (lat/lng) का उपयोग करके वह प्रारंभ स्थान सेट करता है जहां से दिशा-निर्देशों की गणना की जाती है.
setOrigin(address)DirectionFinderपते का इस्तेमाल करके, वह शुरुआती जगह सेट करता है जहां से रास्ता कैलकुलेट करना है.
setRegion(region)DirectionFinderजगह के नामों की व्याख्या करते समय इस्तेमाल करने के लिए क्षेत्र सेट करता है.

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

addWaypoint(latitude, longitude)

एक पॉइंट (lat/lng) का इस्तेमाल करके एक वेपॉइंट जोड़ता है जहां से रूट को गुज़रना ज़रूरी है.

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

पैरामीटर

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

रिटर्न

DirectionFinder — DirectionFinder की मदद से, कॉल की चेन बनाई जा सकती है.


addWaypoint(address)

पते का इस्तेमाल करके ऐसा वेपॉइंट जोड़ता है जहां से रूट को गुज़रना होगा.

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

पैरामीटर

नामTypeब्यौरा
addressStringएक पता.

रिटर्न

DirectionFinder — DirectionFinder की मदद से, कॉल की चेन बनाई जा सकती है.


clearWaypoints()

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

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

रिटर्न

DirectionFinder — DirectionFinder की मदद से, कॉल की चेन बनाई जा सकती है


getDirections()

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

// Logs how long it would take to walk from Times Square to Central Park.
var 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)

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

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

पैरामीटर

नामTypeब्यौरा
useAlternativesBooleanवैकल्पिक रास्तों को लौटाने के लिए सही, अगर गलत है, तो गलत है

रिटर्न

DirectionFinder — DirectionFinder की मदद से, कॉल की चेन बनाई जा सकती है


setArrive(time)

पहुंचने का पसंदीदा समय सेट करता है (लागू होने पर).

// Creates a DirectionFinder with an arrival time of 2 hours from now.
var now = new Date();
var arrive = new Date(now.getTime() + (2 * 60 * 60 * 1000));
var directionFinder = Maps.newDirectionFinder().setArrive(arrive);

पैरामीटर

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

रिटर्न

DirectionFinder — DirectionFinder की मदद से, कॉल की चेन बनाई जा सकती है

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


setAvoid(avoid)

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

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

पैरामीटर

नामTypeब्यौरा
avoidStringAvoid से एक स्थिर मान

रिटर्न

DirectionFinder — DirectionFinder की मदद से, कॉल की चेन बनाई जा सकती है

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


setDepart(time)

उड़ान का पसंदीदा समय सेट करता है (लागू होने पर).

// Creates a DirectionFinder with a departure time of 1 hour from now.
var now = new Date();
var depart = new Date(now.getTime() + (1 * 60 * 60 * 1000));
var directionFinder = Maps.newDirectionFinder().setDepart(depart);

पैरामीटर

नामTypeब्यौरा
timeDateजाने का समय

रिटर्न

DirectionFinder — DirectionFinder की मदद से, कॉल की चेन बनाई जा सकती है.

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


setDestination(latitude, longitude)

एक बिंदु (lat/lng) का उपयोग करके समाप्ति स्थान सेट करता है जिसके लिए निर्देशों की गणना करना है.

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

पैरामीटर

नामTypeब्यौरा
latitudeNumberआखिरी जगह का अक्षांश
longitudeNumberआखिरी जगह का देशांतर

रिटर्न

DirectionFinder — DirectionFinder की मदद से, कॉल की चेन बनाई जा सकती है


setDestination(address)

पते का इस्तेमाल करके वह आखिरी जगह सेट करता है जिसके लिए निर्देशों की गणना करना है.

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

पैरामीटर

नामTypeब्यौरा
addressStringआखिरी पता

रिटर्न

DirectionFinder — DirectionFinder की मदद से, कॉल की चेन बनाई जा सकती है


setLanguage(language)

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

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

पैरामीटर

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

रिटर्न

DirectionFinder — DirectionFinder की मदद से, कॉल की चेन बनाई जा सकती है

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


setMode(mode)

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

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

पैरामीटर

नामTypeब्यौरा
modeStringMode से एक स्थिर मान

रिटर्न

DirectionFinder — DirectionFinder की मदद से, कॉल की चेन बनाई जा सकती है

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


setOptimizeWaypoints(optimizeOrder)

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

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

पैरामीटर

नामTypeब्यौरा
optimizeOrderBooleanक्रम को ऑप्टिमाइज़ करने के लिए सही या गलत है

रिटर्न

DirectionFinder — DirectionFinder की मदद से, कॉल की चेन बनाई जा सकती है

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


setOrigin(latitude, longitude)

एक बिंदु (lat/lng) का उपयोग करके वह प्रारंभ स्थान सेट करता है जहां से दिशा-निर्देशों की गणना की जाती है.

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

पैरामीटर

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

रिटर्न

DirectionFinder — DirectionFinder की मदद से, कॉल की चेन बनाई जा सकती है


setOrigin(address)

पते का इस्तेमाल करके, वह शुरुआती जगह सेट करता है जहां से रास्ता कैलकुलेट करना है.

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

पैरामीटर

नामTypeब्यौरा
addressStringशुरुआती पता

रिटर्न

DirectionFinder — DirectionFinder की मदद से, कॉल की चेन बनाई जा सकती है


setRegion(region)

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

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

पैरामीटर

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

रिटर्न

DirectionFinder — DirectionFinder की मदद से, कॉल की चेन बनाई जा सकती है

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