উচ্চতা উপাদান
সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
উচ্চতা স্বতন্ত্র উপাদান ElevationElement
হল একটি HTML উপাদান যা দৃশ্যত একটি একক বিন্দু বা একটি পলিলাইনের জন্য উচ্চতার ডেটা প্রদর্শন করে। এটি অক্ষাংশ এবং দ্রাঘিমাংশ স্থানাঙ্কের অ্যারে সহ path
সম্পত্তিতে সেট করা পথ বরাবর উচ্চতার একটি গ্রাফ দেখায়। রেখার অংশগুলি অ্যারের বিন্দুগুলির মধ্যে প্রসারিত হয়, তাই এমনকি অল্প সংখ্যক বিন্দু এখনও একটি বিশদ উচ্চতা গ্রাফ তৈরি করবে।
স্থানাঙ্ক ব্যবহার করে পথের উচ্চতা সেট করুন
নিম্নলিখিত উদাহরণটি gmp-elevation
উপাদান ব্যবহার করে স্থানাঙ্কের একটি সেট দ্বারা নির্বাচিত দুটি বিন্দুর মধ্যে একটি পথের উচ্চতা রেন্ডার করে।
উপাদানটি unit-system
বৈশিষ্ট্য ব্যবহার করে মেট্রিক পরিমাপের জন্য কনফিগার করা হয়েছে:
<gmp-elevation unit-system="metric"></gmp-elevation>
একটি querySelector
উচ্চতার উপাদান নির্বাচন করতে এবং অক্ষাংশ এবং দ্রাঘিমাংশ স্থানাঙ্কের সাথে এর path
বৈশিষ্ট্য সেট করতে ব্যবহৃত হয়:
/** Maps JS loaded callback */
async function init() {
// Load the Elevation Element from Maps JS
const {ElevationElement} = await google.maps.importLibrary('elevation');
// Specify an elevation path to render
const elevationElement = document.querySelector('gmp-elevation');
elevationElement.path = [
{lat: 37.4523, lng: -122.2645},
{lat: 37.377, lng: -122.4078},
];
}
সম্পূর্ণ কোড উদাহরণ দেখুন
জাভাস্ক্রিপ্ট
/** Maps JS loaded callback */
async function init() {
// Load the Elevation Element from Maps JS
const {ElevationElement} = await google.maps.importLibrary('elevation');
// Specify an elevation path to render
const elevationElement = document.querySelector('gmp-elevation');
elevationElement.path = [
{lat: 37.4523, lng: -122.2645},
{lat: 37.377, lng: -122.4078},
];
}
init();
সিএসএস
html, body {
margin: 0;
padding: 0;
}
gmp-elevation {
width: 100%;
height: 100%;
}
.overlay {
margin: 20px;
width: 400px;
}
এইচটিএমএল
<!DOCTYPE html>
<html>
<head>
<title>Simple Elevation</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<h1>Path elevation</h1>
<div class="overlay">
<gmp-elevation unit-system="metric"></gmp-elevation>
</div>
<script>
(g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({
key: "YOUR_API_KEY",
v: "alpha"
});
</script>
</body>
</html>
একটি পলিলাইন ব্যবহার করে পথের উচ্চতা সেট করুন
নিম্নলিখিত উদাহরণটি ব্যবহারকারীর আঁকা পলিলাইনের উপর ভিত্তি করে একটি পথের উচ্চতা রেন্ডার করে। এটি polyline.getPath().getArray()
ব্যবহার করে ব্যবহারকারীর পলিলাইন থেকে path
পায়।
elevationElem.path = polyline.getPath().getArray();
সম্পূর্ণ কোড উদাহরণ দেখুন
জাভাস্ক্রিপ্ট
const map = document.querySelector('gmp-map');
const elevationElem = document.querySelector('gmp-elevation');
async function init() {
await google.maps.importLibrary('places');
await google.maps.importLibrary('marker');
await google.maps.importLibrary('elevation');
map.innerMap.setOptions({'mapTypeControl': true, 'clickableIcons': false});
findCurrentLocation();
drawPolyline();
}
async function drawPolyline() {
const {DrawingManager} = await google.maps.importLibrary('drawing');
const drawingManager = new DrawingManager({
drawingMode: google.maps.drawing.OverlayType.POLYLINE,
drawingControl: true,
drawingControlOptions: {
position: google.maps.ControlPosition.TOP_CENTER,
drawingModes: [google.maps.drawing.OverlayType.POLYLINE]
},
polylineOptions: {geodesic: true, strokeColor: '#5491f5', strokeWeight: 6}
});
drawingManager.setMap(map.innerMap);
drawingManager.addListener('polylinecomplete', (polyline) => {
console.log('complete');
console.log(polyline.getPath().getArray());
elevationElem.path = polyline.getPath().getArray();
polyline.addListener('click', (e) => {
console.log(e);
});
});
}
async function findCurrentLocation() {
const {LatLng} = await google.maps.importLibrary('core');
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
(position) => {
const pos =
new LatLng(position.coords.latitude, position.coords.longitude);
map.innerMap.panTo(pos);
map.innerMap.setZoom(16);
},
() => {
console.log('The Geolocation service failed.');
map.innerMap.setZoom(16);
},
);
} else {
console.log(`Your browser doesn't support geolocation`);
map.innerMap.setZoom(16);
}
}
init();
সিএসএস
html, body {
height: 100%;
margin: 0;
}
body {
display: flex;
flex-direction: column;
font-family: Arial, Helvetica, sans-serif;
}
h1 {
font-size: 16px;
text-align: center;
}
gmp-map {
box-sizing: border-box;
margin-top: 20px;
width: 100%;
height: 100%;
}
gmp-elevation {
width: 100%;
height: 300px;
}
.overlay {
width: 800px;
}
এইচটিএমএল
<!DOCTYPE html>
<html>
<head>
<title>Path Elevation</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<h1>Draw polyline and get path elevation</h1>
<gmp-map center="-37.813,144.963" zoom="12" map-id="DEMO_MAP_ID">
<div id="elevation-container" class="overlay" slot="control-block-end-inline-center">
<gmp-elevation unit-system="metric"></gmp-elevation>
</div>
</gmp-map>
<script>
(g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({
key: "YOUR_API_KEY",
v: "alpha"
});
</script>
</body>
</html>
অন্য কিছু উল্লেখ না করা থাকলে, এই পৃষ্ঠার কন্টেন্ট Creative Commons Attribution 4.0 License-এর অধীনে এবং কোডের নমুনাগুলি Apache 2.0 License-এর অধীনে লাইসেন্স প্রাপ্ত। আরও জানতে, Google Developers সাইট নীতি দেখুন। Java হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-07-30 UTC-তে শেষবার আপডেট করা হয়েছে।
[null,null,["2025-07-30 UTC-তে শেষবার আপডেট করা হয়েছে।"],[[["\u003cp\u003eThe \u003ccode\u003eElevationElement\u003c/code\u003e displays elevation data for a point or polyline on a map using a graph.\u003c/p\u003e\n"],["\u003cp\u003eYou can set the elevation path using latitude and longitude coordinates or with a user-drawn polyline.\u003c/p\u003e\n"],["\u003cp\u003eThe elevation graph is generated by interpolating line segments between the provided coordinates.\u003c/p\u003e\n"],["\u003cp\u003eThis feature is currently experimental and might have limited support.\u003c/p\u003e\n"]]],["The `ElevationElement` visually displays elevation data for a point or polyline. It uses a `gmp-elevation` element configured for metric measurements. Elevation paths can be set via coordinates or a user-drawn polyline. When using coordinates, a `querySelector` selects the element, and the `path` property is set with latitude/longitude arrays. For polylines, the element's `path` is populated using `polyline.getPath().getArray()`, to get an array of the polyline's coordinates. This feature is currently in an experimental pre-GA stage.\n"],null,["| This product or feature is Experimental (pre-GA). Pre-GA products and features might have limited support, and changes to pre-GA products and features might not be compatible with other pre-GA versions. Pre-GA Offerings are covered by the [Google\n| Maps Platform Service Specific Terms](https://cloud.google.com/maps-platform/terms/maps-service-terms). For more information, see the [launch stage descriptions](/maps/launch-stages).\nElevation Standalone Element\n\nThe [`ElevationElement`](/maps/documentation/javascript/reference/elevation-widget#ElevationElement) is an HTML element that visually displays elevation data for a single point or a polyline. It shows a graph of elevation along the path set in the [`path`](/maps/documentation/javascript/reference/elevation-widget#ElevationElement.path) property with an array of latitude and longitude coordinates. Line segments are interpolated between the points of the array, so even a small number of points will still produce a detailed elevation graph.\n\nSet path elevation using coordinates\n\nThe following example renders the elevation of a path between two points selected by a set of coordinates, using a `gmp-elevation` element.\n\nThe element is configured for metric measurement using the [`unit-system`](/maps/documentation/javascript/reference/elevation-widget#ElevationElement.unitSystem) attribute: \n\n```html\n \u003cgmp-elevation unit-system=\"metric\"\u003e\u003c/gmp-elevation\u003e\n```\n\nA `querySelector` is used to select the elevation element and set its `path` property with latitude and longitude coordinates: \n\n```javascript\n/** Maps JS loaded callback */\nasync function init() {\n // Load the Elevation Element from Maps JS\n const {ElevationElement} = await google.maps.importLibrary('elevation');\n\n // Specify an elevation path to render\n const elevationElement = document.querySelector('gmp-elevation');\n elevationElement.path = [\n {lat: 37.4523, lng: -122.2645},\n {lat: 37.377, lng: -122.4078},\n ];\n}\n```\n\nSee the complete code example \n\nJavaScript \n\n```javascript\n/** Maps JS loaded callback */\nasync function init() {\n // Load the Elevation Element from Maps JS\n const {ElevationElement} = await google.maps.importLibrary('elevation');\n\n // Specify an elevation path to render\n const elevationElement = document.querySelector('gmp-elevation');\n elevationElement.path = [\n {lat: 37.4523, lng: -122.2645},\n {lat: 37.377, lng: -122.4078},\n ];\n}\n\ninit();\n```\n\nCSS \n\n```css\nhtml, body {\n margin: 0;\n padding: 0;\n}\n\ngmp-elevation {\n width: 100%;\n height: 100%;\n}\n\n.overlay {\n margin: 20px;\n width: 400px;\n}\n```\n\nHTML \n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n \u003chead\u003e\n \u003ctitle\u003eSimple Elevation\u003c/title\u003e\n \u003cmeta charset=\"utf-8\"\u003e\n \u003clink rel=\"stylesheet\" type=\"text/css\" href=\"style.css\"\u003e\n \u003c/head\u003e\n \u003cbody\u003e\n \u003ch1\u003ePath elevation\u003c/h1\u003e\n \u003cdiv class=\"overlay\"\u003e\n \u003cgmp-elevation unit-system=\"metric\"\u003e\u003c/gmp-elevation\u003e\n \u003c/div\u003e\n \u003cscript\u003e\n (g=\u003e{var h,a,k,p=\"The Google Maps JavaScript API\",c=\"google\",l=\"importLibrary\",q=\"__ib__\",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=\u003eh||(h=new Promise(async(f,n)=\u003e{await (a=m.createElement(\"script\"));e.set(\"libraries\",[...r]+\"\");for(k in g)e.set(k.replace(/[A-Z]/g,t=\u003e\"_\"+t[0].toLowerCase()),g[k]);e.set(\"callback\",c+\".maps.\"+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=\u003eh=n(Error(p+\" could not load.\"));a.nonce=m.querySelector(\"script[nonce]\")?.nonce||\"\";m.head.append(a)}));d[l]?console.warn(p+\" only loads once. Ignoring:\",g):d[l]=(f,...n)=\u003er.add(f)&&u().then(()=\u003ed[l](f,...n))})({\n key: \"YOUR_API_KEY\",\n v: \"alpha\"\n });\n \u003c/script\u003e\n \u003c/body\u003e\n\u003c/html\u003e\n```\n\nSet path elevation using a polyline\n\nThe following example renders the elevation of a path based on a user-drawn polyline. It obtains the [`path`](/maps/documentation/javascript/reference/elevation-widget#ElevationElement.path) from the user's polyline using [`polyline.getPath().getArray()`:](/maps/documentation/javascript/reference/polygon#Polyline.getPath) \n\n```javascript\n elevationElem.path = polyline.getPath().getArray();\n```\n\nSee the complete code example \n\nJavaScript \n\n```javascript\nconst map = document.querySelector('gmp-map');\nconst elevationElem = document.querySelector('gmp-elevation');\n\nasync function init() {\n await google.maps.importLibrary('places');\n await google.maps.importLibrary('marker');\n await google.maps.importLibrary('elevation');\n\n\n map.innerMap.setOptions({'mapTypeControl': true, 'clickableIcons': false});\n\n findCurrentLocation();\n drawPolyline();\n}\n\nasync function drawPolyline() {\n const {DrawingManager} = await google.maps.importLibrary('drawing');\n const drawingManager = new DrawingManager({\n drawingMode: google.maps.drawing.OverlayType.POLYLINE,\n drawingControl: true,\n drawingControlOptions: {\n position: google.maps.ControlPosition.TOP_CENTER,\n drawingModes: [google.maps.drawing.OverlayType.POLYLINE]\n },\n polylineOptions: {geodesic: true, strokeColor: '#5491f5', strokeWeight: 6}\n });\n\n drawingManager.setMap(map.innerMap);\n\n drawingManager.addListener('polylinecomplete', (polyline) =\u003e {\n console.log('complete');\n console.log(polyline.getPath().getArray());\n elevationElem.path = polyline.getPath().getArray();\n polyline.addListener('click', (e) =\u003e {\n console.log(e);\n });\n });\n}\n\nasync function findCurrentLocation() {\n const {LatLng} = await google.maps.importLibrary('core');\n if (navigator.geolocation) {\n navigator.geolocation.getCurrentPosition(\n (position) =\u003e {\n const pos =\n new LatLng(position.coords.latitude, position.coords.longitude);\n map.innerMap.panTo(pos);\n map.innerMap.setZoom(16);\n },\n () =\u003e {\n console.log('The Geolocation service failed.');\n map.innerMap.setZoom(16);\n },\n );\n } else {\n console.log(`Your browser doesn't support geolocation`);\n map.innerMap.setZoom(16);\n }\n}\n\ninit();\n```\n\nCSS \n\n```css\nhtml, body {\n height: 100%;\n margin: 0;\n}\n\nbody {\n display: flex;\n flex-direction: column;\n font-family: Arial, Helvetica, sans-serif;\n}\n\nh1 {\n font-size: 16px;\n text-align: center;\n}\n\ngmp-map {\n box-sizing: border-box;\n margin-top: 20px;\n width: 100%;\n height: 100%;\n}\n\ngmp-elevation {\n width: 100%;\n height: 300px;\n}\n\n.overlay {\n width: 800px;\n}\n```\n\nHTML \n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n \u003chead\u003e\n \u003ctitle\u003ePath Elevation\u003c/title\u003e\n \u003cmeta charset=\"utf-8\"\u003e\n \u003clink rel=\"stylesheet\" type=\"text/css\" href=\"style.css\"\u003e\n \u003c/head\u003e\n \u003cbody\u003e\n \u003ch1\u003eDraw polyline and get path elevation\u003c/h1\u003e\n \u003cgmp-map center=\"-37.813,144.963\" zoom=\"12\" map-id=\"DEMO_MAP_ID\"\u003e\n \u003cdiv id=\"elevation-container\" class=\"overlay\" slot=\"control-block-end-inline-center\"\u003e\n \u003cgmp-elevation unit-system=\"metric\"\u003e\u003c/gmp-elevation\u003e\n \u003c/div\u003e\n \u003c/gmp-map\u003e\n \u003cscript\u003e\n (g=\u003e{var h,a,k,p=\"The Google Maps JavaScript API\",c=\"google\",l=\"importLibrary\",q=\"__ib__\",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=\u003eh||(h=new Promise(async(f,n)=\u003e{await (a=m.createElement(\"script\"));e.set(\"libraries\",[...r]+\"\");for(k in g)e.set(k.replace(/[A-Z]/g,t=\u003e\"_\"+t[0].toLowerCase()),g[k]);e.set(\"callback\",c+\".maps.\"+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=\u003eh=n(Error(p+\" could not load.\"));a.nonce=m.querySelector(\"script[nonce]\")?.nonce||\"\";m.head.append(a)}));d[l]?console.warn(p+\" only loads once. Ignoring:\",g):d[l]=(f,...n)=\u003er.add(f)&&u().then(()=\u003ed[l](f,...n))})({\n key: \"YOUR_API_KEY\",\n v: \"alpha\"\n });\n \u003c/script\u003e\n \u003c/body\u003e\n\u003c/html\u003e\n```"]]