Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ <h1>Maps JSAPI Samples</h1>
<li><a href='/samples/event-simple/dist'>event-simple</a></li>
<li><a href='/samples/geocoding-component-restriction/dist'>geocoding-component-restriction</a></li>
<li><a href='/samples/geocoding-place-id/dist'>geocoding-place-id</a></li>
<li><a href='/samples/geocoding-region-es/dist'>geocoding-region-es</a></li>
<li><a href='/samples/geocoding-region-us/dist'>geocoding-region-us</a></li>
<li><a href='/samples/geocoding-reverse/dist'>geocoding-reverse</a></li>
<li><a href='/samples/geocoding-simple/dist'>geocoding-simple</a></li>
Expand Down
13 changes: 13 additions & 0 deletions dist/samples/geocoding-region-es/app/.eslintsrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": [
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"rules": {
"@typescript-eslint/ban-ts-comment": 0,
"@typescript-eslint/no-this-alias": 1,
"@typescript-eslint/no-empty-function": 1,
"@typescript-eslint/explicit-module-boundary-types": 1,
"@typescript-eslint/no-unused-vars": 1
}
}
41 changes: 41 additions & 0 deletions dist/samples/geocoding-region-es/app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Google Maps JavaScript Sample

## geocoding-region-es

This sample demonstrates how to geocode using the Spanish region code.

## Setup

### Before starting run:

`npm i`

### Run an example on a local web server

`cd samples/geocoding-region-es`
`npm start`

### Build an individual example

`cd samples/geocoding-region-es`
`npm run build`

From 'samples':

`npm run build --workspace=geocoding-region-es/`

### Build all of the examples.

From 'samples':

`npm run build-all`

### Run lint to check for problems

