जगहों के बीच निर्देशों को वापस लाने की अनुमति देता है.
नीचे दिए गए उदाहरण में बताया गया है कि इस क्लास का इस्तेमाल करके, टाइम्स स्क्वेयर से सेंट्रल पार्क
तक जाने का रास्ता कैसे तय किया जा सकता है. सबसे पहले लिंकन सेंटर पर जाकर, जगहों और पाथ की जानकारी को मैप पर कैसे जोड़ा जा सकता है, और मैप को ईमेल से कैसे भेजा जा सकता है.
// 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 | ब्यौरा |
---|---|---|
latitude | Number | वेपॉइंट का अक्षांश. |
longitude | Number | वेपॉइंट का देशांतर. |
रिटर्न
DirectionFinder
— DirectionFinder की मदद से, कॉल की चेन बनाई जा सकती है.
addWaypoint(address)
पते का इस्तेमाल करके ऐसा वेपॉइंट जोड़ता है जहां से रूट को गुज़रना होगा.
// Creates a DirectionFinder with a wapoint at Lincoln Center. var directionFinder = Maps.newDirectionFinder().addWaypoint('Lincoln Center, New York, NY');
पैरामीटर
नाम | Type | ब्यौरा |
---|---|---|
address | String | एक पता. |
रिटर्न
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 | ब्यौरा |
---|---|---|
useAlternatives | Boolean | वैकल्पिक रास्तों को लौटाने के लिए सही, अगर गलत है, तो गलत है |
रिटर्न
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 | ब्यौरा |
---|---|---|
time | Date | पहुंचने का समय |
रिटर्न
DirectionFinder
— DirectionFinder की मदद से, कॉल की चेन बनाई जा सकती है
इन्हें भी देखें
setAvoid(avoid)
सेट करता है कि कुछ खास तरह की पाबंदियों से बचना है या नहीं.
// Creates a DirectionFinder that avoid highways. var directionFinder = Maps.newDirectionFinder().setAvoid(Maps.DirectionFinder.Avoid.HIGHWAYS);
पैरामीटर
नाम | Type | ब्यौरा |
---|---|---|
avoid | String | Avoid से एक स्थिर मान |
रिटर्न
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 | ब्यौरा |
---|---|---|
time | Date | जाने का समय |
रिटर्न
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 | ब्यौरा |
---|---|---|
latitude | Number | आखिरी जगह का अक्षांश |
longitude | Number | आखिरी जगह का देशांतर |
रिटर्न
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 | ब्यौरा |
---|---|---|
address | String | आखिरी पता |
रिटर्न
DirectionFinder
— DirectionFinder की मदद से, कॉल की चेन बनाई जा सकती है
setLanguage(language)
निर्देशों के लिए इस्तेमाल की जाने वाली भाषा सेट करता है.
// Creates a DirectionFinder with the language set to French. var directionFinder = Maps.newDirectionFinder().setLanguage('fr');
पैरामीटर
नाम | Type | ब्यौरा |
---|---|---|
language | String | BCP-47 भाषा का आइडेंटिफ़ायर |
रिटर्न
DirectionFinder
— DirectionFinder की मदद से, कॉल की चेन बनाई जा सकती है
इन्हें भी देखें
setMode(mode)
यात्रा का मोड सेट करता है (ड्राइविंग पर डिफ़ॉल्ट होता है).
// Creates a DirectionFinder with the mode set to walking. var directionFinder = Maps.newDirectionFinder().setMode(Maps.DirectionFinder.Mode.WALKING);
पैरामीटर
नाम | Type | ब्यौरा |
---|---|---|
mode | String | Mode से एक स्थिर मान |
रिटर्न
DirectionFinder
— DirectionFinder की मदद से, कॉल की चेन बनाई जा सकती है
इन्हें भी देखें
setOptimizeWaypoints(optimizeOrder)
यह सेट करता है कि दिए गए रूट को ऑप्टिमाइज़ करना है या नहीं. वेपॉइंट को ज़्यादा किफ़ायती क्रम में फिर से व्यवस्थित करें. यह डिफ़ॉल्ट रूप से 'गलत' पर सेट होता है.
// Creates a DirectionFinder with wapoint optimization enabled. var directionFinder = Maps.newDirectionFinder().setOptimizeWaypoints(true);
पैरामीटर
नाम | Type | ब्यौरा |
---|---|---|
optimizeOrder | Boolean | क्रम को ऑप्टिमाइज़ करने के लिए सही या गलत है |
रिटर्न
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 | ब्यौरा |
---|---|---|
latitude | Number | शुरू होने की जगह का अक्षांश |
longitude | Number | शुरू होने की जगह का देशांतर |
रिटर्न
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 | ब्यौरा |
---|---|---|
address | String | शुरुआती पता |
रिटर्न
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 | ब्यौरा |
---|---|---|
region | String | इस्तेमाल करने के लिए क्षेत्रीय कोड |
रिटर्न
DirectionFinder
— DirectionFinder की मदद से, कॉल की चेन बनाई जा सकती है