Class ElevationSampler
সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
উচ্চতা স্যাম্পলার নির্দিষ্ট স্থানে উচ্চতার নমুনা নেওয়ার অনুমতি দেয়।
নীচের উদাহরণটি দেখায় যে আপনি কীভাবে এই ক্লাসটি ব্যবহার করে কলোরাডোর ডেনভার থেকে গ্র্যান্ড জংশন পর্যন্ত রুটের সর্বোচ্চ পয়েন্ট নির্ধারণ করতে পারেন, এটি একটি মানচিত্রে প্লট করতে পারেন এবং Google ড্রাইভে মানচিত্র সংরক্ষণ করতে পারেন৷
// 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'),
);
এছাড়াও দেখুন
বিস্তারিত ডকুমেন্টেশন
sample Location(latitude, longitude)
একটি একক বিন্দুর জন্য উচ্চতা ডেটা প্রদান করে (lat/lng)।
// Gets the elevation of Times Square using a point.
const data = Maps.newElevationSampler().sampleLocation(40.759011, -73.984472);
Logger.log(data.results[0].elevation);
পরামিতি
নাম | টাইপ | বর্ণনা |
---|
latitude | Number | নমুনার বিন্দুর অক্ষাংশ |
longitude | Number | নমুনার বিন্দুর দ্রাঘিমাংশ |
প্রত্যাবর্তন
Object
- একটি JSON অবজেক্ট যেখানে উচ্চতার ডেটা রয়েছে, যেমন এখানে বর্ণনা করা হয়েছে
sample Locations(points)
বিন্দুগুলির একটি সিরিজের জন্য উচ্চতা ডেটা প্রদান করে (lat/lng)।
// 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}`);
পরামিতি
নাম | টাইপ | বর্ণনা |
---|
points | Number[] | অক্ষাংশ/দ্রাঘিমাংশ জোড়ার একটি অ্যারে |
প্রত্যাবর্তন
Object
- একটি JSON অবজেক্ট যেখানে উচ্চতার ডেটা রয়েছে, যেমন এখানে বর্ণনা করা হয়েছে
sample Locations(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}`);
পরামিতি
নাম | টাইপ | বর্ণনা |
---|
encoded Polyline | String | নমুনা পয়েন্টের একটি এনকোডেড পলিলাইন |
প্রত্যাবর্তন
Object
- একটি JSON অবজেক্ট যেখানে উচ্চতার ডেটা রয়েছে, যেমন এখানে বর্ণনা করা হয়েছে
sample Path(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);
}
পরামিতি
নাম | টাইপ | বর্ণনা |
---|
points | Number[] | অক্ষাংশ/দ্রাঘিমাংশ জোড়ার একটি অ্যারে নমুনা ওভারের একটি পথ নির্ধারণ করে |
num Samples | Integer | পয়েন্টের পথ বরাবর নমুনা করার জন্য পয়েন্টের সংখ্যা |
প্রত্যাবর্তন
Object
- একটি JSON অবজেক্ট যেখানে উচ্চতার ডেটা রয়েছে, যেমন এখানে বর্ণনা করা হয়েছে
sample Path(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);
}
পরামিতি
নাম | টাইপ | বর্ণনা |
---|
encoded Polyline | String | পয়েন্টের একটি এনকোডেড পলিলাইন যা নমুনা ওভার করার পথ নির্ধারণ করে |
num Samples | Integer | পয়েন্টের পথ বরাবর নমুনা করার জন্য পয়েন্টের সংখ্যা |
প্রত্যাবর্তন
Object
- একটি JSON অবজেক্ট যেখানে উচ্চতার ডেটা রয়েছে, যেমন এখানে বর্ণনা করা হয়েছে
অন্য কিছু উল্লেখ না করা থাকলে, এই পৃষ্ঠার কন্টেন্ট Creative Commons Attribution 4.0 License-এর অধীনে এবং কোডের নমুনাগুলি Apache 2.0 License-এর অধীনে লাইসেন্স প্রাপ্ত। আরও জানতে, Google Developers সাইট নীতি দেখুন। Java হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-07-24 UTC-তে শেষবার আপডেট করা হয়েছে।
[null,null,["2025-07-24 UTC-তে শেষবার আপডেট করা হয়েছে।"],[[["\u003cp\u003eThe \u003ccode\u003eElevationSampler\u003c/code\u003e class allows you to retrieve elevation data for specific locations or along a path.\u003c/p\u003e\n"],["\u003cp\u003eYou can sample elevation for single points, multiple points defined by latitude/longitude pairs or encoded polylines, and along paths.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003esampleLocation\u003c/code\u003e, \u003ccode\u003esampleLocations\u003c/code\u003e, and \u003ccode\u003esamplePath\u003c/code\u003e methods provide various ways to retrieve elevation data.\u003c/p\u003e\n"],["\u003cp\u003eResults are returned as a JSON object containing elevation, latitude, and longitude information for each sampled point.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eElevationSampler\u003c/code\u003e can be used for tasks such as finding the highest point along a route, as demonstrated in the provided example.\u003c/p\u003e\n"]]],[],null,["# Class ElevationSampler\n\nElevationSampler\n\nAllows for the sampling of elevations at particular locations. \n\nThe example below shows how you can use this class to determine the highest point along the route\nfrom Denver to Grand Junction in Colorado, plot it on a map, and save the map to Google Drive.\n\n```javascript\n// Get directions from Denver to Grand Junction.\nconst directions = Maps.newDirectionFinder()\n .setOrigin('Denver, CO')\n .setDestination('Grand Junction, CO')\n .setMode(Maps.DirectionFinder.Mode.DRIVING)\n .getDirections();\nconst route = directions.routes[0];\n\n// Get elevation samples along the route.\nconst numberOfSamples = 30;\nconst response = Maps.newElevationSampler().samplePath(\n route.overview_polyline.points,\n numberOfSamples,\n);\n\n// Determine highest point.\n\nlet highestLocation = null;\nlet highestElevation = Number.MIN_VALUE;\nfor (const sample of response.results) {\n if (sample.elevation \u003e highestElevation) {\n highestElevation = sample.elevation;\n highestLocation = sample.location;\n }\n}\n\n// Add the path and marker to a map.\nconst map = Maps.newStaticMap()\n .addPath(route.overview_polyline.points)\n .addMarker(highestLocation.lat, highestLocation.lng);\n\n// Save the map to your drive\nDriveApp.createFile(\n Utilities.newBlob(map.getMapImage(), 'image/png', 'map.png'),\n);\n```\n\n#### See also\n\n- [Google Elevation API](/maps/documentation/elevation) \n\n### Methods\n\n| Method | Return type | Brief description |\n|------------------------------------------------------------------------|-------------|-------------------------------------------------------------------------------------------------|\n| [sampleLocation(latitude, longitude)](#sampleLocation(Number,Number)) | `Object` | Returns elevation data for a single point (lat/lng). |\n| [sampleLocations(points)](#sampleLocations(Number)) | `Object` | Returns elevation data for a series of points (lat/lng). |\n| [sampleLocations(encodedPolyline)](#sampleLocations(String)) | `Object` | Returns elevation data for the points in an encoded polyline. |\n| [samplePath(points, numSamples)](#samplePath(Number,Integer)) | `Object` | Returns elevation data for a number of samples along a line, defined using a series of points. |\n| [samplePath(encodedPolyline, numSamples)](#samplePath(String,Integer)) | `Object` | Returns elevation data for a number of samples along a line, defined using an encoded polyline. |\n\nDetailed documentation\n----------------------\n\n### `sample``Location(latitude, longitude)`\n\nReturns elevation data for a single point (lat/lng).\n\n```javascript\n// Gets the elevation of Times Square using a point.\nconst data = Maps.newElevationSampler().sampleLocation(40.759011, -73.984472);\nLogger.log(data.results[0].elevation);\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|-------------|----------|--------------------------------------|\n| `latitude` | `Number` | the latitude of the point to sample |\n| `longitude` | `Number` | the longitude of the point to sample |\n\n#### Return\n\n\n`Object` --- a JSON Object containing the elevation data, as described [here](/maps/documentation/elevation#ElevationResponses)\n\n*** ** * ** ***\n\n### `sample``Locations(points)`\n\nReturns elevation data for a series of points (lat/lng).\n\n```javascript\n// Gets the elevation of Times Square and Central Park using points.\nconst data = Maps.newElevationSampler().sampleLocations([\n // Times Square\n 40.759011,\n -73.984472,\n // Central Park\n 40.777052,\n -73.975464,\n]);\nLogger.log(`Times Square: ${data.results[0].elevation}`);\nLogger.log(`Central Park: ${data.results[1].elevation}`);\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|----------|------------|--------------------------------------|\n| `points` | `Number[]` | an array of latitude/longitude pairs |\n\n#### Return\n\n\n`Object` --- a JSON Object containing the elevation data, as described [here](/maps/documentation/elevation#ElevationResponses)\n\n*** ** * ** ***\n\n### `sample``Locations(encodedPolyline)`\n\nReturns elevation data for the points in an encoded polyline.\n\n```javascript\n// Gets the elevation of Times Square and Central Park using a polyline.\nconst data = Maps.newElevationSampler().sampleLocations('yvwwF|aqbMwoBiw@');\nLogger.log(`Times Square: ${data.results[0].elevation}`);\nLogger.log(`Central Park: ${data.results[1].elevation}`);\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|---------------------|----------|-----------------------------------------|\n| `encoded``Polyline` | `String` | an encoded polyline of points to sample |\n\n#### Return\n\n\n`Object` --- a JSON Object containing the elevation data, as described [here](/maps/documentation/elevation#ElevationResponses)\n\n*** ** * ** ***\n\n### `sample``Path(points, numSamples)`\n\nReturns elevation data for a number of samples along a line, defined using a series of points.\n\n```javascript\n// Gets the elevation of five points between Times Square and Central Park.\nconst data = Maps.newElevationSampler().samplePath(\n [\n // Times Square\n 40.759011,\n -73.984472,\n // Central Park\n 40.777052,\n -73.975464,\n ],\n 5,\n);\nfor (let i = 0; i \u003c data.results.length; i++) {\n Logger.log(data.results[i].elevation);\n}\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|----------------|------------|---------------------------------------------------------------------|\n| `points` | `Number[]` | an array of latitude/longitude pairs defining a path to sample over |\n| `num``Samples` | `Integer` | the number of points to sample along the path of points |\n\n#### Return\n\n\n`Object` --- a JSON Object containing the elevation data, as described [here](/maps/documentation/elevation#ElevationResponses)\n\n*** ** * ** ***\n\n### `sample``Path(encodedPolyline, numSamples)`\n\nReturns elevation data for a number of samples along a line, defined using an encoded polyline.\n\n```javascript\n// Gets the elevation of five points between Times Square and Central Park.\nconst data = Maps.newElevationSampler().samplePath('yvwwF|aqbMwoBiw@', 5);\nfor (let i = 0; i \u003c data.results.length; i++) {\n Logger.log(data.results[i].elevation);\n}\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|---------------------|-----------|--------------------------------------------------------------|\n| `encoded``Polyline` | `String` | an encoded polyline of points defining a path to sample over |\n| `num``Samples` | `Integer` | the number of points to sample along the path of points |\n\n#### Return\n\n\n`Object` --- a JSON Object containing the elevation data, as described [here](/maps/documentation/elevation#ElevationResponses)"]]