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 @@ -43,6 +43,7 @@ <h1>Maps JSAPI Samples</h1>
<li><a href='/samples/place-autocomplete-element/dist'>place-autocomplete-element</a></li>
<li><a href='/samples/place-autocomplete-map/dist'>place-autocomplete-map</a></li>
<li><a href='/samples/place-text-search/dist'>place-text-search</a></li>
<li><a href='/samples/test-example/dist'>test-example</a></li>
<li><a href='/samples/ui-kit-customization/dist'>ui-kit-customization</a></li>
<li><a href='/samples/ui-kit-place-details/dist'>ui-kit-place-details</a></li>
<li><a href='/samples/ui-kit-place-details-compact/dist'>ui-kit-place-details-compact</a></li>
Expand Down
13 changes: 13 additions & 0 deletions dist/samples/test-example/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
}
}
33 changes: 33 additions & 0 deletions dist/samples/test-example/app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Google Maps JavaScript Sample

This sample is generated from @googlemaps/js-samples located at
https://github.com/googlemaps-samples/js-api-samples.

## Setup

### Before starting run:

`$npm i`

### Run an example on a local web server

First `cd` to the folder for the sample to run, then:

`$npm start`

### Build an individual example

From `samples/`:

`$npm run build --workspace=sample-name/`

### Build all of the examples.

From `samples/`:
`$npm run build-all`

## Feedback

For feedback related to this sample, please open a new issue on
[GitHub](https://github.com/googlemaps-samples/js-api-samples/issues).

27 changes: 27 additions & 0 deletions dist/samples/test-example/app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!doctype html>
<!--
@license
Copyright 2025 Google LLC. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
-->
<!--[START maps_test_example]-->
<html>
<head>
<title>Add a Map</title>

<link rel="stylesheet" type="text/css" href="./style.css" />
<script type="module" src="./index.js"></script>
</head>
<body>
<!--[START maps_test_example_heading]-->
<h3>My Google Maps Demo</h3>
<!--[END maps_test_example_heading]-->
<!--[START maps_test_example_body]-->
<div id="map"></div>
<!--[END maps_test_example_body]-->
<!-- 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"});</script>
</body>
</html>
<!--[END maps_test_example]-->
35 changes: 35 additions & 0 deletions dist/samples/test-example/app/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* @license
* Copyright 2025 Google LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

// [START maps_test_example]
// Initialize and add the map.
let map;
async function initMap(): Promise<void> {
// [START maps_test_example_instantiate_map]
// The location of Uluru, Australia.
const position = {lat: -25.344, lng: 131.031};

// Request the needed libraries.
const {Map} =
await google.maps.importLibrary('maps') as google.maps.MapsLibrary;
const {AdvancedMarkerElement} =
await google.maps.importLibrary('marker') as google.maps.MarkerLibrary;

// The map, centered at Uluru, Australia.
map = new Map(document.getElementById('map') as HTMLElement, {
zoom: 4,
center: position,
mapId: 'DEMO_MAP_ID',
});
// [END maps_test_example_instantiate_map]

// [START maps_test_example_instantiate_marker]
// The marker, positioned at Uluru.
const marker = new AdvancedMarkerElement({map, position, title: 'Uluru'});
// [END maps_test_example_instantiate_marker]
}
initMap();
// [END maps_test_example]
14 changes: 14 additions & 0 deletions dist/samples/test-example/app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "@js-api-samples/test-example",
"version": "1.0.0",
"scripts": {
"build": "tsc && bash ../jsfiddle.sh test-example && bash ../app.sh test-example && bash ../docs.sh test-example && npm run build:vite --workspace=. && bash ../dist.sh test-example",
"test": "tsc && npm run build:vite --workspace=.",
"start": "tsc && vite build --base './' && vite",
"build:vite": "vite build --base './'",
"preview": "vite preview"
},
"dependencies": {

}
}
25 changes: 25 additions & 0 deletions dist/samples/test-example/app/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* @license
* Copyright 2025 Google LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
/* [START maps_test_example] */
/*
* 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_test_example] */

17 changes: 17 additions & 0 deletions dist/samples/test-example/app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"module": "esnext",
"target": "esnext",
"strict": true,
"noImplicitAny": false,
"lib": [
"es2015",
"esnext",
"es6",
"dom",
"dom.iterable"
],
"moduleResolution": "Node",
"jsx": "preserve"
}
}
5 changes: 5 additions & 0 deletions dist/samples/test-example/dist/assets/index-35dha72j.js

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

