diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index b84b08e205..653a59785b 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -66,7 +66,7 @@ jobs: env: CI: true - name: Push test report to artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: failure() with: name: Test Results diff --git a/dist/index.html b/dist/index.html index cd99e5dd78..9bd9adf22f 100644 --- a/dist/index.html +++ b/dist/index.html @@ -4284,6 +4284,64 @@
Click on the map to add markers.
@@ -23,10 +22,10 @@Click on the map to add markers.
- - + +Click on the map to add markers.
+ @@ -20,10 +20,10 @@Click on the map to add markers.
+ @@ -16,10 +15,10 @@ @@ -17,10 +16,10 @@ - - + + + + @@ -16,10 +15,10 @@ @@ -17,10 +16,10 @@ - - + + + + @@ -16,10 +15,10 @@ @@ -17,10 +16,10 @@ - - + + + + @@ -16,10 +15,10 @@ @@ -17,10 +16,10 @@ - - + + + + @@ -16,10 +15,10 @@ @@ -17,10 +16,10 @@ - - + + @@ -15,10 +14,10 @@ @@ -16,10 +15,10 @@ @@ -17,10 +16,10 @@ - - + + + + @@ -17,10 +16,10 @@
+
+
+
+
+
diff --git a/dist/samples/place-autocomplete-data-session/app/index.ts b/dist/samples/place-autocomplete-data-session/app/index.ts
new file mode 100644
index 0000000000..8b2817a873
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-session/app/index.ts
@@ -0,0 +1,95 @@
+/**
+ * @license
+ * Copyright 2024 Google LLC. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+let title;
+let results;
+let input;
+let token;
+
+// Add an initial request body.
+let request = {
+ input: "",
+ locationRestriction: { west: -122.44, north: 37.8, east: -122.39, south: 37.78 },
+ origin: { lat: 37.7893, lng: -122.4039 },
+ includedPrimaryTypes: ["restaurant"],
+ language: "en-US",
+ region: "us",
+};
+
+async function init() {
+ token = new google.maps.places.AutocompleteSessionToken();
+
+ title = document.getElementById('title');
+ results = document.getElementById('results');
+ input = document.querySelector("input");
+ input.addEventListener("input", makeAcRequest);
+ request = refreshToken(request) as any;
+}
+
+async function makeAcRequest(input) {
+ // Reset elements and exit if an empty string is received.
+ if (input.target.value == '') {
+ title.innerText = '';
+ results.replaceChildren();
+ return;
+ }
+
+ // Add the latest char sequence to the request.
+ request.input = input.target.value;
+
+ // Fetch autocomplete suggestions and show them in a list.
+ // @ts-ignore
+ const { suggestions } = await google.maps.places.AutocompleteSuggestion.fetchAutocompleteSuggestions(request);
+
+ title.innerText = 'Query predictions for "' + request.input + '"';
+
+ // Clear the list first.
+ results.replaceChildren();
+
+ for (const suggestion of suggestions) {
+ const placePrediction = suggestion.placePrediction;
+
+ // Create a link for the place, add an event handler to fetch the place.
+ const a = document.createElement('a');
+ a.addEventListener('click', () => {
+ onPlaceSelected(placePrediction!.toPlace());
+ });
+ a.innerText = placePrediction!.text.toString();
+
+ // Create a new list element.
+ const li = document.createElement('li');
+ li.appendChild(a);
+ results.appendChild(li);
+ }
+}
+
+// Event handler for clicking on a suggested place.
+async function onPlaceSelected(place) {
+ await place.fetchFields({
+ fields: ['displayName', 'formattedAddress'],
+ });
+ let placeText = document.createTextNode(place.displayName + ': ' + place.formattedAddress);
+ results.replaceChildren(placeText);
+ title.innerText = 'Selected Place:';
+ input.value = '';
+ refreshToken(request);
+}
+
+// Helper function to refresh the session token.
+async function refreshToken(request) {
+ // Create a new session token and add it to the request.
+ token = new google.maps.places.AutocompleteSessionToken();
+ request.sessionToken = token;
+ return request;
+}
+
+declare global {
+ interface Window {
+ init: () => void;
+ }
+ }
+ window.init = init;
+export { };
\ No newline at end of file
diff --git a/dist/samples/place-autocomplete-data-session/app/package.json b/dist/samples/place-autocomplete-data-session/app/package.json
new file mode 100644
index 0000000000..3de8d10425
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-session/app/package.json
@@ -0,0 +1,35 @@
+{
+ "name": "place-autocomplete-data-session",
+ "description": "Samples for Google Maps JavaScript",
+ "version": "2.1.4",
+ "keywords": [
+ "google",
+ "javascript",
+ "maps",
+ "samples"
+ ],
+ "homepage": "https://github.com/googlemaps/js-samples#readme",
+ "bugs": {
+ "url": "https://github.com/googlemaps/js-samples/issues"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/googlemaps/js-samples.git"
+ },
+ "files": [],
+ "license": "Apache-2.0",
+ "scripts": {
+ "dev": "vite",
+ "start": "vite",
+ "build": "vite build --outDir dist --base './'",
+ "test": "tsc --no-emit",
+ "preview": "vite preview"
+ },
+ "devDependencies": {
+ "@types/google.maps": "^3.53.5",
+ "typescript": "^5.5.3",
+ "vite": "^5.4.6"
+ },
+ "private": true,
+ "dependencies": {}
+}
\ No newline at end of file
diff --git a/dist/samples/place-autocomplete-data-session/app/style.css b/dist/samples/place-autocomplete-data-session/app/style.css
new file mode 100644
index 0000000000..d3245cacbd
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-session/app/style.css
@@ -0,0 +1,33 @@
+/**
+ * @license
+ * Copyright 2019 Google LLC. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0
+ */
+/*
+ * Always set the map height explicitly to define the size of the div element
+ * that contains the map.
+ */
+#map {
+ height: 100%;
+}
+
+/*
+ * Optional: Makes the sample page fill the window.
+ */
+html,
+body {
+ height: 100%;
+ margin: 0;
+ padding: 0;
+}
+
+a {
+ cursor: pointer;
+ text-decoration: underline;
+ color: blue;
+}
+
+input {
+ width: 300px;
+}
+
diff --git a/dist/samples/place-autocomplete-data-session/app/tsconfig.json b/dist/samples/place-autocomplete-data-session/app/tsconfig.json
new file mode 100644
index 0000000000..b405998dad
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-session/app/tsconfig.json
@@ -0,0 +1,16 @@
+{
+ "compilerOptions": {
+ "module": "esnext",
+ "target": "esnext",
+ "strict": true,
+ "noImplicitAny": false,
+ "lib": [
+ "esnext",
+ "es6",
+ "dom",
+ "dom.iterable"
+ ],
+ "moduleResolution": "Node",
+ "jsx": "preserve"
+ }
+}
\ No newline at end of file
diff --git a/dist/samples/place-autocomplete-data-session/app/vite.config.js b/dist/samples/place-autocomplete-data-session/app/vite.config.js
new file mode 100644
index 0000000000..d49e45cd7e
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-session/app/vite.config.js
@@ -0,0 +1,11 @@
+import { defineConfig } from "vite";
+
+// https://vitejs.dev/config/
+export default defineConfig({
+ server: {
+ hmr:
+ process.env.CODESANDBOX_SSE || process.env.GITPOD_WORKSPACE_ID
+ ? 443
+ : undefined,
+ },
+});
diff --git a/dist/samples/place-autocomplete-data-session/docs/index.html b/dist/samples/place-autocomplete-data-session/docs/index.html
new file mode 100644
index 0000000000..3fd5df3f21
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-session/docs/index.html
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dist/samples/place-autocomplete-data-session/docs/index.js b/dist/samples/place-autocomplete-data-session/docs/index.js
new file mode 100644
index 0000000000..fead582dbb
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-session/docs/index.js
@@ -0,0 +1,100 @@
+/**
+ * @license
+ * Copyright 2024 Google LLC. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0
+ */
+// [START maps_place_autocomplete_data_session]
+let title;
+let results;
+let input;
+let token;
+// Add an initial request body.
+let request = {
+ input: "",
+ locationRestriction: {
+ west: -122.44,
+ north: 37.8,
+ east: -122.39,
+ south: 37.78,
+ },
+ origin: { lat: 37.7893, lng: -122.4039 },
+ includedPrimaryTypes: ["restaurant"],
+ language: "en-US",
+ region: "us",
+};
+
+async function init() {
+ token = new google.maps.places.AutocompleteSessionToken();
+ title = document.getElementById("title");
+ results = document.getElementById("results");
+ input = document.querySelector("input");
+ input.addEventListener("input", makeAcRequest);
+ request = refreshToken(request);
+}
+
+async function makeAcRequest(input) {
+ // Reset elements and exit if an empty string is received.
+ if (input.target.value == "") {
+ title.innerText = "";
+ results.replaceChildren();
+ return;
+ }
+
+ // Add the latest char sequence to the request.
+ request.input = input.target.value;
+
+ // Fetch autocomplete suggestions and show them in a list.
+ // @ts-ignore
+ const { suggestions } =
+ await google.maps.places.AutocompleteSuggestion.fetchAutocompleteSuggestions(
+ request,
+ );
+
+ title.innerText = 'Query predictions for "' + request.input + '"';
+ // Clear the list first.
+ results.replaceChildren();
+
+ for (const suggestion of suggestions) {
+ const placePrediction = suggestion.placePrediction;
+ // Create a link for the place, add an event handler to fetch the place.
+ const a = document.createElement("a");
+
+ a.addEventListener("click", () => {
+ onPlaceSelected(placePrediction.toPlace());
+ });
+ a.innerText = placePrediction.text.toString();
+
+ // Create a new list element.
+ const li = document.createElement("li");
+
+ li.appendChild(a);
+ results.appendChild(li);
+ }
+}
+
+// Event handler for clicking on a suggested place.
+async function onPlaceSelected(place) {
+ await place.fetchFields({
+ fields: ["displayName", "formattedAddress"],
+ });
+
+ let placeText = document.createTextNode(
+ place.displayName + ": " + place.formattedAddress,
+ );
+
+ results.replaceChildren(placeText);
+ title.innerText = "Selected Place:";
+ input.value = "";
+ refreshToken(request);
+}
+
+// Helper function to refresh the session token.
+async function refreshToken(request) {
+ // Create a new session token and add it to the request.
+ token = new google.maps.places.AutocompleteSessionToken();
+ request.sessionToken = token;
+ return request;
+}
+
+window.init = init;
+// [END maps_place_autocomplete_data_session]
diff --git a/dist/samples/place-autocomplete-data-session/docs/style.css b/dist/samples/place-autocomplete-data-session/docs/style.css
new file mode 100644
index 0000000000..3f89029133
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-session/docs/style.css
@@ -0,0 +1,35 @@
+/**
+ * @license
+ * Copyright 2019 Google LLC. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0
+ */
+/* [START maps_place_autocomplete_data_session] */
+/*
+ * Always set the map height explicitly to define the size of the div element
+ * that contains the map.
+ */
+#map {
+ height: 100%;
+}
+
+/*
+ * Optional: Makes the sample page fill the window.
+ */
+html,
+body {
+ height: 100%;
+ margin: 0;
+ padding: 0;
+}
+
+a {
+ cursor: pointer;
+ text-decoration: underline;
+ color: blue;
+}
+
+input {
+ width: 300px;
+}
+
+/* [END maps_place_autocomplete_data_session] */
\ No newline at end of file
diff --git a/dist/samples/place-autocomplete-data-session/iframe/index.html b/dist/samples/place-autocomplete-data-session/iframe/index.html
new file mode 100644
index 0000000000..dcb02e39a9
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-session/iframe/index.html
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/dist/samples/place-autocomplete-data-session/jsfiddle/demo.css b/dist/samples/place-autocomplete-data-session/jsfiddle/demo.css
new file mode 100644
index 0000000000..d3245cacbd
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-session/jsfiddle/demo.css
@@ -0,0 +1,33 @@
+/**
+ * @license
+ * Copyright 2019 Google LLC. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0
+ */
+/*
+ * Always set the map height explicitly to define the size of the div element
+ * that contains the map.
+ */
+#map {
+ height: 100%;
+}
+
+/*
+ * Optional: Makes the sample page fill the window.
+ */
+html,
+body {
+ height: 100%;
+ margin: 0;
+ padding: 0;
+}
+
+a {
+ cursor: pointer;
+ text-decoration: underline;
+ color: blue;
+}
+
+input {
+ width: 300px;
+}
+
diff --git a/dist/samples/place-autocomplete-data-session/jsfiddle/demo.details b/dist/samples/place-autocomplete-data-session/jsfiddle/demo.details
new file mode 100644
index 0000000000..273703e93e
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-session/jsfiddle/demo.details
@@ -0,0 +1,7 @@
+name: Place Autocomplete Data API Session
+authors:
+ - Justin Poehnelt
+tags:
+ - google maps
+load_type: h
+description: Sample code for Google Maps Platform JavaScript API
diff --git a/dist/samples/place-autocomplete-data-session/jsfiddle/demo.html b/dist/samples/place-autocomplete-data-session/jsfiddle/demo.html
new file mode 100644
index 0000000000..9fad214a50
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-session/jsfiddle/demo.html
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/dist/samples/place-autocomplete-data-session/jsfiddle/demo.js b/dist/samples/place-autocomplete-data-session/jsfiddle/demo.js
new file mode 100644
index 0000000000..e4a804a0a9
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-session/jsfiddle/demo.js
@@ -0,0 +1,98 @@
+/**
+ * @license
+ * Copyright 2024 Google LLC. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0
+ */
+let title;
+let results;
+let input;
+let token;
+// Add an initial request body.
+let request = {
+ input: "",
+ locationRestriction: {
+ west: -122.44,
+ north: 37.8,
+ east: -122.39,
+ south: 37.78,
+ },
+ origin: { lat: 37.7893, lng: -122.4039 },
+ includedPrimaryTypes: ["restaurant"],
+ language: "en-US",
+ region: "us",
+};
+
+async function init() {
+ token = new google.maps.places.AutocompleteSessionToken();
+ title = document.getElementById("title");
+ results = document.getElementById("results");
+ input = document.querySelector("input");
+ input.addEventListener("input", makeAcRequest);
+ request = refreshToken(request);
+}
+
+async function makeAcRequest(input) {
+ // Reset elements and exit if an empty string is received.
+ if (input.target.value == "") {
+ title.innerText = "";
+ results.replaceChildren();
+ return;
+ }
+
+ // Add the latest char sequence to the request.
+ request.input = input.target.value;
+
+ // Fetch autocomplete suggestions and show them in a list.
+ // @ts-ignore
+ const { suggestions } =
+ await google.maps.places.AutocompleteSuggestion.fetchAutocompleteSuggestions(
+ request,
+ );
+
+ title.innerText = 'Query predictions for "' + request.input + '"';
+ // Clear the list first.
+ results.replaceChildren();
+
+ for (const suggestion of suggestions) {
+ const placePrediction = suggestion.placePrediction;
+ // Create a link for the place, add an event handler to fetch the place.
+ const a = document.createElement("a");
+
+ a.addEventListener("click", () => {
+ onPlaceSelected(placePrediction.toPlace());
+ });
+ a.innerText = placePrediction.text.toString();
+
+ // Create a new list element.
+ const li = document.createElement("li");
+
+ li.appendChild(a);
+ results.appendChild(li);
+ }
+}
+
+// Event handler for clicking on a suggested place.
+async function onPlaceSelected(place) {
+ await place.fetchFields({
+ fields: ["displayName", "formattedAddress"],
+ });
+
+ let placeText = document.createTextNode(
+ place.displayName + ": " + place.formattedAddress,
+ );
+
+ results.replaceChildren(placeText);
+ title.innerText = "Selected Place:";
+ input.value = "";
+ refreshToken(request);
+}
+
+// Helper function to refresh the session token.
+async function refreshToken(request) {
+ // Create a new session token and add it to the request.
+ token = new google.maps.places.AutocompleteSessionToken();
+ request.sessionToken = token;
+ return request;
+}
+
+window.init = init;
diff --git a/dist/samples/place-autocomplete-data-session/playground/index.html b/dist/samples/place-autocomplete-data-session/playground/index.html
new file mode 100644
index 0000000000..891575eb65
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-session/playground/index.html
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
diff --git a/dist/samples/place-autocomplete-data-session/playground/index.ts b/dist/samples/place-autocomplete-data-session/playground/index.ts
new file mode 100644
index 0000000000..baa341a713
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-session/playground/index.ts
@@ -0,0 +1,99 @@
+let title;
+let results;
+let input;
+let token;
+
+// Add an initial request body.
+let request = {
+ input: "",
+ locationRestriction: {
+ west: -122.44,
+ north: 37.8,
+ east: -122.39,
+ south: 37.78,
+ },
+ origin: { lat: 37.7893, lng: -122.4039 },
+ includedPrimaryTypes: ["restaurant"],
+ language: "en-US",
+ region: "us",
+};
+
+async function init() {
+ token = new google.maps.places.AutocompleteSessionToken();
+
+ title = document.getElementById("title");
+ results = document.getElementById("results");
+ input = document.querySelector("input");
+ input.addEventListener("input", makeAcRequest);
+ request = refreshToken(request) as any;
+}
+
+async function makeAcRequest(input) {
+ // Reset elements and exit if an empty string is received.
+ if (input.target.value == "") {
+ title.innerText = "";
+ results.replaceChildren();
+ return;
+ }
+
+ // Add the latest char sequence to the request.
+ request.input = input.target.value;
+
+ // Fetch autocomplete suggestions and show them in a list.
+ // @ts-ignore
+ const { suggestions } =
+ await google.maps.places.AutocompleteSuggestion.fetchAutocompleteSuggestions(
+ request,
+ );
+
+ title.innerText = 'Query predictions for "' + request.input + '"';
+
+ // Clear the list first.
+ results.replaceChildren();
+
+ for (const suggestion of suggestions) {
+ const placePrediction = suggestion.placePrediction;
+
+ // Create a link for the place, add an event handler to fetch the place.
+ const a = document.createElement("a");
+ a.addEventListener("click", () => {
+ onPlaceSelected(placePrediction!.toPlace());
+ });
+ a.innerText = placePrediction!.text.toString();
+
+ // Create a new list element.
+ const li = document.createElement("li");
+ li.appendChild(a);
+ results.appendChild(li);
+ }
+}
+
+// Event handler for clicking on a suggested place.
+async function onPlaceSelected(place) {
+ await place.fetchFields({
+ fields: ["displayName", "formattedAddress"],
+ });
+ let placeText = document.createTextNode(
+ place.displayName + ": " + place.formattedAddress,
+ );
+ results.replaceChildren(placeText);
+ title.innerText = "Selected Place:";
+ input.value = "";
+ refreshToken(request);
+}
+
+// Helper function to refresh the session token.
+async function refreshToken(request) {
+ // Create a new session token and add it to the request.
+ token = new google.maps.places.AutocompleteSessionToken();
+ request.sessionToken = token;
+ return request;
+}
+
+declare global {
+ interface Window {
+ init: () => void;
+ }
+}
+window.init = init;
+export {};
diff --git a/dist/samples/place-autocomplete-data-session/playground/package.json b/dist/samples/place-autocomplete-data-session/playground/package.json
new file mode 100644
index 0000000000..33703d5822
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-session/playground/package.json
@@ -0,0 +1,3 @@
+{
+ "dependencies": {}
+}
\ No newline at end of file
diff --git a/dist/samples/place-autocomplete-data-session/playground/playground.ts.json b/dist/samples/place-autocomplete-data-session/playground/playground.ts.json
new file mode 100644
index 0000000000..dfc32121fc
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-session/playground/playground.ts.json
@@ -0,0 +1,17 @@
+{
+ "files": {
+ "index.ts": {
+ "label": "TypeScript"
+ },
+ "style.css": {
+ "label": "CSS"
+ },
+ "index.html": {
+ "label": "HTML"
+ },
+ "../../../types/google-maps/index.d.ts": {
+ "label": "@types/google.maps",
+ "hidden": true
+ }
+ }
+}
\ No newline at end of file
diff --git a/dist/samples/place-autocomplete-data-session/playground/style.css b/dist/samples/place-autocomplete-data-session/playground/style.css
new file mode 100644
index 0000000000..fe4bb863a4
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-session/playground/style.css
@@ -0,0 +1,28 @@
+/*
+ * Always set the map height explicitly to define the size of the div element
+ * that contains the map.
+ */
+#map {
+ height: 100%;
+}
+
+/*
+ * Optional: Makes the sample page fill the window.
+ */
+html,
+body {
+ height: 100%;
+ margin: 0;
+ padding: 0;
+}
+
+a {
+ cursor: pointer;
+ text-decoration: underline;
+ color: blue;
+}
+
+input {
+ width: 300px;
+}
+
diff --git a/dist/samples/place-autocomplete-data-simple/app/.env b/dist/samples/place-autocomplete-data-simple/app/.env
new file mode 100644
index 0000000000..d7474dcb8b
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-simple/app/.env
@@ -0,0 +1 @@
+VITE_GOOGLE_MAPS_API_KEY=AIzaSyB41DRUbKWJHPxaFjMAwdrzWzbVKartNGg
\ No newline at end of file
diff --git a/dist/samples/place-autocomplete-data-simple/app/.eslintrc.json b/dist/samples/place-autocomplete-data-simple/app/.eslintrc.json
new file mode 100644
index 0000000000..841a372aa2
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-simple/app/.eslintrc.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
+ }
+}
\ No newline at end of file
diff --git a/dist/samples/place-autocomplete-data-simple/app/.gitignore b/dist/samples/place-autocomplete-data-simple/app/.gitignore
new file mode 100644
index 0000000000..10ec766622
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-simple/app/.gitignore
@@ -0,0 +1,4 @@
+
+node_modules
+dist
+package-lock.json
diff --git a/dist/samples/place-autocomplete-data-simple/app/README.md b/dist/samples/place-autocomplete-data-simple/app/README.md
new file mode 100644
index 0000000000..012fc1859f
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-simple/app/README.md
@@ -0,0 +1,17 @@
+# Google Maps JavaScript Sample
+
+This sample is generated from @googlemaps/js-samples located at
+https://github.com/googlemaps/js-samples.
+
+## Setup
+
+```sh
+npm i
+npm start # development
+npm run build # production
+```
+
+## Feedback
+
+For feedback related to this sample, please open a new issue on
+[GitHub](https://github.com/googlemaps/js-samples/issues).
diff --git a/dist/samples/place-autocomplete-data-simple/app/env.d.ts b/dist/samples/place-autocomplete-data-simple/app/env.d.ts
new file mode 100644
index 0000000000..2d29a7a6be
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-simple/app/env.d.ts
@@ -0,0 +1,12 @@
+/// +
+
+
+
+
+
diff --git a/dist/samples/place-autocomplete-data-simple/app/index.ts b/dist/samples/place-autocomplete-data-simple/app/index.ts
new file mode 100644
index 0000000000..c479d38d5d
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-simple/app/index.ts
@@ -0,0 +1,56 @@
+/**
+ * @license
+ * Copyright 2024 Google LLC. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**
+ * Demonstrates making a single request for Place predictions, then requests Place Details for the first result.
+ */
+async function init() {
+ // @ts-ignore
+ const { Place, AutocompleteSessionToken, AutocompleteSuggestion } = await google.maps.importLibrary("places") as google.maps.PlacesLibrary;
+
+ // Add an initial request body.
+ let request = {
+ input: "Tadi",
+ locationRestriction: { west: -122.44, north: 37.8, east: -122.39, south: 37.78 },
+ origin: { lat: 37.7893, lng: -122.4039 },
+ includedPrimaryTypes: ["restaurant"],
+ language: "en-US",
+ region: "us",
+ };
+
+ // Create a session token.
+ const token = new AutocompleteSessionToken();
+ // Add the token to the request.
+ // @ts-ignore
+ request.sessionToken = token;
+ // Fetch autocomplete suggestions.
+ const { suggestions } = await AutocompleteSuggestion.fetchAutocompleteSuggestions(request);
+
+ const title = document.getElementById('title') as HTMLElement;
+ title.appendChild(document.createTextNode('Query predictions for "' + request.input + '":'));
+
+ for (let suggestion of suggestions) {
+ const placePrediction = suggestion.placePrediction;
+
+ // Create a new list element.
+ const listItem = document.createElement('li');
+ const resultsElement = document.getElementById("results") as HTMLElement;
+ listItem.appendChild(document.createTextNode(placePrediction.text.toString()));
+ resultsElement.appendChild(listItem);
+ }
+
+ let place = suggestions[0].placePrediction.toPlace(); // Get first predicted place.
+ await place.fetchFields({
+ fields: ['displayName', 'formattedAddress'],
+ });
+
+ const placeInfo = document.getElementById("prediction") as HTMLElement;
+ placeInfo.textContent = 'First predicted place: ' + place.displayName + ': ' + place.formattedAddress;
+
+}
+
+init();
+export { };
diff --git a/dist/samples/place-autocomplete-data-simple/app/package.json b/dist/samples/place-autocomplete-data-simple/app/package.json
new file mode 100644
index 0000000000..683cc14d0a
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-simple/app/package.json
@@ -0,0 +1,35 @@
+{
+ "name": "place-autocomplete-data-simple",
+ "description": "Samples for Google Maps JavaScript",
+ "version": "2.1.4",
+ "keywords": [
+ "google",
+ "javascript",
+ "maps",
+ "samples"
+ ],
+ "homepage": "https://github.com/googlemaps/js-samples#readme",
+ "bugs": {
+ "url": "https://github.com/googlemaps/js-samples/issues"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/googlemaps/js-samples.git"
+ },
+ "files": [],
+ "license": "Apache-2.0",
+ "scripts": {
+ "dev": "vite",
+ "start": "vite",
+ "build": "vite build --outDir dist --base './'",
+ "test": "tsc --no-emit",
+ "preview": "vite preview"
+ },
+ "devDependencies": {
+ "@types/google.maps": "^3.53.5",
+ "typescript": "^5.5.3",
+ "vite": "^5.4.6"
+ },
+ "private": true,
+ "dependencies": {}
+}
\ No newline at end of file
diff --git a/dist/samples/place-autocomplete-data-simple/app/style.css b/dist/samples/place-autocomplete-data-simple/app/style.css
new file mode 100644
index 0000000000..c97e14e569
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-simple/app/style.css
@@ -0,0 +1,23 @@
+/**
+ * @license
+ * Copyright 2019 Google LLC. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0
+ */
+/*
+ * Always set the map height explicitly to define the size of the div element
+ * that contains the map.
+ */
+#map {
+ height: 100%;
+}
+
+/*
+ * Optional: Makes the sample page fill the window.
+ */
+html,
+body {
+ height: 100%;
+ margin: 0;
+ padding: 0;
+}
+
diff --git a/dist/samples/place-autocomplete-data-simple/app/tsconfig.json b/dist/samples/place-autocomplete-data-simple/app/tsconfig.json
new file mode 100644
index 0000000000..b405998dad
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-simple/app/tsconfig.json
@@ -0,0 +1,16 @@
+{
+ "compilerOptions": {
+ "module": "esnext",
+ "target": "esnext",
+ "strict": true,
+ "noImplicitAny": false,
+ "lib": [
+ "esnext",
+ "es6",
+ "dom",
+ "dom.iterable"
+ ],
+ "moduleResolution": "Node",
+ "jsx": "preserve"
+ }
+}
\ No newline at end of file
diff --git a/dist/samples/place-autocomplete-data-simple/app/vite.config.js b/dist/samples/place-autocomplete-data-simple/app/vite.config.js
new file mode 100644
index 0000000000..d49e45cd7e
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-simple/app/vite.config.js
@@ -0,0 +1,11 @@
+import { defineConfig } from "vite";
+
+// https://vitejs.dev/config/
+export default defineConfig({
+ server: {
+ hmr:
+ process.env.CODESANDBOX_SSE || process.env.GITPOD_WORKSPACE_ID
+ ? 443
+ : undefined,
+ },
+});
diff --git a/dist/samples/place-autocomplete-data-simple/docs/index.html b/dist/samples/place-autocomplete-data-simple/docs/index.html
new file mode 100644
index 0000000000..4ef2f47f63
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-simple/docs/index.html
@@ -0,0 +1,32 @@
+
+
+
+
+
+ +
+
+
+
+
+
+
+
diff --git a/dist/samples/place-autocomplete-data-simple/docs/index.js b/dist/samples/place-autocomplete-data-simple/docs/index.js
new file mode 100644
index 0000000000..1851a7d6a3
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-simple/docs/index.js
@@ -0,0 +1,84 @@
+/**
+ * @license
+ * Copyright 2024 Google LLC. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0
+ */
+// [START maps_place_autocomplete_data_simple]
+/**
+ * Demonstrates making a single request for Place predictions, then requests Place Details for the first result.
+ */
+async function init() {
+ // @ts-ignore
+ const { Place, AutocompleteSessionToken, AutocompleteSuggestion } =
+ await google.maps.importLibrary("places");
+ // [START maps_place_autocomplete_data_simple_request]
+ // Add an initial request body.
+ // [START maps_place_autocomplete_data_simple_request_body]
+ let request = {
+ input: "Tadi",
+ locationRestriction: {
+ west: -122.44,
+ north: 37.8,
+ east: -122.39,
+ south: 37.78,
+ },
+ origin: { lat: 37.7893, lng: -122.4039 },
+ includedPrimaryTypes: ["restaurant"],
+ language: "en-US",
+ region: "us",
+ };
+ // [END maps_place_autocomplete_data_simple_request_body]
+ // [START maps_place_autocomplete_data_simple_token]
+ // Create a session token.
+ const token = new AutocompleteSessionToken();
+
+ // Add the token to the request.
+ // @ts-ignore
+ request.sessionToken = token;
+
+ // [END maps_place_autocomplete_data_simple_token]
+ // [END maps_place_autocomplete_data_simple_request]
+ // [START maps_place_autocomplete_data_simple_get_suggestions]
+ // Fetch autocomplete suggestions.
+ const { suggestions } =
+ await AutocompleteSuggestion.fetchAutocompleteSuggestions(request);
+ const title = document.getElementById("title");
+
+ title.appendChild(
+ document.createTextNode('Query predictions for "' + request.input + '":'),
+ );
+
+ for (let suggestion of suggestions) {
+ const placePrediction = suggestion.placePrediction;
+ // Create a new list element.
+ const listItem = document.createElement("li");
+ const resultsElement = document.getElementById("results");
+
+ listItem.appendChild(
+ document.createTextNode(placePrediction.text.toString()),
+ );
+ resultsElement.appendChild(listItem);
+ }
+
+ // [END maps_place_autocomplete_data_simple_get_suggestions]
+ // [START maps_place_autocomplete_data_simple_prediction]
+ let place = suggestions[0].placePrediction.toPlace(); // Get first predicted place.
+
+ // [START maps_place_autocomplete_data_simple_fetch]
+ await place.fetchFields({
+ fields: ["displayName", "formattedAddress"],
+ });
+
+ // [END maps_place_autocomplete_data_simple_fetch]
+ const placeInfo = document.getElementById("prediction");
+
+ placeInfo.textContent =
+ "First predicted place: " +
+ place.displayName +
+ ": " +
+ place.formattedAddress;
+ // [END maps_place_autocomplete_data_simple_prediction]
+}
+
+init();
+// [END maps_place_autocomplete_data_simple]
diff --git a/dist/samples/place-autocomplete-data-simple/docs/style.css b/dist/samples/place-autocomplete-data-simple/docs/style.css
new file mode 100644
index 0000000000..a4ee062627
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-simple/docs/style.css
@@ -0,0 +1,25 @@
+/**
+ * @license
+ * Copyright 2019 Google LLC. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0
+ */
+/* [START maps_place_autocomplete_data_simple] */
+/*
+ * Always set the map height explicitly to define the size of the div element
+ * that contains the map.
+ */
+#map {
+ height: 100%;
+}
+
+/*
+ * Optional: Makes the sample page fill the window.
+ */
+html,
+body {
+ height: 100%;
+ margin: 0;
+ padding: 0;
+}
+
+/* [END maps_place_autocomplete_data_simple] */
\ No newline at end of file
diff --git a/dist/samples/place-autocomplete-data-simple/iframe/index.html b/dist/samples/place-autocomplete-data-simple/iframe/index.html
new file mode 100644
index 0000000000..832c4f38a5
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-simple/iframe/index.html
@@ -0,0 +1,28 @@
+
+
+
+
+ +
+
+
+
+
+
diff --git a/dist/samples/place-autocomplete-data-simple/jsfiddle/demo.css b/dist/samples/place-autocomplete-data-simple/jsfiddle/demo.css
new file mode 100644
index 0000000000..c97e14e569
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-simple/jsfiddle/demo.css
@@ -0,0 +1,23 @@
+/**
+ * @license
+ * Copyright 2019 Google LLC. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0
+ */
+/*
+ * Always set the map height explicitly to define the size of the div element
+ * that contains the map.
+ */
+#map {
+ height: 100%;
+}
+
+/*
+ * Optional: Makes the sample page fill the window.
+ */
+html,
+body {
+ height: 100%;
+ margin: 0;
+ padding: 0;
+}
+
diff --git a/dist/samples/place-autocomplete-data-simple/jsfiddle/demo.details b/dist/samples/place-autocomplete-data-simple/jsfiddle/demo.details
new file mode 100644
index 0000000000..f7ab25979e
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-simple/jsfiddle/demo.details
@@ -0,0 +1,7 @@
+name: Place Autocomplete Data API Predictions
+authors:
+ - Justin Poehnelt
+tags:
+ - google maps
+load_type: h
+description: Sample code for Google Maps Platform JavaScript API
diff --git a/dist/samples/place-autocomplete-data-simple/jsfiddle/demo.html b/dist/samples/place-autocomplete-data-simple/jsfiddle/demo.html
new file mode 100644
index 0000000000..888101865a
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-simple/jsfiddle/demo.html
@@ -0,0 +1,27 @@
+
+
+
+
+ +
+
+
+
+
+
diff --git a/dist/samples/place-autocomplete-data-simple/jsfiddle/demo.js b/dist/samples/place-autocomplete-data-simple/jsfiddle/demo.js
new file mode 100644
index 0000000000..5c734a26b9
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-simple/jsfiddle/demo.js
@@ -0,0 +1,70 @@
+/**
+ * @license
+ * Copyright 2024 Google LLC. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0
+ */
+/**
+ * Demonstrates making a single request for Place predictions, then requests Place Details for the first result.
+ */
+async function init() {
+ // @ts-ignore
+ const { Place, AutocompleteSessionToken, AutocompleteSuggestion } =
+ await google.maps.importLibrary("places");
+ // Add an initial request body.
+ let request = {
+ input: "Tadi",
+ locationRestriction: {
+ west: -122.44,
+ north: 37.8,
+ east: -122.39,
+ south: 37.78,
+ },
+ origin: { lat: 37.7893, lng: -122.4039 },
+ includedPrimaryTypes: ["restaurant"],
+ language: "en-US",
+ region: "us",
+ };
+ // Create a session token.
+ const token = new AutocompleteSessionToken();
+
+ // Add the token to the request.
+ // @ts-ignore
+ request.sessionToken = token;
+
+ // Fetch autocomplete suggestions.
+ const { suggestions } =
+ await AutocompleteSuggestion.fetchAutocompleteSuggestions(request);
+ const title = document.getElementById("title");
+
+ title.appendChild(
+ document.createTextNode('Query predictions for "' + request.input + '":'),
+ );
+
+ for (let suggestion of suggestions) {
+ const placePrediction = suggestion.placePrediction;
+ // Create a new list element.
+ const listItem = document.createElement("li");
+ const resultsElement = document.getElementById("results");
+
+ listItem.appendChild(
+ document.createTextNode(placePrediction.text.toString()),
+ );
+ resultsElement.appendChild(listItem);
+ }
+
+ let place = suggestions[0].placePrediction.toPlace(); // Get first predicted place.
+
+ await place.fetchFields({
+ fields: ["displayName", "formattedAddress"],
+ });
+
+ const placeInfo = document.getElementById("prediction");
+
+ placeInfo.textContent =
+ "First predicted place: " +
+ place.displayName +
+ ": " +
+ place.formattedAddress;
+}
+
+init();
diff --git a/dist/samples/place-autocomplete-data-simple/playground/index.html b/dist/samples/place-autocomplete-data-simple/playground/index.html
new file mode 100644
index 0000000000..95529381a3
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-simple/playground/index.html
@@ -0,0 +1,30 @@
+
+
+ +
+
+
+
+
+
diff --git a/dist/samples/place-autocomplete-data-simple/playground/index.ts b/dist/samples/place-autocomplete-data-simple/playground/index.ts
new file mode 100644
index 0000000000..87236cd8dc
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-simple/playground/index.ts
@@ -0,0 +1,64 @@
+/**
+ * Demonstrates making a single request for Place predictions, then requests Place Details for the first result.
+ */
+async function init() {
+ // @ts-ignore
+ const { Place, AutocompleteSessionToken, AutocompleteSuggestion } =
+ (await google.maps.importLibrary("places")) as google.maps.PlacesLibrary;
+
+ // Add an initial request body.
+ let request = {
+ input: "Tadi",
+ locationRestriction: {
+ west: -122.44,
+ north: 37.8,
+ east: -122.39,
+ south: 37.78,
+ },
+ origin: { lat: 37.7893, lng: -122.4039 },
+ includedPrimaryTypes: ["restaurant"],
+ language: "en-US",
+ region: "us",
+ };
+
+ // Create a session token.
+ const token = new AutocompleteSessionToken();
+ // Add the token to the request.
+ // @ts-ignore
+ request.sessionToken = token;
+ // Fetch autocomplete suggestions.
+ const { suggestions } =
+ await AutocompleteSuggestion.fetchAutocompleteSuggestions(request);
+
+ const title = document.getElementById("title") as HTMLElement;
+ title.appendChild(
+ document.createTextNode('Query predictions for "' + request.input + '":'),
+ );
+
+ for (let suggestion of suggestions) {
+ const placePrediction = suggestion.placePrediction;
+
+ // Create a new list element.
+ const listItem = document.createElement("li");
+ const resultsElement = document.getElementById("results") as HTMLElement;
+ listItem.appendChild(
+ document.createTextNode(placePrediction.text.toString()),
+ );
+ resultsElement.appendChild(listItem);
+ }
+
+ let place = suggestions[0].placePrediction.toPlace(); // Get first predicted place.
+ await place.fetchFields({
+ fields: ["displayName", "formattedAddress"],
+ });
+
+ const placeInfo = document.getElementById("prediction") as HTMLElement;
+ placeInfo.textContent =
+ "First predicted place: " +
+ place.displayName +
+ ": " +
+ place.formattedAddress;
+}
+
+init();
+export {};
diff --git a/dist/samples/place-autocomplete-data-simple/playground/package.json b/dist/samples/place-autocomplete-data-simple/playground/package.json
new file mode 100644
index 0000000000..33703d5822
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-simple/playground/package.json
@@ -0,0 +1,3 @@
+{
+ "dependencies": {}
+}
\ No newline at end of file
diff --git a/dist/samples/place-autocomplete-data-simple/playground/playground.ts.json b/dist/samples/place-autocomplete-data-simple/playground/playground.ts.json
new file mode 100644
index 0000000000..dfc32121fc
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-simple/playground/playground.ts.json
@@ -0,0 +1,17 @@
+{
+ "files": {
+ "index.ts": {
+ "label": "TypeScript"
+ },
+ "style.css": {
+ "label": "CSS"
+ },
+ "index.html": {
+ "label": "HTML"
+ },
+ "../../../types/google-maps/index.d.ts": {
+ "label": "@types/google.maps",
+ "hidden": true
+ }
+ }
+}
\ No newline at end of file
diff --git a/dist/samples/place-autocomplete-data-simple/playground/style.css b/dist/samples/place-autocomplete-data-simple/playground/style.css
new file mode 100644
index 0000000000..a8d59c808e
--- /dev/null
+++ b/dist/samples/place-autocomplete-data-simple/playground/style.css
@@ -0,0 +1,18 @@
+/*
+ * Always set the map height explicitly to define the size of the div element
+ * that contains the map.
+ */
+#map {
+ height: 100%;
+}
+
+/*
+ * Optional: Makes the sample page fill the window.
+ */
+html,
+body {
+ height: 100%;
+ margin: 0;
+ padding: 0;
+}
+
diff --git a/dist/samples/place-autocomplete-element/app/index.html b/dist/samples/place-autocomplete-element/app/index.html
index 7ff8e85a04..7e9bea96eb 100644
--- a/dist/samples/place-autocomplete-element/app/index.html
+++ b/dist/samples/place-autocomplete-element/app/index.html
@@ -7,7 +7,6 @@
Search for a place here:
diff --git a/dist/samples/place-autocomplete-element/jsfiddle/demo.html b/dist/samples/place-autocomplete-element/jsfiddle/demo.html index c9a4121800..8ad57bb2ba 100644 --- a/dist/samples/place-autocomplete-element/jsfiddle/demo.html +++ b/dist/samples/place-autocomplete-element/jsfiddle/demo.html @@ -7,7 +7,7 @@Review: ${reviewText}
Review: ${reviewText}
Review: ${reviewText}
Review: ${reviewText}
Query suggestions for 'pizza near Syd':
@@ -22,10 +21,10 @@ /> + @@ -21,10 +21,10 @@ /> + @@ -22,10 +21,10 @@ @@ -23,10 +22,10 @@ - - + + + @@ -20,10 +20,10 @@ + diff --git a/dist/samples/poly-containsLocation/app/index.html b/dist/samples/poly-containsLocation/app/index.html index d0e9ba99dc..9be91f98c3 100644 --- a/dist/samples/poly-containsLocation/app/index.html +++ b/dist/samples/poly-containsLocation/app/index.html @@ -7,7 +7,6 @@