Skip to content

Commit eee0974

Browse files
Update dist folder [skip ci] (#1065)
1 parent dffca95 commit eee0974

File tree

21 files changed

+821
-0
lines changed

21 files changed

+821
-0
lines changed

dist/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ <h1>Maps JSAPI Samples</h1>
6464
<li><a href='/samples/deckgl-kml-updated/dist'>deckgl-kml-updated</a></li>
6565
<li><a href='/samples/deckgl-polygon/dist'>deckgl-polygon</a></li>
6666
<li><a href='/samples/geocoding-reverse/dist'>geocoding-reverse</a></li>
67+
<li><a href='/samples/geocoding-simple/dist'>geocoding-simple</a></li>
6768
<li><a href='/samples/js-api-loader-map/dist'>js-api-loader-map</a></li>
6869
<li><a href='/samples/layer-data-event/dist'>layer-data-event</a></li>
6970
<li><a href='/samples/layer-data-quakes-red/dist'>layer-data-quakes-red</a></li>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": [
3+
"plugin:@typescript-eslint/recommended"
4+
],
5+
"parser": "@typescript-eslint/parser",
6+
"rules": {
7+
"@typescript-eslint/ban-ts-comment": 0,
8+
"@typescript-eslint/no-this-alias": 1,
9+
"@typescript-eslint/no-empty-function": 1,
10+
"@typescript-eslint/explicit-module-boundary-types": 1,
11+
"@typescript-eslint/no-unused-vars": 1
12+
}
13+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Google Maps JavaScript Sample
2+
3+
## geocoding-simple
4+
5+
This sample shows how to perform simple geocoding.
6+
7+
## Setup
8+
9+
### Before starting run:
10+
11+
`npm i`
12+
13+
### Run an example on a local web server
14+
15+
`cd samples/geocoding-simple`
16+
`npm start`
17+
18+
### Build an individual example
19+
20+
`cd samples/geocoding-simple`
21+
`npm run build`
22+
23+
From 'samples':
24+
25+
`npm run build --workspace=geocoding-simple/`
26+
27+
### Build all of the examples.
28+
29+
From 'samples':
30+
31+
`npm run build-all`
32+
33+
### Run lint to check for problems
34+
35+
`cd samples/geocoding-simple`
36+
`npx eslint index.ts`
37+
38+
## Feedback
39+
40+
For feedback related to this sample, please open a new issue on
41+
[GitHub](https://github.com/googlemaps-samples/js-api-samples/issues).
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<!DOCTYPE html>
2+
<!--
3+
@license
4+
Copyright 2026 Google LLC. All Rights Reserved.
5+
SPDX-License-Identifier: Apache-2.0
6+
-->
7+
<!-- [START maps_geocoding_simple] -->
8+
<html>
9+
<head>
10+
<title>Geocoding Service</title>
11+
12+
<link rel="stylesheet" type="text/css" href="./style.css" />
13+
<script type="module" src="./index.js"></script>
14+
<!-- prettier-ignore -->
15+
<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))})
16+
({key: "AIzaSyA6myHzS10YXdcazAFalmXvDkrYCp5cLc8", v: "weekly"});</script>
17+
</head>
18+
<body>
19+
<gmp-map center="-34.397, 150.644" zoom="10" map-id="DEMO_MAP_ID">
20+
<div id="floating-panel" slot="control-block-start-inline-start">
21+
<input
22+
type="text"
23+
id="address"
24+
placeholder="Enter an address or click the map to reverse geocode." />
25+
<br />
26+
<input type="button" id="submit" value="Geocode" />
27+
<input type="button" id="clear" value="Clear Results" />
28+
<br />
29+
</div>
30+
<pre id="response-container" slot="control-block-start-inline-end">
31+
<code id="response"></code>
32+
</pre>
33+
</gmp-map>
34+
</body>
35+
</html>
36+
<!-- [END maps_geocoding_simple] -->
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/**
2+
* @license
3+
* Copyright 2026 Google LLC. All Rights Reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
// [START maps_geocoding_simple]
8+
let geocoder: google.maps.Geocoder;
9+
let mapElement;
10+
let innerMap;
11+
let marker;
12+
let responseDiv;
13+
let response;
14+
15+
async function initMap() {
16+
// Request the needed libraries.
17+
const [{ Map, InfoWindow }, { Geocoder }, { AdvancedMarkerElement }] =
18+
await Promise.all([
19+
google.maps.importLibrary(
20+
'maps'
21+
) as Promise<google.maps.MapsLibrary>,
22+
google.maps.importLibrary(
23+
'geocoding'
24+
) as Promise<google.maps.GeocodingLibrary>,
25+
google.maps.importLibrary(
26+
'marker'
27+
) as Promise<google.maps.MarkerLibrary>,
28+
]);
29+
30+
// Get the gmp-map element.
31+
mapElement = document.querySelector(
32+
'gmp-map'
33+
) as google.maps.MapElement;
34+
35+
// Get the inner map.
36+
innerMap = mapElement.innerMap;
37+
38+
// Set the cursor to crosshair.
39+
innerMap.setOptions({
40+
mapTypeControl: false,
41+
fullscreenControl: false,
42+
cameraControlOptions: {
43+
position: google.maps.ControlPosition.INLINE_START_BLOCK_END,
44+
},
45+
draggableCursor: 'crosshair',
46+
});
47+
48+
49+
geocoder = new google.maps.Geocoder();
50+
51+
const inputText = document.getElementById('address') as HTMLInputElement;
52+
const submitButton = document.getElementById('submit') as HTMLInputElement;
53+
const clearButton = document.getElementById('clear') as HTMLInputElement;
54+
responseDiv = document.getElementById('response-container') as HTMLDivElement;
55+
response = document.getElementById('response') as HTMLPreElement;
56+
57+
marker = new google.maps.marker.AdvancedMarkerElement({});
58+
59+
innerMap.addListener('click', (e: google.maps.MapMouseEvent) => {
60+
geocode({ location: e.latLng });
61+
});
62+
63+
submitButton.addEventListener('click', () =>
64+
geocode({ address: inputText.value })
65+
);
66+
67+
clearButton.addEventListener('click', () => {
68+
clear();
69+
});
70+
71+
clear();
72+
}
73+
74+
async function clear() {
75+
marker.setMap(null);
76+
responseDiv.style.display = 'none';
77+
}
78+
79+
async function geocode(request: google.maps.GeocoderRequest) {
80+
clear();
81+
82+
geocoder
83+
.geocode(request)
84+
.then((result) => {
85+
const { results } = result;
86+
innerMap.setCenter(results[0].geometry.location);
87+
marker.position = new google.maps.LatLng(results[0].geometry.location);
88+
mapElement.append(marker);
89+
responseDiv.style.display = 'block';
90+
response.innerText = JSON.stringify(result, null, 2);
91+
return results;
92+
})
93+
.catch((e) => {
94+
alert('Geocode was not successful for the following reason: ' + e);
95+
});
96+
}
97+
98+
initMap();
99+
// [END maps_geocoding_simple]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "@js-api-samples/geocoding-simple",
3+
"version": "1.0.0",
4+
"scripts": {
5+
"build": "tsc && bash ../jsfiddle.sh geocoding-simple && bash ../app.sh geocoding-simple && bash ../docs.sh geocoding-simple && npm run build:vite --workspace=. && bash ../dist.sh geocoding-simple",
6+
"test": "tsc && npm run build:vite --workspace=.",
7+
"start": "tsc && vite build --base './' && vite",
8+
"build:vite": "vite build --base './'",
9+
"preview": "vite preview"
10+
}
11+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/**
2+
* @license
3+
* Copyright 2026 Google LLC. All Rights Reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
/* [START maps_geocoding_simple] */
7+
gmp-map {
8+
height: 100%;
9+
width: 100%;
10+
}
11+
12+
/*
13+
* Optional: Makes the sample page fill the window.
14+
*/
15+
html,
16+
body {
17+
height: 100%;
18+
margin: 0;
19+
padding: 0;
20+
}
21+
22+
#floating-panel {
23+
background-color: #fff;
24+
border-radius: 5px;
25+
box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;
26+
margin: 10px;
27+
padding: 5px;
28+
font: 400 18px Roboto, Arial, sans-serif;
29+
width: 350px;
30+
height: 100px
31+
}
32+
33+
#response-container {
34+
background-color: #fff;
35+
border: 0;
36+
border-radius: 5px;
37+
box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;
38+
padding: 5px;
39+
margin: 10px;
40+
font-size: small;
41+
width: 400px;
42+
background-color: rgba(255, 255, 255, 0.95);
43+
max-height: 70vh;
44+
overflow-x: auto;
45+
display: none;
46+
}
47+
48+
#address {
49+
width: 100%;
50+
padding: 10px;
51+
margin: 5px 0;
52+
box-sizing: border-box;
53+
}
54+
55+
#submit,
56+
#clear {
57+
background-color: #fff;
58+
border: 0;
59+
border-radius: 2px;
60+
box-shadow: 0 1px 4px -1px rgba(0, 0, 0, 0.3);
61+
height: 40px;
62+
cursor: pointer;
63+
}
64+
65+
#clear:hover {
66+
background: rgb(235, 235, 235);
67+
}
68+
69+
#submit {
70+
background-color: #1a73e8;
71+
color: white;
72+
}
73+
74+
#submit:hover {
75+
background-color: #1765cc;
76+
}
77+
78+
/* [END maps_geocoding_simple] */
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"compilerOptions": {
3+
"module": "esnext",
4+
"target": "esnext",
5+
"strict": true,
6+
"noImplicitAny": false,
7+
"lib": [
8+
"es2015",
9+
"esnext",
10+
"es6",
11+
"dom",
12+
"dom.iterable"
13+
],
14+
"moduleResolution": "Node",
15+
"jsx": "preserve"
16+
}
17+
}

dist/samples/geocoding-simple/dist/assets/index-5AI2bpO-.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/samples/geocoding-simple/dist/assets/index-ChKjFKk3.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)