5 changes: 5 additions & 0 deletions dist/samples/test-example/dist/assets/index-kz-ac4rW.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*
* @license
* Copyright 2025 Google LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/#map{height:100%}html,body{height:100%;margin:0;padding:0}
27 changes: 27 additions & 0 deletions dist/samples/test-example/dist/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!doctype html>
<!--
@license
Copyright 2025 Google LLC. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
-->
<!--[START maps_test_example]-->
<html>
<head>
<title>Add a Map</title>

<script type="module" crossorigin src="./assets/index-35dha72j.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-kz-ac4rW.css">
</head>
<body>
<!--[START maps_test_example_heading]-->
<h3>My Google Maps Demo</h3>
<!--[END maps_test_example_heading]-->
<!--[START maps_test_example_body]-->
<div id="map"></div>
<!--[END maps_test_example_body]-->
<!-- 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"});</script>
</body>
</html>
<!--[END maps_test_example]-->
27 changes: 27 additions & 0 deletions dist/samples/test-example/docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!doctype html>
<!--
@license
Copyright 2025 Google LLC. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
-->
<!--[START maps_test_example]-->
<html>
<head>
<title>Add a Map</title>

<link rel="stylesheet" type="text/css" href="./style.css" />
<script type="module" src="./index.js"></script>
</head>
<body>
<!--[START maps_test_example_heading]-->
<h3>My Google Maps Demo</h3>
<!--[END maps_test_example_heading]-->
<!--[START maps_test_example_body]-->
<div id="map"></div>
<!--[END maps_test_example_body]-->
<!-- 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"});</script>
</body>
</html>
<!--[END maps_test_example]-->
30 changes: 30 additions & 0 deletions dist/samples/test-example/docs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"use strict";
/*
* @license
* Copyright 2025 Google LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
// [START maps_test_example]
// Initialize and add the map.
let map;
async function initMap() {
// [START maps_test_example_instantiate_map]
// The location of Uluru, Australia.
const position = { lat: -25.344, lng: 131.031 };
// Request the needed libraries.
const { Map } = await google.maps.importLibrary('maps');
const { AdvancedMarkerElement } = await google.maps.importLibrary('marker');
// The map, centered at Uluru, Australia.
map = new Map(document.getElementById('map'), {
zoom: 4,
center: position,
mapId: 'DEMO_MAP_ID',
});
// [END maps_test_example_instantiate_map]
// [START maps_test_example_instantiate_marker]
// The marker, positioned at Uluru.
const marker = new AdvancedMarkerElement({ map, position, title: 'Uluru' });
// [END maps_test_example_instantiate_marker]
}
initMap();
// [END maps_test_example]
35 changes: 35 additions & 0 deletions dist/samples/test-example/docs/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* @license
* Copyright 2025 Google LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

// [START maps_test_example]
// Initialize and add the map.
let map;
async function initMap(): Promise<void> {
// [START maps_test_example_instantiate_map]
// The location of Uluru, Australia.
const position = {lat: -25.344, lng: 131.031};

// Request the needed libraries.
const {Map} =
await google.maps.importLibrary('maps') as google.maps.MapsLibrary;
const {AdvancedMarkerElement} =
await google.maps.importLibrary('marker') as google.maps.MarkerLibrary;

// The map, centered at Uluru, Australia.
map = new Map(document.getElementById('map') as HTMLElement, {
zoom: 4,
center: position,
mapId: 'DEMO_MAP_ID',
});
// [END maps_test_example_instantiate_map]

// [START maps_test_example_instantiate_marker]
// The marker, positioned at Uluru.
const marker = new AdvancedMarkerElement({map, position, title: 'Uluru'});
// [END maps_test_example_instantiate_marker]
}
initMap();
// [END maps_test_example]
25 changes: 25 additions & 0 deletions dist/samples/test-example/docs/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* @license
* Copyright 2025 Google LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
/* [START maps_test_example] */
/*
* 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_test_example] */

25 changes: 25 additions & 0 deletions dist/samples/test-example/jsfiddle/demo.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* @license
* Copyright 2025 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;
}


7 changes: 7 additions & 0 deletions dist/samples/test-example/jsfiddle/demo.details
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: test-example
authors:
- Geo Developer IX Documentation Team
tags:
- google maps
load_type: h
description: Sample code supporting Google Maps Platform JavaScript API documentation.
Loading