diff --git a/package-lock.json b/package-lock.json
index a601553f6..e2d0cc4c1 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1257,6 +1257,10 @@
"resolved": "samples/deckgl-tripslayer",
"link": true
},
+ "node_modules/@js-api-samples/elevation-simple": {
+ "resolved": "samples/elevation-simple",
+ "link": true
+ },
"node_modules/@js-api-samples/event-arguments": {
"resolved": "samples/event-arguments",
"link": true
@@ -6599,6 +6603,10 @@
"name": "@js-api-samples/deckgl-tripslayer",
"version": "1.0.0"
},
+ "samples/elevation-simple": {
+ "name": "@js-api-samples/elevation-simple",
+ "version": "1.0.0"
+ },
"samples/event-arguments": {
"name": "@js-api-samples/event-arguments",
"version": "1.0.0"
@@ -6687,11 +6695,11 @@
"name": "@js-api-samples/map-drawing-terradraw",
"version": "1.0.0",
"dependencies": {
- "terra-draw": "*",
- "terra-draw-google-maps-adapter": "*"
+ "terra-draw": "latest",
+ "terra-draw-google-maps-adapter": "latest"
},
"devDependencies": {
- "@types/google.maps": "*",
+ "@types/google.maps": "latest",
"typescript": "^5.9.3",
"vite": "^7.2.2"
}
diff --git a/samples/elevation-simple/README.md b/samples/elevation-simple/README.md
new file mode 100644
index 000000000..2ce2e3bda
--- /dev/null
+++ b/samples/elevation-simple/README.md
@@ -0,0 +1,41 @@
+# Google Maps JavaScript Sample
+
+## elevation-simple
+
+Elevation Simple sample demonstrating the Elevation Service.
+
+## Setup
+
+### Before starting run:
+
+`npm i`
+
+### Run an example on a local web server
+
+`cd samples/elevation-simple`
+`npm start`
+
+### Build an individual example
+
+`cd samples/elevation-simple`
+`npm run build`
+
+From 'samples':
+
+`npm run build --workspace=elevation-simple/`
+
+### Build all of the examples.
+
+From 'samples':
+
+`npm run build-all`
+
+### Run lint to check for problems
+
+`cd samples/elevation-simple`
+`npx eslint index.ts`
+
+## Feedback
+
+For feedback related to this sample, please open a new issue on
+[GitHub](https://github.com/googlemaps-samples/js-api-samples/issues).
diff --git a/samples/elevation-simple/index.html b/samples/elevation-simple/index.html
new file mode 100644
index 000000000..bdfd963bd
--- /dev/null
+++ b/samples/elevation-simple/index.html
@@ -0,0 +1,29 @@
+
+
+
+
+
+ Elevation Service
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/elevation-simple/index.ts b/samples/elevation-simple/index.ts
new file mode 100644
index 000000000..e65b7427f
--- /dev/null
+++ b/samples/elevation-simple/index.ts
@@ -0,0 +1,60 @@
+/**
+ * @license
+ * Copyright 2026 Google LLC. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+// [START maps_elevation_simple]
+async function init(): Promise {
+ const [{ InfoWindow }, { ElevationService }] = await Promise.all([
+ google.maps.importLibrary('maps'),
+ google.maps.importLibrary('elevation'),
+ ]);
+
+ const mapElement = document.querySelector('gmp-map')!;
+ const innerMap = mapElement.innerMap;
+
+ const elevator = new ElevationService();
+ const infowindow = new InfoWindow();
+
+ infowindow.open(innerMap);
+
+ // Add a listener for the click event. Display the elevation for the LatLng of
+ // the click inside the infowindow.
+ innerMap.addListener('click', (event: google.maps.MapMouseEvent) => {
+ displayLocationElevation(event.latLng!, elevator, infowindow);
+ });
+}
+
+function displayLocationElevation(
+ location: google.maps.LatLng,
+ elevator: google.maps.ElevationService,
+ infowindow: google.maps.InfoWindow
+) {
+ // Initiate the location request
+ elevator
+ .getElevationForLocations({
+ locations: [location],
+ })
+ .then(({ results }) => {
+ infowindow.setPosition(location);
+
+ // Retrieve the first result
+ if (results[0]) {
+ // Open the infowindow indicating the elevation at the clicked position.
+ infowindow.setContent(
+ `The elevation at this point
is ${String(results[0].elevation)} meters.`
+ );
+ } else {
+ infowindow.setContent('No results found');
+ }
+ })
+ .catch((e: unknown) => {
+ infowindow.setContent(
+ `Elevation service failed due to: ${String(e)}`
+ );
+ });
+}
+
+void init();
+// [END maps_elevation_simple]
diff --git a/samples/elevation-simple/package.json b/samples/elevation-simple/package.json
new file mode 100644
index 000000000..b72bbb08f
--- /dev/null
+++ b/samples/elevation-simple/package.json
@@ -0,0 +1,12 @@
+{
+ "name": "@js-api-samples/elevation-simple",
+ "version": "1.0.0",
+ "scripts": {
+ "build": "bash ../build-single.sh",
+ "test": "tsc && npm run build:vite --workspace=.",
+ "start": "tsc && vite build --base './' && vite",
+ "build:vite": "vite build --base './'",
+ "preview": "vite preview"
+ },
+ "dependencies": {}
+}
diff --git a/samples/elevation-simple/style.css b/samples/elevation-simple/style.css
new file mode 100644
index 000000000..b3ea69173
--- /dev/null
+++ b/samples/elevation-simple/style.css
@@ -0,0 +1,18 @@
+/**
+ * @license
+ * Copyright 2026 Google LLC. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0
+ */
+/* [START maps_elevation_simple] */
+
+/*
+ * Optional: Makes the sample page fill the window.
+ */
+html,
+body {
+ height: 100%;
+ margin: 0;
+ padding: 0;
+}
+
+/* [END maps_elevation_simple] */
diff --git a/samples/elevation-simple/tsconfig.json b/samples/elevation-simple/tsconfig.json
new file mode 100644
index 000000000..976bcc6ef
--- /dev/null
+++ b/samples/elevation-simple/tsconfig.json
@@ -0,0 +1,7 @@
+{
+ "extends": "../../tsconfig.base.json",
+ "compilerOptions": {
+ "rootDir": "."
+ },
+ "include": ["./*.ts"]
+}