diff --git a/dist/index.html b/dist/index.html index 006b2267..528d0631 100644 --- a/dist/index.html +++ b/dist/index.html @@ -89,6 +89,7 @@

Maps JSAPI Samples

  • event-simple
  • geocoding-component-restriction
  • geocoding-place-id
  • +
  • geocoding-region-es
  • geocoding-region-us
  • geocoding-reverse
  • geocoding-simple
  • diff --git a/dist/samples/geocoding-region-es/app/.eslintsrc.json b/dist/samples/geocoding-region-es/app/.eslintsrc.json new file mode 100644 index 00000000..4c44dab0 --- /dev/null +++ b/dist/samples/geocoding-region-es/app/.eslintsrc.json @@ -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 + } +} diff --git a/dist/samples/geocoding-region-es/app/README.md b/dist/samples/geocoding-region-es/app/README.md new file mode 100644 index 00000000..83e6c3ca --- /dev/null +++ b/dist/samples/geocoding-region-es/app/README.md @@ -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). diff --git a/dist/samples/geocoding-region-es/app/index.html b/dist/samples/geocoding-region-es/app/index.html new file mode 100644 index 00000000..4c1bc62a --- /dev/null +++ b/dist/samples/geocoding-region-es/app/index.html @@ -0,0 +1,22 @@ + + + + + + Geocoding Region - ES + + + + + + + + + + + diff --git a/dist/samples/geocoding-region-es/app/index.ts b/dist/samples/geocoding-region-es/app/index.ts new file mode 100644 index 00000000..a7a32277 --- /dev/null +++ b/dist/samples/geocoding-region-es/app/index.ts @@ -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 { + 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] diff --git a/dist/samples/geocoding-region-es/app/package.json b/dist/samples/geocoding-region-es/app/package.json new file mode 100644 index 00000000..23b2e9ee --- /dev/null +++ b/dist/samples/geocoding-region-es/app/package.json @@ -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": { + + } +} diff --git a/dist/samples/geocoding-region-es/app/style.css b/dist/samples/geocoding-region-es/app/style.css new file mode 100644 index 00000000..f4c07e1b --- /dev/null +++ b/dist/samples/geocoding-region-es/app/style.css @@ -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] */ \ No newline at end of file diff --git a/dist/samples/geocoding-region-es/app/tsconfig.json b/dist/samples/geocoding-region-es/app/tsconfig.json new file mode 100644 index 00000000..5ba470c0 --- /dev/null +++ b/dist/samples/geocoding-region-es/app/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "rootDir": "." + }, + "include": [ + "./*.ts", + ] +} diff --git a/dist/samples/geocoding-region-es/dist/assets/index-549u98Rk.css b/dist/samples/geocoding-region-es/dist/assets/index-549u98Rk.css new file mode 100644 index 00000000..37abb1c4 --- /dev/null +++ b/dist/samples/geocoding-region-es/dist/assets/index-549u98Rk.css @@ -0,0 +1 @@ +html,body{height:100%;margin:0;padding:0} diff --git a/dist/samples/geocoding-region-es/dist/assets/index-D5BorbMO.js b/dist/samples/geocoding-region-es/dist/assets/index-D5BorbMO.js new file mode 100644 index 00000000..8400782f --- /dev/null +++ b/dist/samples/geocoding-region-es/dist/assets/index-D5BorbMO.js @@ -0,0 +1 @@ +(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();async function e(){await Promise.all([google.maps.importLibrary(`maps`),google.maps.importLibrary(`geocoding`),google.maps.importLibrary(`marker`)]);let e=document.querySelector(`gmp-map`).innerMap;new google.maps.Geocoder().geocode({address:`Toledo`}).then(t=>{let n=t.results[0].geometry.location;e.setCenter(n),new google.maps.marker.AdvancedMarkerElement({map:e,position:n})}).catch(e=>window.alert(`Geocode was not successful for the following reason: `+e))}e(); \ No newline at end of file diff --git a/dist/samples/geocoding-region-es/dist/index.html b/dist/samples/geocoding-region-es/dist/index.html new file mode 100644 index 00000000..933a555a --- /dev/null +++ b/dist/samples/geocoding-region-es/dist/index.html @@ -0,0 +1,22 @@ + + + + + + Geocoding Region - ES + + + + + + + + + + + diff --git a/dist/samples/geocoding-region-es/docs/index.html b/dist/samples/geocoding-region-es/docs/index.html new file mode 100644 index 00000000..4c1bc62a --- /dev/null +++ b/dist/samples/geocoding-region-es/docs/index.html @@ -0,0 +1,22 @@ + + + + + + Geocoding Region - ES + + + + + + + + + + + diff --git a/dist/samples/geocoding-region-es/docs/index.js b/dist/samples/geocoding-region-es/docs/index.js new file mode 100644 index 00000000..24c768a6 --- /dev/null +++ b/dist/samples/geocoding-region-es/docs/index.js @@ -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] diff --git a/dist/samples/geocoding-region-es/docs/index.ts b/dist/samples/geocoding-region-es/docs/index.ts new file mode 100644 index 00000000..a7a32277 --- /dev/null +++ b/dist/samples/geocoding-region-es/docs/index.ts @@ -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 { + 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] diff --git a/dist/samples/geocoding-region-es/docs/style.css b/dist/samples/geocoding-region-es/docs/style.css new file mode 100644 index 00000000..f4c07e1b --- /dev/null +++ b/dist/samples/geocoding-region-es/docs/style.css @@ -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] */ \ No newline at end of file diff --git a/dist/samples/geocoding-region-es/jsfiddle/demo.css b/dist/samples/geocoding-region-es/jsfiddle/demo.css new file mode 100644 index 00000000..f488152d --- /dev/null +++ b/dist/samples/geocoding-region-es/jsfiddle/demo.css @@ -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; +} + diff --git a/dist/samples/geocoding-region-es/jsfiddle/demo.details b/dist/samples/geocoding-region-es/jsfiddle/demo.details new file mode 100644 index 00000000..c17a03a0 --- /dev/null +++ b/dist/samples/geocoding-region-es/jsfiddle/demo.details @@ -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. diff --git a/dist/samples/geocoding-region-es/jsfiddle/demo.html b/dist/samples/geocoding-region-es/jsfiddle/demo.html new file mode 100644 index 00000000..9b1c909e --- /dev/null +++ b/dist/samples/geocoding-region-es/jsfiddle/demo.html @@ -0,0 +1,22 @@ + + + + + + Geocoding Region - ES + + + + + + + + + + + diff --git a/dist/samples/geocoding-region-es/jsfiddle/demo.js b/dist/samples/geocoding-region-es/jsfiddle/demo.js new file mode 100644 index 00000000..343c2fc9 --- /dev/null +++ b/dist/samples/geocoding-region-es/jsfiddle/demo.js @@ -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(); + diff --git a/index.html b/index.html index 006b2267..528d0631 100644 --- a/index.html +++ b/index.html @@ -89,6 +89,7 @@

    Maps JSAPI Samples

  • event-simple
  • geocoding-component-restriction
  • geocoding-place-id
  • +
  • geocoding-region-es
  • geocoding-region-us
  • geocoding-reverse
  • geocoding-simple
  • diff --git a/package-lock.json b/package-lock.json index 87b3645e..189335d1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -743,6 +743,10 @@ "resolved": "samples/geocoding-place-id", "link": true }, + "node_modules/@js-api-samples/geocoding-region-es": { + "resolved": "samples/geocoding-region-es", + "link": true + }, "node_modules/@js-api-samples/geocoding-region-us": { "resolved": "samples/geocoding-region-us", "link": true @@ -5665,6 +5669,10 @@ "name": "@js-api-samples/geocoding-place-id", "version": "1.0.0" }, + "samples/geocoding-region-es": { + "name": "@js-api-samples/geocoding-region-es", + "version": "1.0.0" + }, "samples/geocoding-region-us": { "name": "@js-api-samples/geocoding-region-us", "version": "1.0.0"