Class ElevationSampler

ElevationSampler

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

// Get directions from Denver to Grand Junction.
const directions = Maps.newDirectionFinder()
                       .setOrigin('Denver, CO')
                       .setDestination('Grand Junction, CO')
                       .setMode(Maps.DirectionFinder.Mode.DRIVING)
                       .getDirections();
const route = directions.routes[0];

// Get elevation samples along the route.
const numberOfSamples = 30;
const response = Maps.newElevationSampler().samplePath(
    route.overview_polyline.points,
    numberOfSamples,
);

// Determine highest point.

let highestLocation = null;
let highestElevation = Number.MIN_VALUE;
for (const sample of response.results) {
  if (sample.elevation > highestElevation) {
    highestElevation = sample.elevation;
    highestLocation = sample.location;
  }
}

// Add the path and marker to a map.
const map = Maps.newStaticMap()
                .addPath(route.overview_polyline.points)
                .addMarker(highestLocation.lat, highestLocation.lng);

// Save the map to your drive
DriveApp.createFile(
    Utilities.newBlob(map.getMapImage(), 'image/png', 'map.png'),
);

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

तरीके

तरीकारिटर्न टाइपसंक्षिप्त विवरण
sampleLocation(latitude, longitude)Objectयह फ़ंक्शन, किसी एक पॉइंट (अक्षांश/देशांतर) के लिए ऊंचाई का डेटा दिखाता है.
sampleLocations(points)Objectयह फ़ंक्शन, अक्षांश/देशांतर के हिसाब से पॉइंट की सीरीज़ के लिए ऊंचाई का डेटा दिखाता है.
sampleLocations(encodedPolyline)Objectयह फ़ंक्शन, कोड में बदली गई पॉलीलाइन में मौजूद पॉइंट के लिए ऊंचाई का डेटा दिखाता है.
samplePath(points, numSamples)Objectयह फ़ंक्शन, बिंदुओं की सीरीज़ का इस्तेमाल करके तय की गई लाइन के साथ-साथ कई सैंपल के लिए ऊंचाई का डेटा दिखाता है.
samplePath(encodedPolyline, numSamples)Objectयह फ़ंक्शन, किसी लाइन पर मौजूद कई सैंपल के लिए ऊंचाई का डेटा दिखाता है. लाइन को एन्कोड की गई पॉलीलाइन का इस्तेमाल करके तय किया जाता है.

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

sampleLocation(latitude, longitude)

यह फ़ंक्शन, किसी एक पॉइंट (अक्षांश/देशांतर) के लिए ऊंचाई का डेटा दिखाता है.

// Gets the elevation of Times Square using a point.
const data = Maps.newElevationSampler().sampleLocation(40.759011, -73.984472);
Logger.log(data.results[0].elevation);

पैरामीटर

नामटाइपब्यौरा
latitudeNumberसैंपल के लिए पॉइंट का अक्षांश.
longitudeNumberसैंपल के लिए चुने गए पॉइंट का देशांतर.

वापसी का टिकट

Object — यह एक JSON ऑब्जेक्ट है, जिसमें ऊंचाई का डेटा होता है. इसके बारे में यहां बताया गया है.


sampleLocations(points)

यह फ़ंक्शन, अक्षांश/देशांतर के हिसाब से पॉइंट की सीरीज़ के लिए ऊंचाई का डेटा दिखाता है.

// Gets the elevation of Times Square and Central Park using points.
const data = Maps.newElevationSampler().sampleLocations([
  // Times Square
  40.759011,
  -73.984472,
  // Central Park
  40.777052,
  -73.975464,
]);
Logger.log(`Times Square: ${data.results[0].elevation}`);
Logger.log(`Central Park: ${data.results[1].elevation}`);

पैरामीटर

नामटाइपब्यौरा
pointsNumber[]अक्षांश/देशांतर की जोड़ियों का कलेक्शन.

वापसी का टिकट

Object — यह एक JSON ऑब्जेक्ट है, जिसमें ऊंचाई का डेटा होता है. इसके बारे में यहां बताया गया है.


sampleLocations(encodedPolyline)

यह फ़ंक्शन, कोड में बदली गई पॉलीलाइन में मौजूद पॉइंट के लिए ऊंचाई का डेटा दिखाता है.

// Gets the elevation of Times Square and Central Park using a polyline.
const data = Maps.newElevationSampler().sampleLocations('yvwwF|aqbMwoBiw@');
Logger.log(`Times Square: ${data.results[0].elevation}`);
Logger.log(`Central Park: ${data.results[1].elevation}`);

पैरामीटर

नामटाइपब्यौरा
encodedPolylineStringसैंपल के लिए, पॉइंट की कोड में बदली गई पॉलीलाइन.

वापसी का टिकट

Object — यह एक JSON ऑब्जेक्ट है, जिसमें ऊंचाई का डेटा होता है. इसके बारे में यहां बताया गया है.


samplePath(points, numSamples)

यह फ़ंक्शन, बिंदुओं की सीरीज़ का इस्तेमाल करके तय की गई लाइन के साथ-साथ कई सैंपल के लिए ऊंचाई का डेटा दिखाता है.

// Gets the elevation of five points between Times Square and Central Park.
const data = Maps.newElevationSampler().samplePath(
    [
      // Times Square
      40.759011,
      -73.984472,
      // Central Park
      40.777052,
      -73.975464,
    ],
    5,
);
for (let i = 0; i < data.results.length; i++) {
  Logger.log(data.results[i].elevation);
}

पैरामीटर

नामटाइपब्यौरा
pointsNumber[]अक्षांश/देशांतर के जोड़े का एक ऐसा कलेक्शन जो सैंपल के लिए पाथ तय करता है.
numSamplesIntegerपॉइंट के पाथ के साथ सैंपल किए जाने वाले पॉइंट की संख्या.

वापसी का टिकट

Object — यह एक JSON ऑब्जेक्ट है, जिसमें ऊंचाई का डेटा होता है. इसके बारे में यहां बताया गया है.


samplePath(encodedPolyline, numSamples)

यह फ़ंक्शन, किसी लाइन पर मौजूद कई सैंपल के लिए ऊंचाई का डेटा दिखाता है. लाइन को एन्कोड की गई पॉलीलाइन का इस्तेमाल करके तय किया जाता है.

// Gets the elevation of five points between Times Square and Central Park.
const data = Maps.newElevationSampler().samplePath('yvwwF|aqbMwoBiw@', 5);
for (let i = 0; i < data.results.length; i++) {
  Logger.log(data.results[i].elevation);
}

पैरामीटर

नामटाइपब्यौरा
encodedPolylineStringयह एक कोड में बदली गई पॉलीलाइन होती है. इसमें ऐसे पॉइंट होते हैं जिनसे किसी रास्ते का पता चलता है.
numSamplesIntegerपॉइंट के पाथ के साथ सैंपल किए जाने वाले पॉइंट की संख्या.

वापसी का टिकट

Object — यह एक JSON ऑब्जेक्ट है, जिसमें ऊंचाई का डेटा होता है. इसके बारे में यहां बताया गया है.