`cd samples/geocoding-region-es`
`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).
22 changes: 22 additions & 0 deletions dist/samples/geocoding-region-es/app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!doctype html>
<!--
@license
Copyright 2026 Google LLC. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
-->
<!-- [START maps_js_geocoding_region_es] -->
<html>
<head>
<title>Geocoding Region - ES</title>

<link rel="stylesheet" type="text/css" href="./style.css" />
<script type="module" src="./index.js"></script>
<!-- prettier-ignore -->
<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: "AIzaSyA6myHzS10YXdcazAFalmXvDkrYCp5cLc8", v: "weekly", region: "ES" });</script>
</head>
<body>
<gmp-map zoom="8" map-id="DEMO_MAP_ID"></gmp-map>
</body>
</html>
<!-- [END maps_js_geocoding_region_es] -->
38 changes: 38 additions & 0 deletions dist/samples/geocoding-region-es/app/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* @license
* Copyright 2026 Google LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

// @ts-nocheck TODO remove when fixed

// [START maps_js_geocoding_region_es]
async function initMap(): Promise<void> {
await Promise.all([
google.maps.importLibrary("maps"),
google.maps.importLibrary("geocoding"),
google.maps.importLibrary("marker"),
]);

const mapElement = document.querySelector("gmp-map") as google.maps.MapElement;
const innerMap = mapElement.innerMap;
const geocoder = new google.maps.Geocoder();

geocoder
.geocode({ address: "Toledo" })
.then((response) => {
const position = response.results[0].geometry.location;

innerMap.setCenter(position);
new google.maps.marker.AdvancedMarkerElement({
map: innerMap,
position,
});
})
.catch((e) =>
window.alert("Geocode was not successful for the following reason: " + e)
);
}

initMap();
// [END maps_js_geocoding_region_es]
14 changes: 14 additions & 0 deletions dist/samples/geocoding-region-es/app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "@js-api-samples/geocoding-region-es",
"version": "1.0.0",
"scripts": {
"build": "tsc && bash ../jsfiddle.sh geocoding-region-es && bash ../app.sh geocoding-region-es && bash ../docs.sh geocoding-region-es && npm run build:vite --workspace=. && bash ../dist.sh geocoding-region-es",
"test": "tsc && npm run build:vite --workspace=.",
"start": "tsc && vite build --base './' && vite",
"build:vite": "vite build --base './'",
"preview": "vite preview"
},
"dependencies": {

}
}
18 changes: 18 additions & 0 deletions dist/samples/geocoding-region-es/app/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* @license
* Copyright 2026 Google LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
/* [START maps_js_geocoding_region_es] */

/*
* Optional: Makes the sample page fill the window.
*/
html,
body {
height: 100%;
margin: 0;
padding: 0;
}

/* [END maps_js_geocoding_region_es] */
9 changes: 9 additions & 0 deletions dist/samples/geocoding-region-es/app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "."
},
"include": [
"./*.ts",
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
html,body{height:100%;margin:0;padding:0}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions dist/samples/geocoding-region-es/dist/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!doctype html>
<!--
@license
Copyright 2026 Google LLC. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
-->
<!-- [START maps_js_geocoding_region_es] -->
<html>
<head>
<title>Geocoding Region - ES</title>

<!-- prettier-ignore -->
<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: "AIzaSyA6myHzS10YXdcazAFalmXvDkrYCp5cLc8", v: "weekly", region: "ES" });</script>
<script type="module" crossorigin src="./assets/index-D5BorbMO.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-549u98Rk.css">
</head>
<body>
<gmp-map zoom="8" map-id="DEMO_MAP_ID"></gmp-map>
</body>
</html>
<!-- [END maps_js_geocoding_region_es] -->
22 changes: 22 additions & 0 deletions dist/samples/geocoding-region-es/docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!doctype html>
<!--
@license
Copyright 2026 Google LLC. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
-->
<!-- [START maps_js_geocoding_region_es] -->
<html>
<head>
<title>Geocoding Region - ES</title>

<link rel="stylesheet" type="text/css" href="./style.css" />
<script type="module" src="./index.js"></script>
<!-- prettier-ignore -->
<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: "AIzaSyA6myHzS10YXdcazAFalmXvDkrYCp5cLc8", v: "weekly", region: "ES" });</script>
</head>
<body>
<gmp-map zoom="8" map-id="DEMO_MAP_ID"></gmp-map>
</body>
</html>
<!-- [END maps_js_geocoding_region_es] -->
31 changes: 31 additions & 0 deletions dist/samples/geocoding-region-es/docs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"use strict";
/**
* @license
* Copyright 2026 Google LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
// @ts-nocheck TODO remove when fixed
// [START maps_js_geocoding_region_es]
async function initMap() {
await Promise.all([
google.maps.importLibrary("maps"),
google.maps.importLibrary("geocoding"),
google.maps.importLibrary("marker"),
]);
const mapElement = document.querySelector("gmp-map");
const innerMap = mapElement.innerMap;
const geocoder = new google.maps.Geocoder();
geocoder
.geocode({ address: "Toledo" })
.then((response) => {
const position = response.results[0].geometry.location;
innerMap.setCenter(position);
new google.maps.marker.AdvancedMarkerElement({
map: innerMap,
position,
});
})
.catch((e) => window.alert("Geocode was not successful for the following reason: " + e));
}
initMap();
// [END maps_js_geocoding_region_es]
38 changes: 38 additions & 0 deletions dist/samples/geocoding-region-es/docs/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* @license
* Copyright 2026 Google LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

// @ts-nocheck TODO remove when fixed

// [START maps_js_geocoding_region_es]
async function initMap(): Promise<void> {
await Promise.all([
google.maps.importLibrary("maps"),
google.maps.importLibrary("geocoding"),
google.maps.importLibrary("marker"),
]);

const mapElement = document.querySelector("gmp-map") as google.maps.MapElement;
const innerMap = mapElement.innerMap;
const geocoder = new google.maps.Geocoder();

geocoder
.geocode({ address: "Toledo" })
.then((response) => {
const position = response.results[0].geometry.location;

innerMap.setCenter(position);
new google.maps.marker.AdvancedMarkerElement({
map: innerMap,
position,
});
})
.catch((e) =>
window.alert("Geocode was not successful for the following reason: " + e)
);
}

initMap();
// [END maps_js_geocoding_region_es]
18 changes: 18 additions & 0 deletions dist/samples/geocoding-region-es/docs/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* @license
* Copyright 2026 Google LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
/* [START maps_js_geocoding_region_es] */

/*
* Optional: Makes the sample page fill the window.
*/
html,
body {
height: 100%;
margin: 0;
padding: 0;
}

/* [END maps_js_geocoding_region_es] */
17 changes: 17 additions & 0 deletions dist/samples/geocoding-region-es/jsfiddle/demo.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @license
* Copyright 2026 Google LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/


/*
* Optional: Makes the sample page fill the window.
*/
html,
body {
height: 100%;
margin: 0;
padding: 0;
}

7 changes: 7 additions & 0 deletions dist/samples/geocoding-region-es/jsfiddle/demo.details
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: geocoding-region-es
authors:
- Geo Developer IX Documentation Team
tags:
- google maps
load_type: h
description: Sample code supporting Google Maps Platform JavaScript API documentation.
22 changes: 22 additions & 0 deletions dist/samples/geocoding-region-es/jsfiddle/demo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!doctype html>
<!--
@license
Copyright 2026 Google LLC. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
-->

<html>
<head>
<title>Geocoding Region - ES</title>

<link rel="stylesheet" type="text/css" href="./style.css" />
<script type="module" src="./index.js"></script>
<!-- prettier-ignore -->
<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: "AIzaSyA6myHzS10YXdcazAFalmXvDkrYCp5cLc8", v: "weekly", region: "ES" });</script>
</head>
<body>
<gmp-map zoom="8" map-id="DEMO_MAP_ID"></gmp-map>
</body>
</html>

31 changes: 31 additions & 0 deletions dist/samples/geocoding-region-es/jsfiddle/demo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"use strict";
/**
* @license
* Copyright 2026 Google LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
// @ts-nocheck TODO remove when fixed

async function initMap() {
await Promise.all([
google.maps.importLibrary("maps"),
google.maps.importLibrary("geocoding"),
google.maps.importLibrary("marker"),
]);
const mapElement = document.querySelector("gmp-map");
const innerMap = mapElement.innerMap;
const geocoder = new google.maps.Geocoder();
geocoder
.geocode({ address: "Toledo" })
.then((response) => {
const position = response.results[0].geometry.location;
innerMap.setCenter(position);
new google.maps.marker.AdvancedMarkerElement({
map: innerMap,
position,
});
})
.catch((e) => window.alert("Geocode was not successful for the following reason: " + e));
}
initMap();

Loading
Loading